遍历JSF 1.2中的列表 [英] Iterating over a list in JSF 1.2

查看:69
本文介绍了遍历JSF 1.2中的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在不使用任何第三方组件的情况下,是否有任何方法可以迭代JSF 1.2中的列表?我知道我可以使用战斧做到这一点.我也知道可以使用JSTL做到这一点,但我将其作为最后的选择.另外,由于我们使用的是JSF 1.2,因此我不能使用<ui:repeat>.有没有像<ui:repeat>这样的优雅方法可以在jsf 1.2中实现?

Is there any way of iterating over a list in JSF 1.2 without using any third party components? I know I can do it using Tomahawk. I also know that it can be done using JSTL, but I am keeping that as my last resort. Also I cannot use <ui:repeat> since we are using JSF 1.2. Is there any elegant way like <ui:repeat> to do it in jsf 1.2?

推荐答案

唯一的在JSP中,唯一可以迭代List的其他标准"(即非第三方")标记是JSTL JSF2 Facelets中的JSTL中也提到的原因,此操作不起作用...有意义吗?

In JSP, the only other "standard" (i.e. not "3rd party") tag which can iterate over a List is the JSTL <c:forEach>. Using JSTL shouldn't harm that much if the List which you'd like to iterate over is already available during view build time. You'll only run into trouble when it's only available during view render time, for example because it's been nested in a <h:dataTable> and should be iterating over a property of table's var. This just won't work due to reasons also mentioned in JSTL in JSF2 Facelets... makes sense?

除非您愿意通过自己创建自定义的UIComponent重新发明轮子,否则没有其他方法可以使用不使用Tomahawk的<t:dataList>之类的第三方库.但是,这并不是一件容易的事.

There are no other ways without using a 3rd party library such as Tomahawk's <t:dataList>, unless you're open to reinventing the wheel by creating a custom UIComponent yourself. This is however not a trivial job.

但是可以将Facelets 1.x集成到JSF 1.2中. Facelets 1.x docbook 中介绍了指南.如果您已经拥有使用JSP作为视图技术的现有JSF应用程序,那么这将是相当多的工作.您需要将JSP转换为Facelets.但这最终会使升级到JSF 2.x的路径变得更加容易.另请参阅从JSF 1.2迁移到JSF 2.0 为什么首选Facelets是从JSF2.0开始使用JSP作为视图定义语言?

It's however possible to integrate Facelets 1.x in JSF 1.2. A guide is described in the Facelets 1.x docbook. This is only going to be quite some of work if you already have an existing JSF application using JSP as view technology; you'd need to convert JSP to Facelets. But it'll in end make the upgrade path to JSF 2.x so much easier. See also a.o. Migrating from JSF 1.2 to JSF 2.0 and Why Facelets is preferred over JSP as the view definition language from JSF2.0 onwards?

这篇关于遍历JSF 1.2中的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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