0

JSF + PrettyFacesを使用してナビゲーションとBeanアクションを処理するときに、JavaWebアプリに問題があります。

バージョンの使用:

JSF-2.1
PrettyFaces-3.3.3

リンクからPrettyFacesFilterを使用してナビゲーションを処理すると、エラーが発生します。

             <div class="product_img">
                <pretty:link mappingId="viewProduct">
                    <img src="#{request.contextPath}/image?id=#{product.mainImage.fileReference.id}" />                                             
                    <f:param value="#{productMB.filters.productCategoryName}" />
                    <f:param value="#{product.name}" />                                                                         
                </pretty:link>                                                   
             </div>                                                          

pretty-config.xmlマッピングは次のとおりです。

  <url-mapping id="viewProduct">
      <pattern value="/shop/product/#{ productCategoryName : productMB.filters.productCategoryName }/#{ productName : productMB.filters.productName }/" />
      <view-id value="/pages/productDetails.faces" />
      <action>#{productMB.openProductDetails}</action>
  </url-mapping>

Beanアクション:

public String openProductDetails() {

    if (filters.getProductCategoryName() != null && !filters.getProductName().equals("")) {         
        loadProductDetailsByName(filters.getProductCategoryName());
    }

    return "/pages/productDetails.faces";
}

ユーザーは[製品の詳細]ページにアクセスし、色、サイズなどの製品機能を選択できます。

    <ui:fragment rendered="#{productMB.productVO.featureColorAvailable}">
        <span class="productFeatureLabel">#{msg.color}</span>

        <h:selectOneMenu id="colorSelect"
            value="#{productMB.productVO.colorSelected}"
            valueChangeListener="#{productMB.colorSelectedValueChanged}">
            <f:selectItem itemLabel="#{msg['select']}" noSelectionOption="true" />
            <f:selectItems value="#{productMB.productFeatureAvailableApplMap['color']}" var="colorItem" itemValue="#{colorItem}"
                itemLabel="#{msg[colorItem.name]}"  />
            <f:ajax event="valueChange"             
            listener="#{productMB.colorSelectedValueChanged}"   
                render="@this productDetailImage productSubImage productSubImage2 productSubImage3 sizeSelect"></f:ajax>
        </h:selectOneMenu>      
    </ui:fragment>

//...Beanアクションメソッド

  public void colorSelectedValueChanged(ValueChangeEvent event) {

        if (null != event.getNewValue()) {
            ProductFeatureAppl prodFeatureAppl = (ProductFeatureAppl) event.getNewValue();
            filterProductFeatureSelectItem(AppConstants.SIZE, prodFeatureAppl.getProductFeature().getName() );
        } else {
            filterProductFeatureSelectItem(AppConstants.SIZE, null );
        }
    }   

  public void colorSelectedValueChanged(AjaxBehaviorEvent event) throws javax.faces.event.AbortProcessingException {

      try {
            if (null != productVO.getColorSelected()) {
                ProductFeatureAppl prodFeatureAppl = productVO.getColorSelected(); 
                filterProductFeatureSelectItem(AppConstants.SIZE, prodFeatureAppl.getProductFeature().getName() );

                String prodFeatName = prodFeatureAppl.getProductFeature().getName();

                // switch selected pics.
                productVO.setCurrentDetailImageName(productVO.getProduct().getProductImageByTypeAndFeatureName(
                        NameConstants.DETAIL, prodFeatName).getFileReference().getId());

                productVO.setCurrentBigImageName(productVO.getProduct().getProductImageByTypeAndFeatureName(
                        NameConstants.BIG, prodFeatName).getFileReference().getId());

            } else {
                filterProductFeatureSelectItem(AppConstants.SIZE, null );
                filterProductFeatureSelectItem(AppConstants.COLOR, null );

                // reset to default
                productVO.setCurrentDetailImageName(productVO.getProduct().getProductImageByType(ProductImageType.DETAIL1.toString()).getFileReference().getId());
                productVO.setCurrentBigImageName(productVO.getProduct().getProductImageByType(ProductImageType.BIG1.toString()).getFileReference().getId());                                                
            }       

      } catch (Exception ex) {
            addErrorMessage(getMessage("error"));
            if (screenComponent.isDisplayException()) {
                addErrorMessage(ex.getMessage());
            }
        }

  } 

製品の詳細ページに最初に移動した後、selectOneMenu id = "colorSelect"から値を選択するたびに、valueChangeListenerとajaxリスナーは呼び出されません。さらに、productMB.openProductDetailsアクションが呼び出されます。

ajax呼び出しは、ログに表示されるエラーなしで完了しますが、リスナーメソッドは呼び出されません。これらのJSFajaxリスナーがスキップされる理由を誰かが知っていますか?

前もって感謝します。


URLから直接アクセスした場合、ページは機能しますか?PrettyFacesが無効になっている場合は機能しますか?

これがリンクまたはPrettyFacesの問題ではないかと思います。私はそれがAJAXと部分的な状態の保存ともっと関係があると確信しています。

これに関係している可能性があります:

public String openProductDetails() {
    if (filters.getProductCategoryName() 
            != null && !filters.getProductName().equals("")) {         
        loadProductDetailsByName(filters.getProductCategoryName());
    }

    return "/pages/productDetails.faces"; // why is this being returned?
}

そこにページ名を返しています。PrettyFacesは、実際にこの文字列をナビゲートしようとする場合があります。マッピングで構成したページを表示する場合は、単にnullを返すか、 ""空の文字列を返すか、何も返しません。

お役に立てれば。

4

1 に答える 1

1

URLから直接アクセスしてもページは動きますか?PrettyFaces を無効にしても機能しますか?

これがリンクまたは PrettyFaces の問題であるとは思えません。私は、AJAX と部分的な状態保存にもっと関係があると確信しています。

これに関係している可能性があります:

public String openProductDetails() {
    if (filters.getProductCategoryName() 
            != null && !filters.getProductName().equals("")) {         
        loadProductDetailsByName(filters.getProductCategoryName());
    }

    return "/pages/productDetails.faces"; // why is this being returned?
}

そこにページ名を返しています。PrettyFaces は、実際にこの文字列をナビゲートしようとする場合があります。マッピングで構成したページを表示する場合は、単に null を返すか、"" 空の文字列を返すか、何も返さないでください。

お役に立てれば。

于 2012-04-10T15:01:59.213 に答える