简体   繁体   English

表外的JSF Ajax组件更新不起作用

[英]JSF ajax component update outside table does not work

I have below code, any of the components out side table does not update in ajax call. 我有下面的代码,表外的任何组件都不会在ajax调用中更新。 The component "lms-vouchers-error-div" and other component out side data is not updated.I tried so many ways, but it does not work. 组件“ lms-vouchers-error-div”和其他组件外部数据未更新。我尝试了很多方法,但不起作用。 Please help."form" is the form id 请帮助。“表单”是表单ID

<h:panelGroup id="lms-prestige-inner-div" layout="block"
            styleClass="lmsPricePlanInnerDiv">
            <table class="pricePlanTable">
                <ui:repeat var="vo" value="#{orderOverviewBean.prestigeVouchers}"
                    varStatus="status">

                    <ui:fragment rendered="#{status.index > 0}">
                        <tr>
                            <td colspan="2">
                                <h2 class="#{vo.atLeastOneItemSelected ? 'remove' : 'redeem'}">
                                    <span
                                        class="#{vo.atLeastOneItemSelected ? 'removeline-center' : 'redeemline-center'}">or</span>
                                </h2>
                            </td>
                        </tr>
                    </ui:fragment>
                    <tr>
                        <td style="width: 302px">Voucher
                            #{status.index+1}.$#{-vo.amount} expires on
                            &nbsp;#{vo.expireDate}</td>

                        <td class="spanDisable"><h:commandLink value="> Redeem"
                                styleClass="removeUnderline" rendered="#{not vo.selected}"
                                disabled="#{vo.atLeastOneItemSelected}"
                                action="#{orderOverviewBean.addPrestigeVoucher}">
                                <f:setPropertyActionListener
                                    target="#{orderOverviewBean.selectedVoucherItem}"
                                    value="#{vo}" />

                                <f:ajax
                                    render=":form:total-price-container :form:lms-vouchers-error-div :form:lms-prestige-div"
                                    onevent="lmsVoucherDisplayLoader.displayLoader" />
                            </h:commandLink> <h:commandLink value="> Remove" styleClass="removeUnderline"
                                rendered="#{vo.selected}"
                                action="#{orderOverviewBean.removePrestigeVoucher}">
                                <f:setPropertyActionListener
                                    target="#{orderOverviewBean.selectedVoucherItem}"
                                    value="#{vo}" />

                                <f:ajax
                                    render=":form:total-price-container :form:lms-vouchers-error-div :form:lms-prestige-div"
                                    onevent="lmsVoucherDisplayLoader.displayLoader" />
                            </h:commandLink></td>


                        <ui:fragment rendered="#{vo.selected}">

                            <td style="width: 350px; text-align: right;">
                                -$#{-vo.amount}</td>
                        </ui:fragment>

                    </tr>
                </ui:repeat>
            </table>
        </h:panelGroup>

A common mistake that lead to this kind of problems is make an ajax/updatable container conditionally rendered: 导致此类问题的常见错误是有条件地渲染ajax /可更新容器:

ie: if you try to update with ajax this container: 即:如果您尝试使用ajax更新此容器:

<ui:fragment id="lms-vouchers-error-div" rendered="#{false_condition}"/>

Even if the rendered condition change to true with your ajax/update process, it will not be rendered, because it doesn't exists in your previous html generated code, so instead, try to wrap (in an 'always visible wrapper container') your conditional container, with <h:panelGroup/> or if you use primefaces <p:outputPanel/> 即使使用ajax / update过程将呈现的条件更改为true,也不会呈现它,因为它在先前的html生成的代码中不存在,因此,请尝试包装(在“始终可见的包装容器”中)您的条件容器,带<h:panelGroup/>或者如果您使用质数<p:outputPanel/>

ie: 即:

<h:panelGroup id="target_to_update_with_ajax">
    <ui:fragment id="lms-vouchers-error-div" rendered="#{condition}"/>
</h:panelGroup>

This is a suggestion that maybe works for your case, but if you post the rest of your code it would be more clear. 这是一个建议,可能适合您的情况,但是如果您发布其余代码,则将更加清楚。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM