<a4j:commandbutton>没有调用动作</a4j:commandbutton>

时间:2013-05-30 05:08:07

标签: ajax jsf richfaces jsf-1.2

我正在尝试使用<a4j:commandButton>在bean中调用一个简单的操作方法。但是,当我使用rendereddisabled属性(也从动作方法进行评估)时,它无效。

这是我的代码段:

<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的action方法。但我现在使用的方式不起作用

studentInfo.validForDownload正在评估为true,因此a4j:commandButton正在正确呈现。

1 个答案:

答案 0 :(得分:1)

由于您的studentInfo托管bean具有请求范围,如您对Luiggi的回复中所述,rendered="#{studentInfo.validForDownload}"将始终评估为默认值。正如Luiggi所提到的,你必须使用a4j:keepAlive才能获得所需的行为,但代码稍有变化:

<a4j:keepAlive beanName = "studentInfo"/>
<h:form id="download_form">  
  <a4j:region block="true" >
    <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:region>
</h:form>

我不知道a4j:form是否有效,但肯定h:form会起作用