Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
860 views
in Technique[技术] by (71.8m points)

jsf 1.2 - Iterating over a list in 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The only JSF 1.2 component which can iterate over a List is the <h:dataTable>.

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?

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.

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...