关闭ui:repeat中所有展开的行 [英] Close all expanded rows inside a ui:repeat

查看:140
本文介绍了关闭ui:repeat中所有展开的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ui:在桌子内重复拍卖物品.这是一个常规的html表,因为当您单击出价"命令链接时,将在所选拍卖项目的正下方打开一行,并显示一个出价组件. Bid commandLink正在使用像这样的ajax:

I have a ui:repeat of auction items inside a table. It is a regular html table because when you click on a Bid commandLink a row opens right under the selected auction item, and displays a bidding component. The Bid commandLink is using ajax like this:

<f:ajax listener="#{bean.addBidView(lot)}" render="bidView" />

addBidView正在更新AuctionItems的地图,这就是打开正确的所选行的方式.当用户再次单击相同的Bid链接时,addBidView会将其找出来并关闭出价组件.

addBidView is updating a map of auctionItems and that's how the correct selected row opens up. When the user clicks on the same Bid link again, the addBidView figures it out and closes the bidding component.

现在,我们假设用户点击了几行,从而打开了几个出价组件.它们都打开,但是只有一个处于活动状态.所以这是我的问题:使用上述ajax时如何呈现整个循环,以便打开出价组件将自动关闭其他打开的组件. (拍卖品地图反映了正确的出价组件,但仅呈现了一个出价区域,因此其他出价区域不受影响.如果刷新整个页面,则显示正确,并且仅当我我正在使用ajax.)

Now let's say the user clicks on several rows, and thus opens several bidding components. They all open, but only one is active. So here's my question: how do I get the entire loop to render when I use the above ajax, so that opening a bidding component would automatically close the other open ones. (the auction items map is reflecting the correct bidding component, but only this one bidding area is rendered, so the others aren't effected. If I'm refreshing the whole page, the display is correct, and the problem only exists when I'm using ajax.)

这是页面上元素的结构(所有这些都在h:form:内部)

This is the structure of the elements on the page (all this is inside an h:form:)

<table id="bidstable">
    <h:panelGroup id="entireLoop">
        <ui:repeat id="repeatAuctionItems" var="auctionItem" varStatus="status" value="#{bean.auctionItems}">
            <td>... a bunch of td's with the auction item values ... and then: 
                <h:commandLink id="bid" rendered="#{some conditions}">
                    <f:ajax listener="#{bean.addBidView(auctionItem)}" render="bidView"/>
                </h:commandLink>
            </td>
        </ui:repeat>
    </h:panelGroup>
</table>

我几乎尝试了渲染"中元素的每种组合-例如:

I tried pretty much every combination of elements in the "render" -- for example:

render="bidView bidsTable"

或 render ="bidView bidsTable:entireLoop:repeateAuctionItems"

or render="bidView bidsTable:entireLoop:repeateAuctionItems"

和其他我能想到的线索.什么都行不通.有任何想法吗?

and every other trail I can think of. Nothing works. Any ideas?

推荐答案

您已在<f:ajax render>属性中指定了一个客户端ID,该ID与当前

You have specified a client ID in the <f:ajax render> attribute which is relative to the current NamingContainer component. Client IDs which do not start with the naming container separator character, which defaults to :, are relative to the current NamingContainer component. The <ui:repeat> is such a component. So the client ID has to refer a child of <ui:repeat>. But the component which you are trying to reference is actually outside the <ui:repeat>. You'd need to reference it with an absolute client ID instead.

要找到绝对客户端ID,需要在浏览器中打开页面,右键单击并执行 View Source ,然后找到最接近的父JSF的生成的HTML. <ui:repeat>之外的组件,在您的特殊情况下为<h:panelGroup id="entireLoop">.看起来像这样:

To find the absolute client ID, you need to open the page in the browser, rightclick and do View Source and then locate the generated HTML of the closest parent JSF component outside <ui:repeat>, which is in your particular case the <h:panelGroup id="entireLoop">. It'll look something like:

<span id="someId:possiblyOtherId:entireLoop">

准确获取此客户端ID,并在其前加上:以便在<f:ajax render>中使用.

Take exactly this client ID and prefix it with : for usage in <f:ajax render>.

<f:ajax ... render=":someId:possiblyOtherId:entireLoop" />

如果它包含动态生成的ID(如j_id_123),则需要为所有父级NamingContainer组件(如<h:form>)提供固定的ID(如<h:form id="someId">).

If it contains a dynamically generated ID like j_id_123, then you'd need to give all parent NamingContainer components like <h:form> a fixed ID like <h:form id="someId">.

请注意,不可能引用纯HTML 元素(如<table id="bidsTable">)的客户端ID.它必须是像<h:dataTable id="bidsTable">这样的完全有价值的JSF组件.

Note that it is not possible to reference the client ID of a plain HTML element like <table id="bidsTable">. It has to be a fullworthy JSF component like <h:dataTable id="bidsTable">.

这篇关于关闭ui:repeat中所有展开的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆