Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
p:commandButton操作在和ajax更新后未调用_Ajax_Jsf_Primefaces - Fatal编程技术网

p:commandButton操作在和ajax更新后未调用

p:commandButton操作在和ajax更新后未调用,ajax,jsf,primefaces,Ajax,Jsf,Primefaces,我有一个JSF页面,它有一个p:commandButton,它的ajax=true,并呈现一个p:panel,当单击它时,它被包装在p:outputPanel中。单击此按钮时,操作方法会将ManagedBean中的showCreateUser值设置为true,并用于渲染面板。这工作正常-单击按钮时面板正确渲染。在p:panel中还有另一个p:commandButton。这个commanButton不起作用,因为我单击它时什么也没发生。永远不会调用action方法。当我调试时,我意识到即使ajax

我有一个JSF页面,它有一个p:commandButton,它的ajax=true,并呈现一个p:panel,当单击它时,它被包装在p:outputPanel中。单击此按钮时,操作方法会将ManagedBean中的showCreateUser值设置为true,并用于渲染面板。这工作正常-单击按钮时面板正确渲染。在p:panel中还有另一个p:commandButton。这个commanButton不起作用,因为我单击它时什么也没发生。永远不会调用action方法。当我调试时,我意识到即使ajax操作将showCreateUser设置为true,但当我单击第二个按钮时,showCreateUser值为false。因此,panel rendered=false,因此永远不会调用该操作。下面是xhtml和managedbean类。我如何解决这个问题?谢谢你的帮助

registration.xhtml

<h:form id="userForm" style="background-color:white;border:0px; width:90%;">
   <p:messages id="messagesForDebugging"
               showDetail="true"
               autoUpdate="true" />
   <ui:debug hotkey="x"/>
   <div style="margin-bottom: 10px;">
       <p:commandButton id="btnConfirmYes" value="Yes" ajax="true" update="userRegOutPanel" 
               action="#{regBean.confirmYes}" styleClass="button" style="height:35px;">
        <!-- <f:ajax render="userRegOutPanel" execute="userRegOutPanel"/> -->
       </p:commandButton>

       <p:commandButton id="btnConfirmNo" value="No" ajax="false"
             action="#{regBean.confirmNo}" styleClass="button" style="height:35px;"/>
   </div>

   <p:outputPanel id="userRegOutPanel">
        <p:panel id="userRegPanel" rendered="#{regBean.showCreateUser}">
            <p:panelGrid id="userRegPanelGrid">
                <p:row>
                   <p:column style="width:40%;background-color:#00a5b6;-moz-border-radius: 10px;-webkit-border-radius: 10px;-khtml-border-radius: 10px;border-radius: 10px;text-align:left;">

                      <h:inputHidden id="ssn" value="#{regBean.ssn}"/>

                      <p:panelGrid>
                          <p:row>
                              <p:column>
                                  <p:commandButton value="Submit" ajax="true" action="#{regBean.submitRegistration}"                                                 
                                           styleClass="button" style="width:140px;height:35px;" type="submit"/>
                              </p:column>
                          </p:row>
                      </p:panelGrid>
                   </p:column>
                </p:row>
            </p:panelGrid>
        </p:panel>
   </p:outputPanel>
</h:form>
现在,它将从注册bean调用方法
agentConfirmNo


我希望这有帮助

嗨,Makky,我之前的代码中有一个输入错误。我现在更新了。我已经在纠正xhtml中的方法了。还有一点需要指出的是,如果我在以前的调用中没有执行任何ajax调用来呈现/更新Submit按钮的父组件,那么Submit按钮就可以正常工作。您可能与Balusc在回答中所述的一个错误有关
    @ManagedBean
        @ViewScoped
        public class RegBean implements Serializable{

    private static final long serialVersionUID = 1L;
    static Logger log = LoggerFactory.getLogger(RegBean.class);

    private String ssn;

    private boolean showCreateUser = false;

    public void confirmYes(){
        setShowCreateUser(true);
    }

    public String confirmNo(){
        log.info("In retrieveRegistration");
        FacesContext fc = FacesContext.getCurrentInstance();
        fc.addMessage("registrationError", new FacesMessage(
                FacesMessage.SEVERITY_ERROR,
                "Error. Contact customer service",
                "Error. Contact customer service"));
        return "/registration/registrationError";
    }

    public String submitRegistration() {  
        log.info("In submitRegistration");
        FacesContext fc = FacesContext.getCurrentInstance();

        return "/secured/home";
    }  

    public String getSsn() {
        return ssn;
    }
    public void setSsn(String ssn) {
        this.ssn = ssn;
    }

    public boolean isShowCreateUser() {
        return showCreateUser;
    }

    public void setShowCreateUser(boolean showCreateUser) {
        this.showCreateUser = showCreateUser;
    }
}
<p:commandButton id="btnConfirmNo" value="No" ajax="false"
action="#{regBean.ConfirmNo}"
styleClass="button" style="height:35px;"/>
<p:commandButton id="btnConfirmNo" value="No" ajax="false"
action="#{regBean.agentConfirmNo}"
styleClass="button" style="height:35px;"/>