在UI组件ID:重复问题 [英] Component ID in ui:repeat problems

查看:137
本文介绍了在UI组件ID:重复问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图渲染祖父母组成部分。 在code:

I'm trying to render a grandparent component. The code:

<h:form prependId="false>
<h:panelGroup id="outer_panel">
    <ui:repeat var="curr" value="#{bean.map}">
        <h:panelGroup id="inner_panel">
            <h:commandButton value="Remove" action="actionThing" >
                <f:ajax render="outer_panel" />
            </h:commandButton>
        </h:panelGroup>
    </ui:repeat>
</h:panelGroup>
</h:form>

我得到一个异常:

I get an exception:

javax.faces.FacesException: Component with id:outer_panel not found

尝试添加索引的ID,没有工作也不:

Tried to add the index to the id, which didn't work neither:

<h:form prependId="false>
<h:panelGroup id="outer_panel">
    <ui:repeat var="curr" value="#{bean.map}" varStatus="loop">
        <h:panelGroup id="inner_panel">
            <h:commandButton value="Remove" action="actionThing" >
                <f:ajax render="#{loop.index+1}:outer_panel" />
            </h:commandButton>
        </h:panelGroup>
    </ui:repeat>
</h:panelGroup>
</h:form>

为什么找不到该ID的任何想法?

Any idea why the ID is not found?

感谢。

推荐答案

这是没有发现,因为你使用相对客户端ID渲染属性。它成为相对于最接近的父命名容器零件。在这种情况下,这就是&LT; UI:重复&GT; (它prepends产生的行索引的儿童客户端ID)。因此,与ID组件 outer_panel 必须是&LT内部; UI:重复&GT; 为了得到它的工作。但是, outer_panel 是的实际上的外面。

It is not found because you used a relative client ID in render attribute. It becomes relative to the closest parent naming container component. In this case, that's the <ui:repeat> (it prepends generated client ID of the children with the row index). So the component with ID outer_panel has to be inside the <ui:repeat> in order to get it to work. However, the outer_panel is actually outside it.

您需要指定一个相对客户端ID的绝对客户端ID来代替。为了让绝对的(所以它基本上会从视图根扫描),preFIX与客户端ID

You need to specify an absolute client ID instead of a relative client ID. To make it absolute (so that it will basically scan from the view root on), prefix the client ID with :.

<f:ajax render=":outer_panel" />

有关,你没有使用 prependId =假&LT的情况下,H:形式GT; ,那么你就应该用

For the case that you didn't use prependId="false" on the <h:form>, then you should have used

<f:ajax render=":form_id:outer_panel" />

来代替。

这篇关于在UI组件ID:重复问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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