I am using <rich:fileupload> and I need to send some extra parameters to my Controller. I tried to use <f:param> for this.
Here is the view:
<rich:fileUpload
fileUploadListener="#{fileUploadController.listener}"
maxFilesQuantity="#{fileUploadController.uploadsAvailable}"
addControlLabel="Hinzufügen"
uploadControlLabel="Hochladen"
cancelEntryControlLabel="Abbrechen"
doneLabel="Fertig"
clearAllControlLabel="Alle entfernen"
noDuplicate="true"
stopControlLabel="Stop"
clearControlLabel="Entfernen"
id="upload"
immediateUpload="#{fileUploadController.autoUpload}"
ajaxSingle="true"
acceptedTypes="jpg"
allowFlash="#{fileUploadController.useFlash}"
rerender="info">
<a4j:support event="onuploadcomplete" reRender="info" status="globalStatus" />
<f:param
value="#{imageFormat}"
name="#{fileUploadController.imageFormat}"/>
</rich:fileUpload>
Here is the FileUploadController backing bean:
private String imageFormat;
public void setImageFormat(String imageFormat) {
this.imageFormat = imageFormat;
}
public String getImageFormat() {
return imageFormat;
}
However, the setter is never called, so the variable is always null. The #{imageFormat} has the correct value, I verified it with an <h:outputText>.
I can’t use <a4j:param>, because there is no button to hook on.
We are using JSF 1.2, not JSF 2.0.
To perform some operations on specific phases of upload, you can attach to an event of rich:fileUpload. Along with standard events, rich:fileUpload provides a number of specific events:
client side
are uploaded
via cancel control
according to any errors
To invoke server side logic using AJAX when event occurs, use ‘a4j:status’ or ‘a4j:jsFunction’, for example using ‘a4j:status’:
and using ‘a4j:jsFunction’ (also demonstrated how to use setPropertyActionListener, it is for case if your EL resolver does not support method invocations with parameters (refer to BalusC comment))