a4j:commandButton动作未在rich中触发:popupPanel Richfaces 4 JSF 2

时间:2012-03-28 12:02:48

标签: jsf-2 richfaces popuppanel

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>

2 个答案:

答案 0 :(得分:0)

更改操作属性,如下所示

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

或将您的方法更改为

public void runAction(String action){}

答案 1 :(得分:0)

请尝试遵循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>

Managed bean中的方法:

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