JSF + PrettyFacesを使用してナビゲーションおよびBeanアクションを処理するときにJava Web Appに問題が発生します。JSF2 <h:selectOneMenuおよび<f:PrettyFacesフィルタナビゲーション後にajaxリスナーが呼び出されない
<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>
かなり-config設定: - - 2.1
PrettyFacesリンクからPrettyFacesフィルターを使用してナビゲーションを取り扱うとき3.3.3
エラーが発生した
JSF:バージョンを使用して
.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>
豆アクション:彼はなど、色、大きさ、のような製品の機能を選択することができます商品の詳細ページで
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>
// ...豆の動作方法
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 =「カラーセレクト」から値を選択するたびには、valueChangeListenerのとAJAXリスナが呼び出されていません。それ以外にも、productMB.openProductDetailsアクションが呼び出されます。
ログにエラーが表示されずにAjax呼び出しが完了しましたが、リスナーメソッドが呼び出されません。 JSF ajaxリスナーがスキップされている理由を誰かが知っていますか?
ありがとうございます。
nullを返すようにメソッドを変更しました。今度はリスナーが呼び出されますが、productMB.openProductDetails()はまだHTTP POST AjaxリクエストのJSFライフサイクルで呼び出されています。私は変更しようとしました:
\t \t Pretty Filter \t com.ocpsoft.pretty.PrettyFilter \t \t false \t \t \t
を真と偽にしてどちらも解決しませんでした。私はまた、ASYNCとINCLUDEのディスパッチャを含めるようにPrettyFilterのフィルタマッピングを変更しようとしましたが、これらを追加したり問題を解決しなかったりしました。 – guilheblajaxリクエストの後にproductMB.openProductDetailsが呼び出された理由を見つけたので、#{productMB.openProductDetails} を追加しました。私はajaxコンポーネントを持つすべてのページにonPostback = falseを入力する必要があると信じています。これがAjaxコールとPrettyFacesに関する正しい記述であるかどうか分かりますか?前もって感謝します。 –
guilhebl
JSF AJAXリクエストは実際にHTTP POSTを使用しているので、これは間違いありません。 – Lincoln