commandButton动作方法未执行

时间:2014-06-30 01:38:19

标签: html css jsf primefaces

我正在使用jsf和primefaces在Web应用程序中工作。

我的navBar代码如下:

<p:layoutUnit position="north"  >
                <h:form>
                    <img src="resources/images/logo.png" alt="" />&nbsp;&nbsp;&nbsp;
                    <p:outputLabel value="Rechercher    " style="font-size: large"/>  &nbsp;&nbsp;&nbsp;
                    <p:inputText  value="#{acount.searchWord}" required="true" requiredMessage="Le titre est requit"/>&nbsp;&nbsp;&nbsp;
                    <p:commandButton value="Go" action="#{acount.rechercherLivre(acount.searchWord)}"  styleClass="btngo"  />
                    <h:link outcome="main.xhtml" value="Accueil"   style="margin-left: 400px;font-size: medium"/>&nbsp;&nbsp;
                    <h:link outcome="Contact.xhtml"  value="Contact" style="font-size: medium"/>&nbsp;&nbsp;
                    <h:link outcome="Info.xhtml" value="Info" style="font-size: medium"/>&nbsp;&nbsp;&nbsp;
                    <h:link outcome="Login.xhtml" value="Login" style="font-size: medium" rendered="#{!acount.connected}" /> &nbsp;&nbsp;
                    <h:link outcome="exe.xhtml" value="S'enregistrer" style="font-size: medium" rendered="#{!acount.connected}" /> &nbsp;&nbsp;

                    <p:menuButton value="Panier #{shopingCart.produits.size()}"   style="color: #045491;background: greenyellow;background-color: yellowgreen;font-size: medium">
                        <p:menuitem value="Afficher"    action="#{shopingCart.afficherPanier()}"/>
                        <p:separator />
                        <p:menuitem value="Homepage" url="http://www.primefaces.org" />
                    </p:menuButton>
                    <p:menuButton value="Options"   rendered="#{acount.connected}" style="color: #045491;background: greenyellow;background-color: yellowgreen;font-size: medium">
                        <p:menuitem value="Compte"   />
                        <p:menuitem value="Mes Commandes "  />
                        <p:menuitem value="Se deconnecter" action="#{acount.doLogout()}"  />
                        <p:separator />
                        <p:menuitem value="Homepage" url="http://www.primefaces.org" />
                    </p:menuButton>
                </h:form>
            </p:layoutUnit>

此代码的图片是:

enter image description here

问题是,如果我没有在imput文本中放入任何内容,则不会执行commandButton的操作,如果我不在inputText中输入内容,也不会执行menuButton中的action方法

我可以通过为每个操作方法添加一个表单来解决这个问题,但我的导航栏变大了,看起来值得。

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

如果您不需要通过commandButton向bean发布任何值,则将process属性添加到commandButton。我认为你试图将一些输入留空并仍然发送请求,但问题是其中一个输入必需的属性设置为'true'。从输入中删除所需的属性,并将process =“@ this”添加到commandButton。我希望我是对的。

相关问题