JSF +丰富:文件上传 +参数
我正在使用
并且我需要向我的控制器发送一些额外的参数。我尝试为此使用
。
视图如下:
<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>
这是 FileUploadController
支持 bean:
private String imageFormat;
public void setImageFormat(String imageFormat) {
this.imageFormat = imageFormat;
}
public String getImageFormat() {
return imageFormat;
}
但是,永远不会调用 setter,因此变量始终为 null
。 #{imageFormat}
具有正确的值,我使用
对其进行了验证。
我无法使用
,因为没有可以挂接的按钮。
我们使用的是 JSF 1.2,而不是 JSF 2.0。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要在上传的特定阶段执行某些操作,您可以附加到 rich:fileUpload 事件。除了标准事件之外,rich:fileUpload 还提供了许多特定事件:
客户端
上传
通过取消控制
根据任何错误
要在事件发生时使用 AJAX 调用服务器端逻辑,请使用 'a4j:status' 或 'a4j:jsFunction',例如使用 'a4j:status':
并使用 'a4j:jsFunction' (还演示了如何使用setPropertyActionListener,适用于您的 EL 解析器不支持带参数的方法调用的情况(请参阅 BalusC 注释))
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))