webtier@glassfish.java.net

JSF 2.0 Custom Tag Library

From: <forums_at_java.net>
Date: Sat, 13 Nov 2010 03:27:07 -0800

Hello

I am developing a workflow that download and upload files from the FileSystem
to an Oracle database. Based on Jim Driscoll's blog and the and BalusC's blog
at

http://balusc.blogspot.com/2009/12/uploading-files-with-jsf-20-and-servl...
[1]

I am developing a needed custom tag HtmlInputFile. Here it is,

<code>

import javax.faces.component.FacesComponent;
import javax.faces.component.html.HtmlInputText;

/**
* Faces component for <code>input type="file"</code> field.
*
* @author BalusC
* @link
http://balusc.blogspot.com/2009/12/uploading-files-with-jsf-20-and-servlet.html
[2]
*/
@FacesComponent(value = "HtmlInputFile")
public class HtmlInputFile extends HtmlInputText {

// Getters
------------------------------------------------------------------------------------

@Override
public String getRendererType() {
return "javax.faces.File";
}
}

</code>

This class extends HtmlInputText so the idea is that it heritage all the
properties and attributes.

Now the tag library,

<code>

<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee [3]"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance [4]"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee [5]
http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd [6]"
version="2.0">
<namespace>http://balusc.net/jsf/html</namespace>
<tag>
<tag-name>inputFile</tag-name>
<component>
<component-type>HtmlInputFile</component-type>
</component>
</tag>
</facelet-taglib>

</code>

and the web.xml,

<code>

<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/balusc.taglib.xml</param-value>
</context-param>

</code>

Finally the xhtml,

<hh:inputFile id="file" value="#{tomaRequisitosManagedBean.file}" />

Well, the xhtml file does not recognize the atributte 'value' and I do not
know why.

Any idea about it?

Thanks in advance,

Jose


[1]
http://balusc.blogspot.com/2009/12/uploading-files-with-jsf-20-and-servlet.html
[2]
http://balusc.blogspot.com/2009/12/uploading-files-with-jsf-20-and-servlet.html
[3] http://java.sun.com/xml/ns/javaee
[4] http://www.w3.org/2001/XMLSchema-instance
[5] http://java.sun.com/xml/ns/javaee
[6] http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd

--
[Message sent by forum member 'josealvarezdelara']
View Post: http://forums.java.net/node/717560