如何将参数传递给ui:包含c:forEach标记内的参数

时间:2022-06-06 20:05:25

We are trying to create a list with iterating an entity with ui:include.

我们正在尝试创建一个使用ui:include迭代实体的列表。

my .xhtml file is like;

我的.xhtml文件就像;

<c:forEach items="#{entityHome.list}" var="entityId">
    <ui:include src="/some.xhtml">
        <ui:param name="id" value="#{entityId}" />
    </ui:include>
</c:forEach>

We have already created a .xhtml file to visualize single entity. Not we want a list of all entities. Firstly we were using a h:dataGrid but according to this we changed it to c:forEach.

我们已经创建了一个.xhtml文件来可视化单个实体。我们不想要所有实体的列表。首先我们使用的是h:dataGrid,但据此我们将其更改为c:forEach。

Now when page is rendered, fields in /some.xhtml are empty. I think we cant pass parameter to ui:include. By cant i mean for this situation.

现在,当呈现页面时,/ some.xhtml中的字段为空。我想我们不能将参数传递给ui:include。我不是指这种情况。

Any idea?

Thanks.

1 个解决方案

#1


0  

I just had the same problem, what I did to solve it was putting another ui:param above the ui:include, and then link that param to the param inside the ui:include :

我只是遇到了同样的问题,我要解决的问题是在ui:include上面放置另一个ui:param,然后将该param链接到ui中的param:include:

<c:forEach items="#{entityHome.list}" var="entityId">
    <ui:param name="someId" value="#{entityId}"/>
    <ui:include src="/some.xhtml">
        <ui:param name="id" value="#{someId}" />
    </ui:include>
</c:forEach>

This seemed to do the trick for me.

这似乎对我有用。

#1


0  

I just had the same problem, what I did to solve it was putting another ui:param above the ui:include, and then link that param to the param inside the ui:include :

我只是遇到了同样的问题,我要解决的问题是在ui:include上面放置另一个ui:param,然后将该param链接到ui中的param:include:

<c:forEach items="#{entityHome.list}" var="entityId">
    <ui:param name="someId" value="#{entityId}"/>
    <ui:include src="/some.xhtml">
        <ui:param name="id" value="#{someId}" />
    </ui:include>
</c:forEach>

This seemed to do the trick for me.

这似乎对我有用。