-
1. Re: File upload
nbelaevski Sep 27, 2009 7:43 AM (in response to arkief)Hi arkief,
File upload cannot be done by AJAX, so a4j:commandButton won't work. -
2. Re: File upload
arkief Sep 27, 2009 10:57 AM (in response to arkief)What a pitty. So can it be done in a new window, or in an iFrame, and then just reRender the 'main'-form to display the results?
-
3. Re: File upload
ilya_shaikovsky Sep 28, 2009 4:42 AM (in response to arkief)Our fileUpload works in this way. Some guys created such workaround for thirdparty components some times ago and shared at this forum. Try to search for it there.
-
4. Re: File upload
arkief Sep 28, 2009 6:08 AM (in response to arkief)I found this article: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=105534&postdays=0&postorder=asc&start=10.
But the problem is, that I cannot find 'com.sun.faces.renderkit.html_basic.ButtonRenderer'. Do you know if there is a new class which does this work? -
5. Re: File upload
nbelaevski Sep 28, 2009 7:50 AM (in response to arkief)'com.sun.faces.renderkit.html_basic.ButtonRenderer' is available in JSF RI, are you using MyFaces?
-
6. Re: File upload
arkief Sep 28, 2009 8:52 AM (in response to arkief)Yes I'm using MyFaces. Does it not work with MyFaces?
-
7. Re: File upload
ilya_shaikovsky Sep 28, 2009 9:01 AM (in response to arkief)So just check for corresponding myFaces class.. it should be something like org.apache.renderkit...
-
8. Re: File upload
arkief Sep 29, 2009 2:56 AM (in response to arkief)It was the class 'org.apache.myfaces.renderkit.html.HtmlButtonRenderer'.
Now I just got it almost working. It compiles without errors, but when I open the site, I get the following error: "/pages/upload.jsp(6,70) PWC6188: The absolute uri: http://myfaces.apache.org/tomahawk/custom cannot be resolved in either web.xml or the jar files deployed with this application". -
9. Re: File upload
ilya_shaikovsky Sep 29, 2009 4:19 AM (in response to arkief)you sure you defined your taglib like:
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>
/META-INF/taglib/facelets-taglib-custom.xml
</param-value>
</context-param>
and carefully read this
Ok, seems some "glue" is screwed in the middle.
1) Your TLD file must use a namespace you havent used with another taglib, and it must declare the Tag class used. In my case <tag-class>org.apache.myfaces.custom.fileupload.HtmlAjaxFileUploadTag</tag-class>
2) Your faces-config must declare the component
<component-type>org.apache.myfaces.HtmlAjaxFileUpload</component-type>
<component-class>org.apache.myfaces.custom.fileupload.HtmlAjaxFileUpload</component-class>
The type can by anything BUT it MUST match HtmlAjaxFileUpload.COMPONENT_TYPE.
The class is the component class containing saveState and restoreState
3) Your faces-config must contain the way to render the component
<component-family>javax.faces.Input</component-family>
<renderer-type>org.apache.myfaces.AjaxFileUpload</renderer-type>
<renderer-class>org.apache.myfaces.custom.fileupload.HtmlAjaxFileUploadRenderer</renderer-class>
renderer-type can be anything BUT it MUST macth HtmlAjaxFileUpload.DEFAULT_RENDERER_TYPE
renderer-class must contain the class you're useing to render the component, that is the one containing the encodes/decode
4) All the glue is made thanks to the getComponentType() and getRendererType() in the tag class.
If you have this kind of "chain", you can make it to work. -
10. Re: File upload
arkief Sep 29, 2009 4:30 AM (in response to arkief)Thanks for the replay. Now it displays the page, but not the new control. The maven control displays the following errors:
1436780 [22629000@qtp-9206757-0] WARN org.apache.myfaces.renderkit.html.HtmlRenderKitImpl - Unsupported component-family/renderer-type: javax.faces.Input/org.apache.myfaces.AjaxFileUpload 2009-09-29 10:23:44.979:/kaleeo:INFO: No Renderer found for component {Component-Path : [Class: org.ajax4jsf.component.AjaxViewRoot,ViewId: /pages/register.xhtml][Class: org.ajax4jsf.component.html.AjaxForm,Id: registerForm][Class: org.richfaces.component.html.HtmlGraphValidator,Id: j_id6][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id7][Class: com.kaleeo.custom.fileupload.HtmlAjaxFileUpload,Id: fileUp]} (component-family=javax.faces.Input, renderer-type=org.apache.myfaces.AjaxFileUpload) 1436780 [22629000@qtp-9206757-0] WARN javax.faces.component.UIComponentBase - No Renderer found for component {Component-Path : [Class: org.ajax4jsf.component.AjaxViewRoot,ViewId: /pages/register.xhtml][Class: org.ajax4jsf.component.html.AjaxForm,Id: registerForm][Class: org.richfaces.component.html.HtmlGraphValidator,Id: j_id6][Class: javax.faces.component.html.HtmlPanelGrid,Id: j_id7][Class: com.kaleeo.custom.fileupload.HtmlAjaxFileUpload,Id: fileUp]} (component-family=javax.faces.Input, renderer-type=org.apache.myfaces.AjaxFileUpload) 1436780 [22629000@qtp-9206757-0] WARN org.apache.myfaces.renderkit.html.HtmlRenderKitImpl - Unsupported component-family/renderer-type: javax.faces.Input/org.apache.myfaces.AjaxFileUpload
My faces-config.xml... <component> <component-type>org.apache.myfaces.HtmlAjaxFileUpload</component-type> <component-class>com.kaleeo.custom.fileupload.HtmlAjaxFileUpload</component-class> <component-extension> <component-family>javax.faces.Input</component-family> <renderer-type>org.apache.myfaces.AjaxFileUpload</renderer-type> <renderer-class>com.kaleeo.custom.fileupload.HtmlAjaxFileUploadRenderer</renderer-class> </component-extension> </component> ...
My web.xml... <context-param> <param-name>facelets.LIBRARIES</param-name> <param-value>/WEB-INF/facelets/custom.taglib.xml</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.custom.uploadMaxFileSize</param-name> <param-value>1048576</param-value> </context-param> <context-param> <param-name>org.apache.myfaces.custom.uploadDirectory</param-name> <param-value>/upload</param-value> </context-param> <servlet> <servlet-name>UploadServlet</servlet-name> <servlet-class>com.kaleeo.custom.fileupload.AjaxFileUploadServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>UploadServlet</servlet-name> <url-pattern>/uploadHtml</url-pattern> </servlet-mapping> ...
My HtmlAjaxFileUpload.java:... public class HtmlAjaxFileUpload extends HtmlInputFileUpload { public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlAjaxFileUpload"; public static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.AjaxFileUpload"; ...
My /WEB-INF/facelets.custom.taglib.xml:<?xml version="1.0"?> <!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "http://java.sun.com/dtd/facelet-taglib_1_0.dtd"> <facelet-taglib xmlns="http://java.sun.com/JSF/Facelet"> <namespace>http://myfaces.apache.org/tomahawk/custom</namespace> <tag> <tag-name>ajaxFileUpload</tag-name> <component> <component-type>org.apache.myfaces.HtmlAjaxFileUpload</component-type> <renderer-type>org.apache.myfaces.AjaxFileUpload</renderer-type> </component> </tag> </facelet-taglib>
And /WEB-INF/tld/customtags.xml... <name>ajaxFileUpload</name> <tag-class>com.kaleeo.custom.fileupload.HtmlAjaxFileUploadTag</tag-class> ...
I am really sorry for bothering you so much. I never wrote custom components, though I am trying to dig my head in the code.
Thanks!!