【问题标题】:JSF AJAX Request not working with hx:panelDialogJSF AJAX 请求不适用于 hx:panelDialog
【发布时间】:2010-09-14 19:47:11
【问题描述】:

我写了以下代码,

        <h:form id="PrefForm" >
        <hx:commandExButton id="preferenceButton" type="button" style="align:right;" value="#{nls.preferenceLink }" title="#{nls.preferenceLinkTitle}" >
                    <hx:behavior event="onclick" behaviorAction="get" targetAction="prefPanelGroup"></hx:behavior>
                    <hx:behavior event="onclick" behaviorAction="show;stop" targetAction="preferenceSet"></hx:behavior>
        </hx:commandExButton>

        <hx:panelDialog id="preferenceSet"    type="modal" styleClass="panelDialog" title="#{nls.preferenceDialogTitle}" >
            <h:outputText styleClass="panelStartMessage" style="display:block;" value="#{nls.preferenceDialogWindowText}" />

            <h:panelGroup id="prefPanelGroup" rendered="#{neoReport.hasSelectItem }" style="display:block;width:300px;height:360px;overflow:auto;" >
                <hx:ajaxRefreshRequest id="refreshform" />
                <h:selectManyCheckbox value="#{neoReport.selectedItems}" layout="pageDirection">
                        <f:selectItems value="#{neoReport.selectItems}" />
                </h:selectManyCheckbox>
            </h:panelGroup> 

            <hx:panelBox id="noCommandWindow" rendered="#{!neoReport.hasSelectItem }" style="display:block;width:300px;height:50px;" layout="lineDirection"> 
                <h:outputText styleClass="outputText" id="cmdInfo"    value="#{nls.noCommands}" />
            </hx:panelBox>

            <h:panelGroup id="buttonBox1" styleClass="panelStartBox" >
                    <hx:commandExButton id="submitPref"    styleClass="commandExButton" type="submit" value="#{nls.submit}" action="#{neoReport.action}">
                        <hx:behavior event="onclick" behaviorAction="hide"    targetAction="preferenceSet" id="behaviorSubmitPref" />
                    </hx:commandExButton>
                    <hx:commandExButton id="CancelPref"    styleClass="commandExButton" type="submit" value="#{nls.cancel}" action="neoReport">
                        <hx:behavior event="onclick" behaviorAction="hide"    targetAction="preferenceSet" id="behaviorCancelPref" />
                    </hx:commandExButton>
            </h:panelGroup>
         </hx:panelDialog>
    </h:form>

此代码背后的基本思想是在页面上有一个按钮,当用户单击时,它应该从bean中获取最新数据(通过提取文件,不断更新)并将List对象填充到databean中,所以h:selectManyCheckBox 可以呈现它。所以我用commandExButton添加了一个行为,这样它就会得到新的数据,它应该在selectManyCheckBox中呈现最新的选项。但是在这两个 hx:behavior 中,只有第一个在工作,它调用了

的 getter 函数
<f:selectItems value="#{neoReport.selectItems}"

但它不会进一步渲染 panelDialog。如果我删除“get”的行为,它将显示面板对话框,但不会显示更新的数据。所以我无法找出,我在这里做错了什么。有人可以帮忙吗?

【问题讨论】:

    标签: ajax jsf ibm-jsf


    【解决方案1】:

    首先我不知道这是什么类型的标签库。你应该在标签和/或问题中指出它。

    您应该只有一个&lt;hx:behavior&gt; 标签,它可以为您完成所有工作。如果这样做,您应该有一个调用所有三个方法的方法。这些标签是否可以使用 AJAX 重新渲染多个组件 - 例如targetAction="prefPanelGroup, preferenceSet"

    据我所知,重新渲染preferenceSet会导致prefPanelGroup也重新渲染,所以单独重新渲染是没有意义的。

    此外,重新渲染prefPanelGroup 只能通过告诉&lt;hx:behavior&gt; 标签更精确的ID 来工作,例如"PrefForm:prefPanelGroup"

    希望这会有所帮助, 丹尼尔

    【讨论】:

    • 那些hx 标记是“IBM Faces 客户端框架”的一部分,这是一个文档很少的 JSF 组件库,由 IBM Websphere/RAD 独家提供。
    猜你喜欢
    • 2012-09-02
    • 1970-01-01
    • 1970-01-01
    • 2012-12-21
    • 2019-12-02
    • 2014-04-26
    • 2016-03-20
    • 1970-01-01
    • 2011-09-24
    相关资源
    最近更新 更多