如何使用< ui:include>在< h:dataTable> [英] How to use <ui:include> inside a <h:dataTable>?

查看:135
本文介绍了如何使用< ui:include>在< h:dataTable>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要动态地多次输入一个页面< ui:include>

I want to inlude <ui:include> one page dynamically several times.

代码:

<h:dataTable ..>
    <h:column>
        <ui:include  src="#{create_page}">
    <h:column>
<h:dataTable>

现在,当我提交它只存在最后一个内容。它只记住最后一个包含的页面的值。我想要在每个create_page中的唯一实体对象。我该怎么做?

Now when I submit it persists only the last inlude. It remembers only the values for the last included page. I want unique entity object in each create_page. How can I do that?

推荐答案

< ui:include> 是在视图构建时执行的标签处理程序,而< h:dataTable> 是在视图呈现时执行的UI组件。这意味着< ui:include> 在 之前只执行一次 code>,因此不是在迭代。您有效地得到每行中完全相同的包含源。当表单提交时,行被逐个处理,直到最后一行,这就是为什么你有效地得到最后一行的值。

The <ui:include> is as being a tag handler executed during view build time, while the <h:dataTable> is as being an UI component executed during view render time. This means that the <ui:include> is executed only once before the <h:dataTable> and thus not during the iteration. You effectively end up with exactly the same include source in every row. When the form is submitted the rows are processed one by one until the last row, that's why you effectively end up with the values of the last row.

基本上是2解决方法:


  1. 使用< c:forEach> 而不是< h:dataTable> ,这也在视图构建期间运行。

  1. Use <c:forEach> instead of <h:dataTable>, this runs also during view build time.

标签文件或复合组件,而不是< ui:include> ,这也在视图渲染时间运行。

Use a tag file or a composite component instead of <ui:include>, this runs also during view render time.



    无论哪种方式,您还需要确保输入值绑定到datatable的 var 属性后面的对象,而不是一个相同的支持bean属性。

Either way, you also need to ensure that the input values are bound to the object behind the var attribute of the datatable, not to one and same backing bean property.

  • JSTL in JSF2 Facelets... makes sense? (the <ui:include> falls in the same category as JSTL)
  • When to use <ui:include>, tag files, composite components and/or custom components?

这篇关于如何使用&lt; ui:include&gt;在&lt; h:dataTable&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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