首页 > 解决方案 > 将 jsf 2.0 应用程序迁移到 JSF 2.2 和 WAS9 复合组件未触发事件

问题描述

我有一个运行良好的应用程序,直到我们迁移到 WAS9 应用程序服务器(默认使用 jsf2.2)。

  1. 该应用程序有一个复合组件,其中包含一个 primefaces:autosuggest 小部件。小部件停止“触发” itemSelect 事件。ajaxListener 永远不会触发。

我看到的一切都表明它编码正确,但什么也没有。我尝试添加“更改”事件,但该事件也永远不会触发。我唯一能做的就是让它成为一个普通的监听器 <cc:attribute name="ajaxLocationListener" method-signature="void listener()"/> 但是我无法访问我需要的事件。

这是复合组件的实现:


<com:stopComponent id="Origin" 
                               customerKey="#{templateController.ordrBeanUI.orderHeaderUI.customerUniqueKey}"
                               stop="#{templateController.ordrBeanUI.orderStopListUI.orderStopList[0]}"
                               options="#{templateController.custOptionsBean.countryCodesBean}"
                               mode="#{templateController.ordrBeanUI.orderHeaderUI.shippingMode}"
                               intlModeFlag="#{templateController.ordrBeanUI.orderHeaderUI.intlModeFlag}"
                               docType="#{templateController.ordrBeanUI.orderHeaderUI.documentType}"
                               addressBookAction="#{templateController.addressBookLookUp}"
                               saveAddressAction="#{templateController.saveAddressBook}" 
                               lookAheadAction="#{templateController.obtainLocationList}"
                               ajaxListener="#{templateController.handleSelect}"
                               >
                <f:ajax execute="Origin" render="originPanel" onevent="setOrderFieldFlagsAjax"/>
            </com:stopComponent>

实际的 StopComponent 在这里:


<html xmlns:x="http://www.w3.org/1999/xhtml" 
    xmlns:cc="http://xmlns.jcp.org/jsf/composite" 
    xmlns:f="http://xmlns.jcp.org/jsf/core" 
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
    xmlns:lf="http://websphere.landstar.com/jsf"
    xmlns:com="http://xmlns.jcp.org/jsf/composite/components">

<cc:interface displayName="locationSection">
    <cc:attribute name="customerKey" type="java.lang.Integer" />
    <cc:attribute name="stop" type="com.landstar.cust.orders.beans.OrderStopUI" required="true" />
    <cc:attribute name="options" type="com.landstar.cust.orders.beans.CountryCodesSelectOptionsBean" required="true" />
    <cc:attribute name="mode" type="java.lang.String" required="true" />
    <cc:attribute name="intlModeFlag" type="java.lang.Boolean" required="true" />
    <cc:attribute name="docType" type="java.lang.String" />
    <cc:attribute name="addressBookAction" method-signature="void actionListener(javax.faces.event.AjaxBehaviorEvent)" required="true"/>
    <cc:attribute name="saveAddressAction" method-signature="void actionListener(javax.faces.event.ActionEvent)" /> 
    <cc:attribute name="lookAheadAction" method-signature="java.util.List obtainAddress(java.lang.String)" />
    <cc:attribute name="ajaxListener"  method-signature="void actionListener(javax.faces.event.AjaxBehaviorEvent)" /> 
    <cc:clientBehavior name="click" event="action" targets="saveLink" />
    <cc:clientBehavior name="itemSelect" event="itemSelect" targets="stopLocationID stopLocationName" />
    <cc:clientBehavior name="dateSelect" event="dateSelect" targets="#{cc.clientId}_fromDate #{cc.clientId}_toDate" />
</cc:interface>



<p:autoComplete id="stopLocationName" value="#{cc.attrs.stop.selectedLocationName}" minQueryLength="3"
                        completeMethod="#{cc.attrs.lookAheadAction}"  forceSelection="false"
                        var="p" itemLabel="#{p.locationText}" itemValue="#{p}" size="32" maxlength="30"
                        converter="locationConverter">
                        <f:attribute name="customerKey" value="#{cc.attrs.customerKey}" />
                        <f:attribute name="searchType" value="locationName" />
                        <f:attribute name="mode" value="#{cc.attrs.mode}" />
                        <f:attribute name="geoType" value="#{cc.attrs.stop.stopInternational}" />
                        <f:attribute name="stopType" value="#{cc.clientId}"/>

                        <p:ajax event="itemSelect" listener="#{cc.attrs.ajaxLocationListener}" update="stopComponent" oncomplete="setOrderFieldFlagsPrimeFaces(xhr,status,args)" />

</p:autoComplete>



The Backing Bean is here:
@ManagedBean(name="orderController")
@ViewScoped
public class OrderController extends DocumentController implements Serializable {

}

public class DocumentController extends DateTimeConversions implements Serializable {

... 


    public void handleSelect(SelectEvent event) {
        String stopType = event.getComponent().getClientId();
        String calledFrom = "lookAhead";

        populateLocationFromAddressBook(stopType, calledFrom,
                ((LocationLookAheadBean) event.getObject()).getLocationAddressUniqueKey());
        String stopTypeStr = "";
        if (stopType != null && !stopType.trim().equals("")) {
            stopTypeStr = stopType.trim().substring(0, stopType.trim().indexOf(":"));
        }

        RequestContext context = RequestContext.getCurrentInstance();
        context.addCallbackParam("location", stopTypeStr);
    }



}


标签: primefacesjsf-2.2

解决方案


推荐阅读