2015-06-13 205 views
0

我正在使用PF 5.2的Web應用程序。我想使用notificationBar來駐留一些數據輸入和commandButton來觸發這些輸入數據到輔助bean。因此,我在notificationBar中放置了一個commandButton,但actionListener不調用backing bean方法。 CommandButton使用「filterBtn」的id定義。Primefaces commandButton actionListener not working inside notificationBar

的.xhtml頁面代碼是在下面:

<h:form> 
<p:notificationBar position="top" effect="slide" styleClass="top" widgetVar="bar" style="height:200px;"> 
    <h:panelGrid columns="1"> 
     <h:panelGrid id="filterGrid1" columns="4" > 
      <h:outputLabel id="vhclIdLbl" value="#{general.vehicleId}"/> 
      <p:inputText id="fMtsId" value="#{notifyBean.fMtsId}" style="width:200px"/> 
      <h:outputLabel id="serialNoLabel" value="#{general.serialNo}"/> 
      <p:inputText id="fSerialNo" value="#{notifyBean.fSerialNo}" style="width:200px"/> 
      <h:outputLabel id="brandLbl" value="#{general.brand}"/> 
      <p:selectCheckboxMenu id="fBrand" value="#{notifyBean.fBrands}" effect="slide" style="width:210px" 
       appendTo="@this"> 
       <f:selectItem itemLabel="#{general.pleaseSelect}" itemValue=""/> 
       <f:selectItems value="#{notifyBean.brandList}"/> 
      </p:selectCheckboxMenu> 
      <h:outputLabel id="modelLabel" value="#{general.model}"/> 
      <p:selectCheckboxMenu id="fModel" value="#{notifyBean.fModels}" effect="slide" style="width:210px" 
       appendTo="@this"> 
       <f:selectItem itemLabel="#{general.pleaseSelect}" itemValue=""/> 
       <f:selectItems value="#{notifyBean.modelList}"/> 
      </p:selectCheckboxMenu> 
      <h:outputLabel id="provLabel" value="#{general.province}"/> 
      <p:selectCheckboxMenu id="fProvince" value="#{notifyBean.fProvinces}" effect="slide" style="width:210px" 
      filter="true" filterMatchMode="startsWith" appendTo="@this"> 
       <f:selectItem itemLabel="#{general.pleaseSelect}" itemValue=""/> 
       <f:selectItems value="#{notifyBean.provinceList}"/> 
      </p:selectCheckboxMenu> 
      <h:outputLabel id="regionLabel" value="#{general.region}"/> 
      <p:selectCheckboxMenu id="fRegion" value="#{notifyBean.fRegions}" effect="slide" style="width:210px" 
       appendTo="@this"> 
       <f:selectItem itemLabel="#{general.pleaseSelect}" itemValue=""/> 
       <f:selectItems value="#{notifyBean.regionList}"/> 
      </p:selectCheckboxMenu> 
     </h:panelGrid> 

     <p:commandButton id="filterBtn" value="Filter" actionListener="#{notifyBean.filterByProperties()}" icon="ui-icon-arrow-1-n"/> 

     <p:commandButton value="Hide" onclick="PF('bar').hide()" type="button" icon="ui-icon-arrow-1-n"/> 
    </h:panelGrid> 
</p:notificationBar> 
</h:form> 

我知道這是一個簡單的使用該組件,但它無法正常工作。任何幫助?

回答

1

notificationBar不應嵌入到表單中。只需交換notificationBar和表單標籤,以便表單位於通知欄內。

<p:notificationBar position="top" effect="slide" styleClass="top" widgetVar="bar"> 
    <h:form> 
     <p:commandButton value="yes" actionListener="#{backingBean.onDeleteButton}" onclick="PF('bar').hide()" /> 
     <p:commandButton value="no" onclick="PF('bar').hide()" /> 
    </h:form> 
</p:notificationBar> 
相關問題