Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.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
Jsf 2 双击JSF2中的submit按钮_Jsf 2_Primefaces_Submit_Double - Fatal编程技术网

Jsf 2 双击JSF2中的submit按钮

Jsf 2 双击JSF2中的submit按钮,jsf-2,primefaces,submit,double,Jsf 2,Primefaces,Submit,Double,我有这个问题,在一个页面中,当我单击commandButton“editer”时,它会工作:它运行managedBean中的方法,并将我返回到目标页面,但在这个目标页面中,我必须双击链接按钮将我发送到另一个目标页面,但如果我只单击“取消”按钮(它只将我重定向到目标页面,数据库中没有任何更改)我没有这个问题 这是包含“编辑”和“取消”按钮的页面: 下面是facelet模板: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//

我有这个问题,在一个页面中,当我单击
commandButton
“editer”时,它会工作:它运行
managedBean
中的方法,并将我返回到目标页面,但在这个目标页面中,我必须双击链接按钮将我发送到另一个目标页面,但如果我只单击“取消”按钮(它只将我重定向到目标页面,数据库中没有任何更改)我没有这个问题

这是包含“编辑”和“取消”按钮的页面:

下面是facelet模板:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <h:outputStylesheet name="style.css" library="css" />
        <h:outputStylesheet name="styleTableExpansion.css" library="css" />
    </h:head>
    <h:body>

        <div id="page">
            <div id="bloc-principal">
                 <h:form prependId="false">
                 <div id="templatemo_header_wrapper">

                    <div id="templatemo_header">

                        <div id="site_title">
                            <h1>
                                <span>vous etes connect en tant qu' #{userController.u1.nom} mais le newNum #{commmandeController.nouvelId}</span>
                            </h1>
                        </div>

                        <ul class="social_network">
                            <li><a id="ident">1dd</a></li>
                            <li><a href="login.xhtml" class="identifiant">on voie celle ci</a></li>
                            <li><a class="identifiant">#{userController.identifiant}2ddd</a></li>
                            <li><h:commandLink action="#{userController.deconnecter}"><h:graphicImage library="images" name="facebook.png" /></h:commandLink></li>
                        </ul>

                    </div> <!-- end of templatemo_header -->
                </div> <!-- end of templatemo_header_wrapper -->   

                <div id="templatemo_banner_wrapper">

                    <div id="templatemo_banner">


                    </div> <!-- end of templatemo_banner -->

                </div> <!-- end of templatemo_banner_wrapper -->


                <div id="templatemo_content_wrapper">

                    <div id="templatemo_content">

                         <ui:insert name="content">content</ui:insert>
                    </div> <!-- end of templatemo_content -->
                </div> <!-- end of templatemo_content_wrapper -->    
                </h:form>
            </div>
            <div id="templatemo_footer_wrapper">

                <div id="templatemo_footer">


                    <center>

                    </center>

                </div> <!-- end of footer -->
            </div>
        </div>

    </h:body>
</html>

您可以随时连接到“{userController.u1.nom}mais le newNum{commmandeconcontroller.nouvelId}”
  • #{userController.identifiant}2ddd
内容
我希望我已经很好地解释了我的问题。
提前感谢。

尝试设置
ajax=“false”
如果出现

问题,请询问我是否已经阅读了本页,我认为我没有验证第4点,因为包含问题的页面也包含h:datatable,然后我将managedBean更改为ViewScope,但没有结果,你有什么想法吗,谢谢阅读以了解如何找到good代码片段。到目前为止发布的代码包含相当多的噪音,使问题更难被发现。例如,重现确切的问题是否绝对需要
style=“margin bottom:20px;”
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>

        <ui:composition template="./template_admin.xhtml">

            <ui:define name="content">


                    <p:commandButton value="ajouter" style="margin-bottom: 20px;" />
                    <p:dataTable id="carsTable" var="car" value="#{utilisateursController.lu}">  

                        <f:facet name="header">  
                            Expand rows to see detailed information  
                        </f:facet>  

                        <p:column style="width:4%">  
                            <p:rowToggler />  
                        </p:column>  

                        <p:column style="width:48%">  
                            <f:facet name="header">  
                                Id  
                            </f:facet>  
                            <h:outputText value="#{car.id}" />  
                        </p:column>  

                        <p:column style="width:48%">  
                            <f:facet name="header">  
                                Nom et prénom
                            </f:facet>  
                            <h:outputText value="#{car.nom}   #{car.prenom}" />  
                        </p:column>  

                        <p:column>
                            <p:commandLink ajax="false" value="Editer" action="updateUser_v1" >
                                <f:setPropertyActionListener value="#{car}" target="#{editUserController.u1}" />  
                            </p:commandLink>
                        </p:column>



                        <p:column>
                            <p:commandLink value="supprimer"  />
                        </p:column>            

                        <p:rowExpansion>  
                            <h:panelGrid id="display" columns="2" cellpadding="4" style="width:300px;"  
                                         styleClass=" ui-widget-content grid">  

                                <h:outputText value="Division : " />  
                                <h:outputText id="model" value="#{car.division}" />  

                                <h:outputText value="Grade : " />  
                                <h:outputText id="year" value="#{car.grade}" /> 

                                <h:outputText value="Type : " />  
                                <h:outputText value="#{car.type}"/>  

                                <h:outputText value="Télephone du poste : " />  
                                <h:outputText value="#{car.telPoste}"/>  

                                <h:outputText value="Email : " />  
                                <h:outputText value="#{car.email}"/>  

                                <h:outputText value="Autres : " />  
                                <h:outputText value="#{car.autres}"/>  

                                <h:outputText value="Identifiant : " />  
                                <h:outputText value="#{car.identifiant}"/>  

                                <h:outputText value="Mot de passe : " />  
                                <h:outputText value="#{car.motdepasse}"/>  


                            </h:panelGrid>  
                            <h:commandLink value="liste des commandes" ></h:commandLink><br></br>
                            <h:commandLink value="liste des messages" ></h:commandLink>

                        </p:rowExpansion>  
                    </p:dataTable>  





            </ui:define>

        </ui:composition>

    </body>
</html>
@ManagedBean
@ViewScoped
public class utilisateursController  implements Serializable{

    utilisateursHelper uh;
    List<Utilisateur> lu;

    public List<Utilisateur> getLu() {
        return lu;
    }
    /**
     * Creates a new instance of utilisateurs
     */
    public utilisateursController() {
        uh = new utilisateursHelper();
        lu = uh.getUtilisateurs();
    }



}
@ManagedBean
@SessionScoped
public class editUserController implements Serializable{

    utilisateursHelper uh;
    Utilisateur u1;
    String[] Types = {"utilisateur", "operateur", "admin"};

    public String[] getTypes() {
        return Types;
    }

    public Utilisateur getU1() {
        return u1;
    }

    public void setU1(Utilisateur u1) {
        this.u1 = u1;
    }

    /**
     * Creates a new instance of editUserController
     */
    public editUserController() {
        u1 = new Utilisateur();
        uh = new utilisateursHelper();
    }

    public String updateUser() {


        uh.updateUtilisateur(u1);
        return "utilisateurs";
    }
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <h:outputStylesheet name="style.css" library="css" />
        <h:outputStylesheet name="styleTableExpansion.css" library="css" />
    </h:head>
    <h:body>

        <div id="page">
            <div id="bloc-principal">
                 <h:form prependId="false">
                 <div id="templatemo_header_wrapper">

                    <div id="templatemo_header">

                        <div id="site_title">
                            <h1>
                                <span>vous etes connect en tant qu' #{userController.u1.nom} mais le newNum #{commmandeController.nouvelId}</span>
                            </h1>
                        </div>

                        <ul class="social_network">
                            <li><a id="ident">1dd</a></li>
                            <li><a href="login.xhtml" class="identifiant">on voie celle ci</a></li>
                            <li><a class="identifiant">#{userController.identifiant}2ddd</a></li>
                            <li><h:commandLink action="#{userController.deconnecter}"><h:graphicImage library="images" name="facebook.png" /></h:commandLink></li>
                        </ul>

                    </div> <!-- end of templatemo_header -->
                </div> <!-- end of templatemo_header_wrapper -->   

                <div id="templatemo_banner_wrapper">

                    <div id="templatemo_banner">


                    </div> <!-- end of templatemo_banner -->

                </div> <!-- end of templatemo_banner_wrapper -->


                <div id="templatemo_content_wrapper">

                    <div id="templatemo_content">

                         <ui:insert name="content">content</ui:insert>
                    </div> <!-- end of templatemo_content -->
                </div> <!-- end of templatemo_content_wrapper -->    
                </h:form>
            </div>
            <div id="templatemo_footer_wrapper">

                <div id="templatemo_footer">


                    <center>

                    </center>

                </div> <!-- end of footer -->
            </div>
        </div>

    </h:body>
</html>