【问题标题】:Primefaces commandButton actionListener not working inside notificationBarPrimefaces commandButton actionListener在notificationBar内不起作用
【发布时间】:2015-08-29 16:31:15
【问题描述】:

我正在为网络应用程序使用 PF 5.2。我想使用notificationBar 来驻留一些数据输入,并使用commandButton 来触发这些输入数据到backing bean。因此,我在 notificationBar 中放置了一个 commandButton,但 actionListener 没有调用支持 bean 方法。 CommandButton 定义为 id 为“filterBtn”。

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

我知道这是对组件的简单使用,但它不起作用。有什么帮助吗?

【问题讨论】:

    标签: jsf primefaces jsf-2.2


    【解决方案1】:

    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>
    

    【讨论】:

      猜你喜欢
      • 2014-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多