[英]Richfaces render with a4j:ajax
我有一个页面使用rich:fileUpload
和a4j:commandButton
我想要实现的是,第一次加载页面时会出现fileUpload(渲染,我的backingBean默认为true,因此它呈现正确)并且当用户点击commandButton我很想隐藏fileUpload并显示一个outputText
(这没有发生,根本没有错误)
我怎么能解决这个问题,我的网页看起来像
<div id="content">
<a4j:outputPanel id="contentForm">
<h:form enctype="multipart/form-data"
rendered="#{uploadBean.formRendered}">
<br/><br/>
<h:selectOneRadio value="#{uploadBean.selectedOption}">
<f:selectItems value="#{uploadBean.loadOptions}"/>
</h:selectOneRadio>
<br/>
<rich:fileUpload addLabel="Agregar" clearAllLabel="Quitar todos"
clearLabel="Quitar" deleteLabel="Quitar"
doneLabel="Completado" uploadLabel="Subir archivos"
fileUploadListener="#{uploadBean.doUpload}"
acceptedTypes="txt, csv"
noDuplicate="true"/>
<a4j:commandButton value="Iniciar validación"
action="#{uploadBean.doLaunchProcess}"
render="processLabel"
execute="@form"
/>
</h:form>
</a4j:outputPanel>
<a4j:outputPanel id="processLabel">
<h:outputText
value="#{uploadBean.processStarted}"
rendered="#{not uploadBean.formRendered}"/>
</a4j:outputPanel>
</div>
而commandButton的动作代码是:
public String doLaunchProcess() {
formRendered = false;
InfoValidator iv = new InfoValidator(loadOptions,
selectedOption, userBean.getDependencia(),
userBean.getTipoDependencia(), userBean.getUsuario(),
userBean.getIdUsuario(), userBean.getEmail());
iv.start();
return "carga-archivos";
}
似乎formRendered
总是被评估为true,当我希望一旦用户单击该按钮它为false,所以fileUpload隐藏并显示outputText。
更新基本上我想要的是当用户点击按钮时用户上传文件,fileUpload组件消失并出现outputText,并说“谢谢上传”
也许我的方法是错的,只是把我放在正确的方向,我有点混淆ajax的东西。
干杯,
最后我做到了!
这是代码,因此您可以看到修改。 基本上我必须处理整个表单( execute="@form"
),其中a4j:commandButton已经然后render="contentForm :processLabel"
。
我只是渲染(reRendering?)只是processLabel而且表单始终存在'因为我没有更新视图(我认为这必须是DOM树,有人请澄清这个)
<div id="content">
<a4j:outputPanel id="contentForm">
<h:form enctype="multipart/form-data"
rendered="#{uploadBean.formRendered}">
<br/><br/>
<h:selectOneRadio value="#{uploadBean.selectedOption}">
<f:selectItems value="#{uploadBean.loadOptions}"/>
</h:selectOneRadio>
<br/>
<rich:fileUpload addLabel="Agregar" clearAllLabel="Quitar todos"
clearLabel="Quitar" deleteLabel="Quitar"
doneLabel="Completado" uploadLabel="Subir archivos"
fileUploadListener="#{uploadBean.doUpload}"
acceptedTypes="txt, csv"
noDuplicate="true"/>
<a4j:commandButton value="Iniciar validación"
action="#{uploadBean.doLaunchProcess}"
render="contentForm :processLabel"/>
</h:form>
</a4j:outputPanel>
<a4j:outputPanel id="processLabel">
<h:outputText
value="#{uploadBean.processStarted}"
rendered="#{not uploadBean.formRendered}"/>
</a4j:outputPanel>
</div>
支持bean保持不变。
干杯!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.