-
15. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
fabmars Aug 18, 2007 2:23 PM (in response to holgerprause)Since I posted all this code a few days ago, I changed 3 things :
1) You may get some duplicate IDs errors. Indeed, at the first page call, you have the component tree created, and a call to encode. There, the HtmlCommandButton and the HtmlAjaxFunction are created programatically, but only the HtmlAjaxFunction is added to the tree as you can see in the code. Then you upload some stuff, you only update another part of the page, so as most, you have a restoreState, decode, saveState, the tree is unchanged. In the end you submit your whole form (not the hidden one, but the actual form of the page), and if the same page is displayed, you have restoreState, decode, encode, saveState. This encode adds the HtmlAjaxFunction once again to the tree and JSF always checks such things !!!
So i added a boolean _ajaxEnhanced into my HtmlAjaxInputFile component, that has protected get/sets and that is also taken into account durung saveState and restoreState. Then I test this flag before adding of not the HtmlAjaxFunction programatically during encode.
2) I added the flags _ajaxSingle (and _ajaxSingleSet, I did like in other a4j components) into my HtmlAjaxInputFile. These flags are taen into account into saveState and restoreState, and they are copied into the HtmlAjaxFunction a the time it's created programatically, at encode time. Nevertheless, ajaxSingle doesnt seem to work correctly in the jsFunction...
3) After each upload, the input file component would still display the previously selected upload file path. Actually the component's value is reset to null as expected but the component in the view isn't updated. So, when you submit the whole form, the file would get uploaded again ! Two solutions ot that: either add the input file id to its own reRender attribute, or add it programatically, again in the encode phase.
All in one, here's the modified code :
HtmlAjaxFileUpload.javapackage org.apache.myfaces.custom.fileupload; import javax.faces.context.FacesContext; import javax.faces.el.ValueBinding; import org.apache.myfaces.custom.fileupload.HtmlInputFileUpload; import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils; 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"; private boolean _ajaxSingle = false; private boolean _ajaxSingleSet = false; private String _reRender = null; private String _buttonValue = null; private boolean _ajaxEnhanced = false; public HtmlAjaxFileUpload() { super(); setRendererType(DEFAULT_RENDERER_TYPE); } /** * if "true", submits ONLY one field/link, instead of all form controls * Setter for ajaxSingle * @param ajaxSingle - new value */ public void setAjaxSingle(boolean __ajaxSingle) { this._ajaxSingle = __ajaxSingle; this._ajaxSingleSet = true; } /** * if "true", submits ONLY one field/link, instead of all form controls * Getter for ajaxSingle * @return ajaxSingle value from local variable or value bindings */ public boolean isAjaxSingle() { if (this._ajaxSingleSet) { return this._ajaxSingle; } ValueBinding vb = getValueBinding("ajaxSingle"); if (vb != null) { Boolean value = (Boolean) vb.getValue(getFacesContext()); if (null == value) { return this._ajaxSingle; } return (value.booleanValue()); } else { return (this._ajaxSingle); } } public String getReRender() { if (_reRender != null) return _reRender; ValueBinding vb = getValueBinding("reRender"); return vb != null ? RendererUtils.getStringValue(getFacesContext(), vb) : null; } public void setReRender(String string) { _reRender = string; } public String getButtonValue() { if (_buttonValue != null) return _buttonValue; ValueBinding vb = getValueBinding("buttonValue"); return vb != null ? RendererUtils.getStringValue(getFacesContext(), vb) : null; } public void setButtonValue(String string) { _buttonValue = string; } protected boolean isAjaxEnhanced() { return _ajaxEnhanced; } protected void setAjaxEnhanced(boolean enhanced) { _ajaxEnhanced = enhanced; } public Object saveState(FacesContext context) { Object values[] = new Object[6]; values[0] = super.saveState(context); values[1] = new Boolean(_ajaxSingle); values[2] = Boolean.valueOf(_ajaxSingleSet); values[3] = _reRender; values[4] = _buttonValue; values[5] = new Boolean(_ajaxEnhanced); return ((Object) (values)); } public void restoreState(FacesContext context, Object state) { Object values[] = (Object[])state; super.restoreState(context, values[0]); _ajaxSingle = ((Boolean) values[1]).booleanValue(); _ajaxSingleSet = ((Boolean) values[2]).booleanValue(); _reRender = (String)values[3]; _buttonValue = (String)values[4]; _ajaxEnhanced = ((Boolean) values[5]).booleanValue(); } }
HtmlAjaxFileUploadRenderer.javapackage org.apache.myfaces.custom.fileupload; import java.io.IOException; import java.util.Map; import javax.faces.component.UIComponent; import javax.faces.component.html.HtmlCommandButton; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import javax.faces.convert.ConverterException; import org.ajax4jsf.ajax.html.HtmlAjaxFunction; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.myfaces.component.UserRoleUtils; import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils; import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML; import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils; import org.richfaces.renderkit.InputRendererBase; import com.sun.faces.renderkit.html_basic.ButtonRenderer; public class HtmlAjaxFileUploadRenderer extends InputRendererBase { private static final Log log = LogFactory.getLog(HtmlAjaxFileUploadRenderer.class); private final static String NAME_CLEAN_REGEX = "[^a-zA-Z0-9]"; public final static String INPUTFILE_ID = "id"; public final static String INPUTFILE_PREFIX = "upload"; public final static String CALLBACK_SUCCESS_SUFFIX = "cb_success"; public final static String CALLBACK_FAIL_SUFFIX = "cb_fail"; public final static String CALLBACK_RERENDER_SUFFIX = "cb_rerender"; public final static String DEFAULT_BUTTON_VALUE = "Upload"; /** * @see http://jboss.com/index.html?module=bb&op=viewtopic&t=105534 * @see http://www.ibm.com/developerworks/library/wa-facescomp3/ * @see http://developer.apple.com/internet/webcontent/iframe.html */ public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException { super.encodeEnd(facesContext, uiComponent); //check for NP ResponseWriter writer = facesContext.getResponseWriter(); HtmlAjaxFileUpload inputFileComponent = (HtmlAjaxFileUpload)uiComponent; String clientId = uiComponent.getClientId(facesContext); String idSuffix = clientId.replaceAll(NAME_CLEAN_REGEX, "_"); //to conform to the jsf spec about ids String spanId = "span_" + idSuffix; writer.startElement(HTML.SPAN_ELEM, uiComponent); writer.writeAttribute(HTML.ID_ATTR, spanId, null); //file input writer.startElement(HTML.INPUT_ELEM, uiComponent); writer.writeAttribute(HTML.TYPE_ATTR, HTML.FILE_ATTR, null); writer.writeAttribute(HTML.ID_ATTR, clientId, null); writer.writeAttribute(HTML.NAME_ATTR, clientId, null); UploadedFile value = (UploadedFile)inputFileComponent.getValue(); if (value != null) { if( value.getName() != null ) { writer.writeAttribute(HTML.VALUE_ATTR, value.getName(), null); } } HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.INPUT_FILE_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED); if (isDisabled(facesContext, uiComponent)) { writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null); } writer.endElement(HTML.INPUT_ELEM); String frameFunc = makeFuncName(clientId, "onclick"); String contextPath = facesContext.getExternalContext().getRequestContextPath(); String actionUrl = contextPath + "/uploadHtml?" + INPUTFILE_ID + "=" + clientId; String hFrameId = "hifrm_" + idSuffix; String hFormId = "hform_" + idSuffix; String buttonId = "upbtn_" + idSuffix; String buttonValue = inputFileComponent.getButtonValue(); if(buttonValue == null) { buttonValue = DEFAULT_BUTTON_VALUE; } // Adding the upload button. // No need to maintain any flag like the ajaxEnhanced one for the jsFunction // because this component isn't added to the inputFileComponents' children HtmlCommandButton uploadButton = new HtmlCommandButton(); uploadButton.setId(buttonId); uploadButton.setType(HTML.BUTTON_ELEM); uploadButton.setValue(buttonValue); String submitCall = frameFunc + "('" + actionUrl + "','" + hFrameId + "','" + hFormId + "');"; uploadButton.setOnclick(submitCall); ButtonRenderer btRenderer = new ButtonRenderer(); btRenderer.encodeBegin(facesContext, uploadButton); //btRenderer.encodeChildren(facesContext, uploadButton); //not needed btRenderer.encodeEnd(facesContext, uploadButton); writer.endElement(HTML.SPAN_ELEM); writer.write("\n"); writer.write("\n"); // Adding the IFRAME remote scripting trick writer.startElement(HTML.SCRIPT_ELEM, null); writer.writeAttribute(HTML.LANG_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null); writer.writeText("//<![CDATA[", null); // Hidden iframe creation writer.write("\n"); writer.writeText("function " + frameFunc + "(actionUrl, frameId, formId) {", null); writer.writeText("if (!document.createElement) {", null); writer.writeText("alert('Cannot create elements for uploading');", null); writer.writeText("return;", null); writer.writeText("}", null); writer.writeText("var ie = false;", null); writer.writeText("if (navigator.appName == \"Microsoft Internet Explorer\") {", null); writer.writeText("ie = true;", null); writer.writeText("}", null); writer.writeText("var sIframe = (ie)?'<iframe name=\"' + frameId + '\"></iframe>':'iframe';", null); writer.writeText("var hIFrame = document.createElement(sIframe);", null); writer.writeText("hIFrame.setAttribute('id',frameId);", null); writer.writeText("if (!ie) {", null); writer.writeText("hIFrame.setAttribute('name', frameId);", null); writer.writeText("}", null); writer.writeText("hIFrame.src='javascript:false';", null); writer.writeText("hIFrame.style.border = '0px';", null); writer.writeText("hIFrame.style.width = '0px';", null); writer.writeText("hIFrame.style.height = '0px';", null); writer.writeText("var IFrameObj = document.body.appendChild(hIFrame);", null); // this is for IE5 Mac, because it will only // allow access to the document object // of the IFrame if we access it through // the document.frames array writer.writeText("if (document.frames) {", null); writer.writeText("IFrameObj = document.frames[frameId];", null); writer.writeText("}", null); writer.writeText("if (navigator.userAgent.indexOf('Gecko') !=-1) {", null); writer.writeText("while(!IFrameObj.contentDocument) {", null); // we have to wait for NS6 to recognize the new IFrame writer.writeText("}", null); writer.writeText("}", null); // Hidden form creation writer.writeText("var hForm = document.createElement('form');", null); writer.writeText("hForm.id = formId;", null); writer.writeText("hForm.style.width = '0px';", null); writer.writeText("hForm.style.height = '0px';", null); writer.writeText("hForm.style.border = '0px';", null); writer.writeText("document.body.appendChild(hForm);", null); writer.writeText("hForm.target = frameId;", null); writer.writeText("hForm.encoding = 'multipart/form-data';", null); //for IE6 writer.writeText("hForm.enctype = 'multipart/form-data';", null); writer.writeText("hForm.method = 'post';", null); writer.writeText("hForm.action = actionUrl;", null); //passing input file client id writer.writeText("var fSpan = document.getElementById('" + spanId + "');", null); writer.writeText("var fInput = document.getElementById('" + clientId + "');", null); writer.writeText("fSpan.removeChild(fInput);", null); writer.writeText("hForm.appendChild(fInput);", null); writer.writeText("var fButton = document.getElementById('" + buttonId + "');", null); writer.writeText("fSpan.removeChild(fButton);", null); writer.writeText("hForm.appendChild(fButton);", null); writer.writeText("hForm.submit();", null); writer.writeText("hForm.removeChild(fInput);", null); writer.writeText("fSpan.appendChild(fInput);", null); writer.writeText("hForm.removeChild(fButton);", null); writer.writeText("fSpan.appendChild(fButton);", null); writer.writeText("}", null); writer.write("\n"); String reRenderFuncName = makeFuncName(clientId, CALLBACK_RERENDER_SUFFIX); String callbackFuncName = makeFuncName(clientId, CALLBACK_SUCCESS_SUFFIX); writer.writeText("function " + callbackFuncName + "() {", null); //writer.writeText("alert('Upload success');", null); writer.writeText(reRenderFuncName + "();", null); writer.writeText("}", null); String failFuncName = makeFuncName(clientId, CALLBACK_FAIL_SUFFIX); writer.writeText("function " + failFuncName + "(name) {", null); writer.writeText("alert('Upload failed:' + name);", null); writer.writeText(reRenderFuncName + "();", null); writer.writeText("}", null); writer.write("\n"); writer.writeText("//]]>", null); writer.endElement(HTML.SCRIPT_ELEM); writer.write("\n"); if(!inputFileComponent.isAjaxEnhanced()) { HtmlAjaxFunction reRenderFunction = new HtmlAjaxFunction(); inputFileComponent.getChildren().add(reRenderFunction); //must be added downstream reRenderFunction.setParent(inputFileComponent); // and upstream ! reRenderFunction.setName(reRenderFuncName); reRenderFunction.setAjaxSingle(inputFileComponent.isAjaxSingle()); String reRender = inputFileComponent.getReRender(); if(reRender == null) { reRender = clientId; } else { reRender += "," + clientId; } reRenderFunction.setReRender(reRender); reRenderFunction.encodeBegin(facesContext); //reRenderFunction.encodeChildren(facesContext); //not needed reRenderFunction.encodeEnd(facesContext); inputFileComponent.setAjaxEnhanced(true); } } public static String makeFuncName(String id, String suffix) { return "func_" + id.replaceAll(NAME_CLEAN_REGEX, "_") + '_' + suffix.replaceAll(NAME_CLEAN_REGEX, "_"); } protected boolean isDisabled(FacesContext facesContext, UIComponent uiComponent) { if (!UserRoleUtils.isEnabledOnUserRole(uiComponent)) { return false; } else { if (uiComponent instanceof HtmlAjaxFileUpload) { return ((HtmlAjaxFileUpload)uiComponent).isDisabled(); } else { return RendererUtils.getBooleanAttribute(uiComponent, HTML.DISABLED_ATTR, false); } } } public void decode(FacesContext facesContext, UIComponent uiComponent) { super.decode(facesContext, uiComponent); //check for NP System.out.println("***** DECODE *****"); HtmlAjaxFileUpload inputFileComponent = (HtmlAjaxFileUpload) uiComponent; Map sessionMap = facesContext.getExternalContext().getSessionMap(); String key = INPUTFILE_PREFIX + '_' + uiComponent.getClientId(facesContext); Object obj = sessionMap.get(key); if(obj != null) { if(obj instanceof UploadedFile) { inputFileComponent.setSubmittedValue(obj); inputFileComponent.setValid(true); } else { log.warn("Content of key " + key + " was not an UploadedFile"); } } } public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException { if(submittedValue instanceof UploadedFile) { UploadedFile file = (UploadedFile) submittedValue; if(file.getName() != null && file.getName().length() > 0) { return file; } } return null; } }
-
16. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
fabmars Aug 18, 2007 3:15 PM (in response to holgerprause)There's an obvious bug in the renderer's decode(). The correct one is :
public void decode(FacesContext facesContext, UIComponent uiComponent) { super.decode(facesContext, uiComponent); //check for NP HtmlAjaxFileUpload inputFileComponent = (HtmlAjaxFileUpload) uiComponent; Map sessionMap = facesContext.getExternalContext().getSessionMap(); String key = INPUTFILE_PREFIX + '_' + uiComponent.getClientId(facesContext); Object obj = sessionMap.get(key); if(obj != null) { sessionMap.remove(key); if (obj instanceof UploadedFile) { inputFileComponent.setSubmittedValue(obj); inputFileComponent.setValid(true); } else { log.warn("Content of key " + key + " was not an UploadedFile"); } } }
-
17. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
icai Aug 28, 2007 8:57 PM (in response to holgerprause)Hi,
I tried using the custom tag as you have explained here. Everything compiles but when I run the App I get following error :javax.faces.FacesException: Expression Error: Named Object: 'com.etc.ist.isell.customTags.HtmlAjaxFileUpload' not found. at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:380) at javax.faces.webapp.UIComponentTag.createComponent(UIComponentTag.java:1023) at javax.faces.webapp.UIComponentTag.createChild(UIComponentTag.java:1046) at javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:761) at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:451) at _search._jspService(_search.java:1570) [/search.jsp] .......
Can you pleaes point out wat could be wrong !
I'll appreciate any help a great deal.
Thanks! -
18. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
fabmars Aug 29, 2007 6:06 AM (in response to holgerprause)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. -
19. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
icai Aug 29, 2007 2:14 PM (in response to holgerprause)Hi Fabmars
Thanks a lot for replying. I made the changes you suggested. Before making these changes I observed that execution failed at getComponentType() of HtmlAjaxFileUploadTag class. Now after applying the changes I dont get the old error but I get following :java.lang.NullPointerException at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:703) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:463) at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:253) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:721) at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:465) at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:253) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:721) at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282) at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262) at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:284) at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262) at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:284) at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262) at org.ajax4jsf.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:79) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:721) at javax.faces.webapp.UIComponentTag.encodeChildren(UIComponentTag.java:629) at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:566) at _search._jspService(_search.java:3183)
Can you please point out where could be the problem?
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! -
20. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
fabmars Aug 30, 2007 12:04 PM (in response to holgerprause)Sorry, no clue. Isn't there a CAUSE for this error ? Your NPE gives no info.
It wasn't my first JSf component but it was the first one trying to mix Tomahawk and A4J stuff, and it was a pain too, so my knowledge stops at the internal workings of each framework me component is build on top of.
I did that "freestyle" component and tested it with JSF 1.1 RI. Maybe it will screw up using v1.2 or MyFaces impl, I can't tell, I haven't tried. This is no official stuff at all.
What version are you using, on what app server ?
Can you give me the line you've put in your jsp/jspx/xhtml so that i can check nothing is missing ? -
21. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
icai Aug 30, 2007 2:33 PM (in response to holgerprause)Hi Fabmars
First, Thanks for replying!
Here are the details from my code:
jsf version 1.1_02, tomahawk 1.1.6, richfaces RC2, server OC4J.
Following is the tablib declaration in my jsp :
jsp:<%@ taglib uri="http://myfaces.apache.org/tomahawk/custom" prefix="tc"%>
faces-config.xml:<component> <component-type>org.apache.myfaces.HtmlAjaxFileUpload</component-type> <component-class>org.apache.myfaces.custom.fileupload.HtmlAjaxFileUpload</component-class> <component-extension> <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> </component-extension> </component>
web.xml<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-name>UploadServlet</servlet-name> <servlet-class>org.apache.myfaces.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>
Rest of the code is also what I got from this thread. -
22. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
fabmars Aug 31, 2007 4:03 AM (in response to holgerprause)Hi,
So this is clear, from your former code, you've refactored the classes I gave to the package com.etc.ist.isell.customTags, nevertheless, you kept the old packages names org.apache.myfaces.custom.fileupload in the config files. This explains that. -
23. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
icai Aug 31, 2007 11:26 AM (in response to holgerprause)Hi Fabmars,
I had created another package : org.apache.myfaces.custom.fileupload after I got error on my refracted classes. I thought that some mismatch might be occuring somewhere in code so I got rid of com.etc.ist.isell.customTags package.
Error I mentioned is coming after that. My code is excat copy of the one given by you here.
Thanks! -
24. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
icai Aug 31, 2007 11:56 AM (in response to holgerprause)infact I get the following error now:
javax.servlet.jsp.JspException at com.sun.faces.taglib.html_basic.PanelGridTag.doEndTag(PanelGridTag.java:470) at _ajaxFileUpload._jspService(_ajaxFileUpload.java:91) [/ajaxFileUpload.jsp]
-
25. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
fabmars Sep 1, 2007 9:01 AM (in response to holgerprause)Can you give the code on your jsp please ?
-
26. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
icai Sep 1, 2007 2:35 PM (in response to holgerprause)Hi Fabmars,
Thanks for replying!
Here is the code of JSP (I created a test page as you had written here one)<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page contentType="text/html;charset=ISO-8859-1"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://myfaces.apache.org/tomahawk/custom" prefix="tc"%> <f:view> <html> <head> <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8"/> <title>welcome</title> </head> <body><h:form> <h:panelGrid columns="3"> <h:outputLabel value="Upload: "/> <tc:ajaxFileUpload id="fileUp" value="#{inputFileBean.uploadedFile}" reRender="fileName, fileSize"/> <h:outputLabel value="File name: "/> <h:outputText id="fileName" value="#{inputFileBean.uploadedFile.name}"/> <h:outputText value="File size: "/> <h:outputText id="fileSize" value="#{inputFileBean.uploadedFile.size}"/> </h:panelGrid> </h:form></body> </html> </f:view>
-
27. Re: t:inputFileUpload or s:fileUpload with ajax4jsf
khanmurtuza Sep 23, 2007 12:16 PM (in response to holgerprause)first thanks for the code..i was looking for something similar..I tried it it works..but I do get an error message on IE...any idea..I used firebug in fire fox to debug got a javascipt error..
form has no properties
oamSetHiddenInput("linkDummyForm", "autoScroll", "0,0")orderList.jsf (line 54)
onclick(click clientX=0, clientY=0)
..
..
if(typeof form.elements[name]=='undefined')