1
votes

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.

1
Seems your bean does not implement something the renderer needs. Look into sources of that method in stacktrace. - Frantisek Kossuth
Probably, yes. What I forgot to mention is that the page doesn't even load the first time. The stack trace doesn't contain any of my sources. I'll check again. Maybe some "Implements" in Java is missing or so. - D.Bugger
Is there anybody who knows what happens in FileuploadRendererEx.java on line 371?? - D.Bugger

1 Answers

1
votes
/* 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.