2013-08-29 151 views
1

我有有一個數據網格,我想用一個按鈕或鏈接按鈕,我編碼爲以下做調用一個方法內數據網格XHTML頁面命令按鈕不會工作primefaces

<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:p="http://primefaces.org/ui" 
    xmlns:f="http://java.sun.com/jsf/core"> 
<h:head> 
    <title>TODO supply a title</title>   
</h:head>  
<h:body> 
    <p:layout fullPage="true"> 
     <p:layoutUnit position="center"> 
      <p:graphicImage value="images/common/banner1.png" 
          style="width: 100%;min-width: 1350px"/>     
      <h:form id="menu_bar_form"> 
       <p:menubar style="font-size: 14px;min-width: 1340px;" > 
        <p:menuitem style="width: 50px" disabled="true"/> 
        <p:menuitem value="HOME" url="home.xhtml"/> 
        <p:menuitem style="width: 100px" disabled="true"/>      
        <p:submenu label="PHONES"> 
         <p:menuitem value="Apple" outcome="phones"> 
          <f:param name="brand" value="Apple"/> 
         </p:menuitem> 
         <p:menuitem value="Motorola" outcome="phones"> 
          <f:param name="brand" value="Motorola"/> 
         </p:menuitem> 
         <p:menuitem value="Nokia" outcome="phones"> 
          <f:param name="brand" value="Nokia"/> 
         </p:menuitem> 
         <p:menuitem value="Samsung" outcome="phones"> 
          <f:param name="brand" value="Samsung"/> 
         </p:menuitem> 
        </p:submenu> 
        <p:menuitem style="width: 100px" disabled="true"/> 
        <p:menuitem value="COMPARE"/> 
        <p:menuitem style="width: 100px" disabled="true"/> 
        <p:submenu label="ACCESSORIES"> 
         //ADD CONTENT 
        </p:submenu> 
        <p:menuitem style="width: 100px" disabled="true"/> 
        <p:menuitem value="CONTACT"/> 
        <f:facet name="options"> 
         <h:panelGrid columns="2" style="font-size: 12px"> 
          <p:autoComplete id="search_textBox" value="#{homeBean.searchItem}" 
              completeMethod="#{homeBean.search}"/> 
          <p:commandButton value="Search" icon="ui-icon-search" /> 
         </h:panelGrid> 
        </f:facet> 
       </p:menubar> 
      </h:form> 
      <h:form id="page_content"> 
       <table cellspacing="2" style="font-size: 14px; 
         width: 100%;min-width: 1350px"> 
        <thead> 
         <tr> 
          <th></th> 
          <th style="width: 1000px;text-align:center"> 
           <p:dataGrid var="phone" value="#{phonesBean.phoneList}" columns="8" 
          rows="12" paginator="true" 
    paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
    rowsPerPageTemplate="9,12,15" style="text-align: center;"> 
// ++++++++++++++++++++++++++++++++++++ Problem++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
            <p:panel header="#{phone.model}" style="width: 175px" > 
             <h:panelGrid columns="1" style="width:100%"> 
              <p:graphicImage value="#{phone.imageUrl}"/> 
             </h:panelGrid> 
             <p:commandButton value="click here" action="#{phonesBean.test()}"/> 
            </p:panel> 
//+++++++++++++++++++++++++++++++++++Problem+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
          </p:dataGrid>         
          </th> 
          <th></th> 
         </tr> 
        </thead> 
       </table>         
      </h:form>     
     </p:layoutUnit> 
    </p:layout> 
</h:body> 

我debbuged的代碼,但測試方法不會打電話。沒有任何異常或錯誤。在EL

+0

嘗試看看下面這個例子/回答:[http://stackoverflow.com/a/12857697/1692632](http://stackoverflow .com/a/12857697/1692632) 也許把phoneBean代碼放在​​這裏。 – Darka

+0

我試過了,但沒有任何事發生 – smk

+0

@smk確保您在'@ ManagedBean'中使用'@ ViewScoped'註釋。 –

回答

0

Write方法名稱,沒有括號,並添加ajax="false"

<p:commandButton value="click here" action="#{phonesBean.test}" ajax="false"/>