We developed a form and fields using a backing bean. The upload used won't work, loading the page stops after the afterRenderResponse, for some reason:
<xp:fileUpload value="#{field.fileUpload}" id="fileUpload1">
<xp:this.attrs>
<xp:attr name="alias" value="#{form.name}.#{field.fieldName}"></xp:attr>
</xp:this.attrs>
</xp:fileUpload>
The code in the bean:
private UploadedFile uploadedFile= null;
public FieldData(Field field) {
this.field = field;
this.value = field.getFieldValue();
System.err.print("new FieldData: " + field.getFieldName());
}
public UploadedFile getFileUpload() {
System.err.print("getFileUpload");
return uploadedFile;
}
public void setFileUpload(UploadedFile to) {
System.err.print("setFileUpload " + to);
this.uploadedFile = to;
}
The error I keep on getting:
java.lang.NullPointerException
at com.ibm.xsp.renderkit.html_extended.FileuploadRendererEx.encodeEnd(FileuploadRendererEx.java:371)
at com.ibm.xsp.renderkit.ReadOnlyAdapterRenderer.encodeEnd(ReadOnlyAdapterRenderer.java:180)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:1005)
at com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:857)
and many more lines.
Other types of fields behave nicely, except for this one. Just as an example, a text field is defined as:
<xp:inputText type="text" value="#{field.fieldValue}" id="inputText1">
<xp:this.attrs>
<xp:attr name="required" value="true" rendered="#{javascript:field.isRequired()}"></xp:attr>
<xp:attr name="alias" value="#{form.name}.#{field.fieldName}"></xp:attr>
</xp:this.attrs>
</xp:inputText>
I have beans form and field, with the necessary getter and setter functions.
The error happens somewhere in XPages, and not in my code. If I comment the upload control out, everything else works. Can someone please shed some light on why I always get a null pointer exception? Thanks!!
EDIT some clarifications added, especially the fact that the error occurs after the afterRenderResponse step. I print a simple trace of all events in every custom control, and there is no difference in the trace when I use the upload control or not, they are identical including the last afterRenderresponse event.
/* 370 */ Object localObject1 = getForm(paramUIComponent);
/* 371 */ String str3 = ((UIForm)localObject1).getClientId(paramFacesContext);
JD-Eclipse is very useful tool, works with Domino Designer. Works perfectly with Java debugging, including breakpoints.
To locate the class, use this hint: Assistance locating jar containing Domino/XPages classes
My guess: file upload control misses reference to form. Possibly the component is outside the form, or the form rendering is disabled.