繁体   English   中英

jsf2监听器未使用f:ajax调用

[英]Jsf2 listener not called with f:ajax

我正在使用jsf2和richfaces 4。

这是我的home.xhtml

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:f="http://java.sun.com/jsf/core"      
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ui="http://java.sun.com/jsf/facelets" 
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:rich="http://richfaces.org/rich">

<h:head>
    <title>My Web Application</title>
    <link rel="stylesheet" href="resources/stylesheet/style.css" />
</h:head>

<h:body>

    <h:panelGrid columns="2">

        <h:form>

            <rich:panel>

                <f:facet name="header">
                    Statut
                    <div class="status_refresh" style="float:right;">
                        <h:graphicImage styleClass="loading" value="resources/stylesheet/images/refresh.png">
                            <f:ajax execute="@form" event="click" listener="#{statusBean.refresh}" render="station_status station_action"/>
                        </h:graphicImage>
                    </div>
                </f:facet>

                <h:panelGroup id="station_status" style="display:inline-block;" class="#{statusBean.stationTableStatus?'status_ok':'status_not_ok'}">
                    <a4j:outputPanel>
                        <rich:tooltip rendered="#{statusBean.stationTableStatus != true}">
                            <h:outputText value="#{statusBean.stationTableStatusMessage}" />
                        </rich:tooltip>
                        <h:outputText value="Table " />
                        <b><h:outputText style="margin-right:10px;" value="Station" /></b>
                    </a4j:outputPanel>
                </h:panelGroup>
                <h:panelGroup id="station_action" rendered="#{statusBean.stationTableStatus != true}">
                    <a4j:status>
                        <f:facet name="start">
                            <div class="loading_container">
                                <h:graphicImage styleClass="loading" value="resources/stylesheet/images/waiting.gif" alt="Please wait ..." />
                            </div>
                        </f:facet>
                        <f:facet name="stop">
                            <h:commandButton type="button" value="Créer la table">
                                <a4j:ajax execute="@form" listener="#{statusBean.createStationTable}" render="station_status,station_action"/>
                            </h:commandButton>
                        </f:facet>
                    </a4j:status>                       
                </h:panelGroup>

            </rich:panel>

        </h:form>

    </h:panelGrid>

</h:body>

</html>

通过支持bean,我有:

public void createStationTable()
{
....
}

public void refresh()
{
    System.out.println("******* start refresh() ************");
}

而且我不明白为什么调用了我的按钮的侦听器,而不是我的图像之一。

我也尝试过

public void refresh(ActionEvent actionEvent)

public void refresh(AjaxBehaviorEvent e)

但没有一个工作。

我还尝试了f:ajax和a4j:ajax。 相同的结果。

好吧,我尝试了您的代码,它调用了<f:ajax>标记中定义的侦听器。

我不知道您在复制时是否错过了它,您是否丢失了</html>

对于<h:panelGrid>您使用了错误的属性。 应该是styleClass而不是class

JSF2 <h:selectonemenu and <f:ajax listeners not called after prettyfaces filter navigation< div><div id="text_translate"><p> 使用 Java Web 应用程序时出现问题 JSF + PrettyFaces 处理导航和 bean 操作。</p><p> 使用版本:</p><p> JSF - 2.1<br> 漂亮的脸蛋 - 3.3.3</p><p> 使用来自链接的 PrettyFaces 过滤器处理导航时发生错误:</p><pre> <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></pre><p></p><p> pretty-config.xml 映射是:</p><pre> <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></pre><p></p><p> 豆行动:</p><pre> public String openProductDetails() { if (filters.getProductCategoryName().= null &&.filters.getProductName();equals("")) { loadProductDetailsByName(filters.getProductCategoryName()); } return "/pages/productDetails.faces"; }</pre><p></p><p> 用户登陆产品详细信息页面,在那里他可以 select 产品功能,如颜色、尺寸等......</p><pre> <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></pre><p> //... Bean 动作方法</p><pre> 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()); } } }</pre><p></p><p> 首次导航到产品详细信息页面后,无论何时从 selectOneMenu id="colorSelect" 中选择一个值,都不会调用 valueChangeListener 和 ajax 侦听器。 除此之外,productMB.openProductDetails 操作被调用。</p><p> ajax 调用已完成,我在日志中看到没有错误,但没有调用任何侦听器方法。 有人知道为什么跳过这些 JSF ajax 听众吗?</p><p> 提前致谢。</p></div></h:selectonemenu>

[英]JSF2 <h:selectOneMenu and <f:ajax listeners not called after PrettyFaces Filter Navigation

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当f:ajax被执行时,总是调用JSF2 preRenderComponent JSF: f:ajax 监听器未调用 t:selectOneRadio JSF2-f:ajax元素的范围是什么? 数据表中的jsf2 f:ajax渲染问题 与复合组件一起使用且execute =“ @ this”时,未调用JSF f:ajax侦听器 JSF2 <h:selectonemenu and <f:ajax listeners not called after prettyfaces filter navigation< div><div id="text_translate"><p> 使用 Java Web 应用程序时出现问题 JSF + PrettyFaces 处理导航和 bean 操作。</p><p> 使用版本:</p><p> JSF - 2.1<br> 漂亮的脸蛋 - 3.3.3</p><p> 使用来自链接的 PrettyFaces 过滤器处理导航时发生错误:</p><pre> <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></pre><p></p><p> pretty-config.xml 映射是:</p><pre> <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></pre><p></p><p> 豆行动:</p><pre> public String openProductDetails() { if (filters.getProductCategoryName().= null &&.filters.getProductName();equals("")) { loadProductDetailsByName(filters.getProductCategoryName()); } return "/pages/productDetails.faces"; }</pre><p></p><p> 用户登陆产品详细信息页面,在那里他可以 select 产品功能,如颜色、尺寸等......</p><pre> <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></pre><p> //... Bean 动作方法</p><pre> 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()); } } }</pre><p></p><p> 首次导航到产品详细信息页面后,无论何时从 selectOneMenu id="colorSelect" 中选择一个值,都不会调用 valueChangeListener 和 ajax 侦听器。 除此之外,productMB.openProductDetails 操作被调用。</p><p> ajax 调用已完成,我在日志中看到没有错误,但没有调用任何侦听器方法。 有人知道为什么跳过这些 JSF ajax 听众吗?</p><p> 提前致谢。</p></div></h:selectonemenu> JSF2 f:ajax ajax 请求没有查询字符串? 为什么JSF2(PrimeFaces3)Ajax属性监听器未触发? JSF2 AJAX h:selectOneMenu侦听器不会调用 jQuery Chosen和JSF2 f:ajax渲染问题
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM