2014-06-30 84 views
0

我正在使用jsf和primefaces在Web应用程序中工作。commandButton操作方法未执行

我的导航栏的代码看起来如下:

<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

的问题是,如果我不把任何东西在开关输入text不执行commandButton的动作,如果我不在inputText中放入某些东西,menuButton中的动作方法也不会执行。

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

我该如何解决这个问题?

+1

'required =“true”requiredMessage =“Le titre est requit”'是不是很自我解释? –

+0

谢谢,我一直没有注意,因为邮件从未发布过。 – user3521250

+0

我还有一个问题,如果你可以帮助我,对于搜索功能,我刚刚实现了一个像子字符串函数,我想要一个功能有更多的搜索可能性,因为如果用户忘记了一个字母表,就没有结果。这很糟糕 – user3521250

回答

1

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