【发布时间】:2013-05-25 13:36:33
【问题描述】:
我正在尝试使用<a4j:commandButton> 在 bean 中调用一个简单的操作方法。但是当我使用 rendered 或 disabled 属性(也从操作方法评估)时,它不起作用。
这是我的代码 sn-p:
<a4j:region block="true" >
<a4j:form id="download_form">
<a4j:commandButton id="download_button"
action="#{studentInfo.actionDownload}"
onclick="#{rich:component('download_progress')}.show(); setPopupPosition('#{rich:clientId('download_progress')}');"
reRender="dlod_msg_grd"
oncomplete="#{rich:component('download_progress')}.hide();
value="Download a student"
rendered="#{studentInfo.validForDownload}"
/>
</a4j:form>
</a4j:region>
如果我使用rendered="#{studentInfo.validForDownload}" 作为rendered="#{true}" 一切正常,bean 的操作方法被调用。但是我现在用的方式不行
studentInfo.validForDownload 正在评估为 true,因此 a4j:commandButton 正在正确呈现。
【问题讨论】:
-
studentInfo托管 bean 的范围是什么? -
@LuiggiMendoza,它在请求范围内
-
看起来您的
studentInfo.validForDownload字段具有默认值false。尝试在studentInfo类定义上添加@KeepAlive注释,例如@KeepAlive public class StudentIfo { ... }. -
@LuiggiMendoza,也尝试过,但没有成功
-
尝试使用
<h:messages>并删除 ajax 行为,以便您的页面可以进行刷新并显示其他问题,例如转换问题或其他问题。
标签: ajax jsf richfaces jsf-1.2