JSF AJAX 请求不适用于 hx:panelDialog

发布于 2024-09-19 00:25:13 字数 2837 浏览 5 评论 0原文

我编写了以下代码,

        <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: 行为中,只有第一个在工作,它调用 getter 函数,

<f:selectItems value="#{neoReport.selectItems}"

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

I wrote the following code,

        <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>

Basic idea behind this code is to have a button on the page,when user click,it should get the latest data from bean( by extracting a file,which is continuously getting updated) and fill the List object in databean,so that h:selectManyCheckBox can render that. So i added a behavior with the commandExButton,so that it will get the new data and it should render the latest options in selectManyCheckBox. BUT out of these two hx:behavior,only the first one is working,its calling the getter function of

<f:selectItems value="#{neoReport.selectItems}"

but its not rendering the panelDialog further.If i remove the behavior for "get" it will show the panel dialog but not with the updated data. So i am not able to find out,what exactly wrong i am doing here.Can anyone help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若水微香 2024-09-26 00:25:14

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

您应该只有一个 标记,它可以为您完成所有工作。如果这样做,您应该有一个调用所有三个方法的方法。是否可以使用这些标签通过 AJAX 重新呈现多个组件 - 例如 targetAction="prefPanelGroup,preferenceSet"

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

此外,重新渲染 prefPanelGroup 只能通过告诉 标记更精确的 ID 来实现,例如 "PrefForm:prefPanelGroup"

希望这有帮助,
丹尼尔

First of all I don't know what type of tag library is this. You should point it out in the tags and/or in the question.

You should have only one <hx:behavior> tag, which does all the job for you. If doing so, you should have a method that calls all three methods. Is it possible with these tags to rerender multiple components with AJAX - like targetAction="prefPanelGroup, preferenceSet"?

As far as I know, rerendering preferenceSet will cause prefPanelGroup to rerender too, so it's pointless to rerender separately.

Also, rerendering prefPanelGroup will work only by telling the <hx:behavior> tag a more precise id, like "PrefForm:prefPanelGroup".

Hope this helps,
Daniel

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文