Primefaces commandButton actionListener not working inside notificationBar

598 Views Asked by At

I am using PF 5.2 for the web app. I wanted to use notificationBar to reside some data inputs and commandButton to trigger these inputs data to the backing bean. Therefore I put a commandButton inside the notificationBar but actionListener is not calling the backing bean method. CommandButton is defined with id of "filterBtn".

The .xhtml page code is in the below:

<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>

I know it is a simple use of the components but it is not working. Any help?

1

There are 1 best solutions below

0
On

The notificationBar should not be embedded in a form. Just exchange the notificationBar and form tags, so the form is within the 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>