【问题标题】:a4j:commandButton action not firing in rich:popupPanel Richfaces 4 JSF 2a4j:commandButton 操作未在 Rich:popupPanel Richfaces 4 JSF 2 中触发
【发布时间】:2012-04-12 00:28:21
【问题描述】:

JSF 代码:

<rich:popupPanel modal="true" id="editPanelUser">
  <h:form>
    <h:panelGrid columns="2">
      <h:outputLabel value="first name (*)" />
      <h:inputText value="#{usersBean.currentItem.firstName}" />
    </h:panelGrid>
    <h:panelGrid>
      <a4j:commandButton value="save"
        oncomplete="if(#{facesContext.maximumSeverity==null}) #{rich:component('editPanelUser')}.hide()"
        action="#{usersBean.runAction('saveUser')}"/>
    </h:panelGrid>
  </h:form>
</rich:popupPanel>

支持 bean 代码:

public void setRunAction(String action){
    if("saveUser".equals(action)){
        ...
    }
}

我在 setRunAction 方法中设置了一个断点,但它从来没有在这里设置。想法?

奇怪的是,打开这个弹窗的 a4j:commandLink 代码工作正常,并且调用了 runAction 方法:

<h:form>
  <rich:dataTable value="#{usersBean.dataList}" var="singleUser"
    rowClasses="row1,row2" rowKeyVar="row" id="singleUserTable"
    ajaxKeys="#{usersBean.keys}">
    <rich:column>
      <a4j:commandLink id="editlink"
        oncomplete="#{rich:component('editPanelUser')}.show();return false;">
        <f:setPropertyActionListener value="editUser"
          target="#{usersBean.runAction}" />
      </a4j:commandLink>
    </rich:column>
  </rich:dataTable>
</h:form>

【问题讨论】:

  • 你的
  • 我在
  • 只是为了检查,尝试删除oncomplete ...也不应该是eq null而不是你的条件...还要检查firebug
  • 去掉了oncomplete,但在eclipse调试器中仍然没有到达方法中的断点。
  • 刚刚注意到...将 bean 中的操作方法的名称从 setRunAction 更改为 runAction

标签: jsf-2 richfaces popuppanel


【解决方案1】:

如下更改您的 action 属性

action="#{usersBean.setRunAction('saveUser')}"

或将您的方法更改为

public void runAction(String action){}

【讨论】:

    【解决方案2】:

    请尝试以下 XHTML 代码(同时确保您没有在另一个表单元素中包含表单):

    <rich:popupPanel modal="true" id="editPanelUser">
      <h:form id="myForm">
        <h:panelGrid columns="2">
          <h:outputLabel value="first name (*)" />
          <h:inputText value="#{usersBean.currentItem.firstName}" />
        </h:panelGrid>
        <h:panelGrid>
          <a4j:commandButton id="myBtn" value="save"
            oncomplete="if(#{facesContext.maximumSeverity==null}) #{rich:component('editPanelUser')}.hide()"
            actionListener="#{usersBean.runAction('saveUser')}"/>
        </h:panelGrid>
      </h:form>
    </rich:popupPanel>
    

    托管 bean 中的方法:

    public void runAction(String action){
        if("saveUser".equals(action)){
            ...
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2011-10-17
      • 2013-12-19
      • 1970-01-01
      • 2014-09-18
      • 1970-01-01
      • 1970-01-01
      • 2014-01-30
      • 1970-01-01
      • 2019-12-27
      相关资源
      最近更新 更多