-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello,
I use ZK JSF and I would like to output values from a database.
But z:forEach attribute does not work.
For example, the following code does not work (where "solutions" is a List of Objects):
...
<z:rows >
<z:row z:forEach="${solutions}">
<z:label z:value="${each.solutionPK.taskId}" />
<z:label z:value="${each.solutionPK.solutionId}" />
<z:label z:value="${each.solutionPK.moduleId}" />
</z:row>
</z:rows>
...
So, how to iterate over the List?
Regards,
-Andrey
First of all, ZK:forEach is not supported in JSF yet.
Please post it to feature request. Sorry for your inconvinience.
Second, use EL when mixing ZK and JSF, you have to think about which context does the variable belong. The syntax is different.
My suggestion, why not just use ZUL, and include it?
By the way, of this topics. I have a question. Is possible to iterate with forEach in a zul page a list of object? For Example
Person p=new Person("Tommy", "Lee", "12345");// (name, surname, number telephone)
list.add(p);
p=new Person("Jerry", "Sullivan", "56789");
list.add(p);
in a zul page:
<label value="{each}" forEach{p.name}>
<label value="{each}" forEach{p.surname}>
is possible?
I Try what I Henrichen say but the zul page contains a blank window
This is the class
public class Vetrina extends Window{
private List listaBox = new ArrayList();
public Vetrina ()
{
Box box= new Box();
box.setLink("www.aaaaa.it");
box.setPreview("img/aaaa.gif");
box.setTitle("Famoso");
box.setSlide("img/AAAA.gif");
listaBox.add(box);
Box box2= new Box();
box2.setLink("www.bbbb.it");
box2.setPreview("img/bbb.jpg");
box2.setTitle("Altro");
box2.setSlide("img/bbb.jpg");
listaBox.add(box2);
Box box3= new Box();
box3.setLink("www.ccc.it");
box3.setPreview("img/ccc.jpg");
box3.setTitle("Messaggeria");
box3.setSlide("img/ccc.jpg");
listaBox.add(box3);
System.out.println(listaBox.toString());
Executions.getCurrent().getDesktop().getSession().setAttribute("lista", listaBox);
this is a zul file
<?page id="testZul" title=" New ZUL Title" cacheable="false"
language="xul/html" zscriptLanguage="Java" contentType="text/html;charset=UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<zk xmlns="http://www.zkoss.org/2005/zul"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
<div align="center">
<window title="La vetrina di Euro2Box" use="Vetrina" xmlns:h="http://www.w3.org/1999/xhtml" border="normal" width="1024px">
<zscript><![CDATA[
List listaBox=(ArrayList)Executions.getCurrent().getDesktop().getSession().getAttribute("lista");
System.out.println(listaBox.get(0).getLink());
]]></zscript>
<zk forEach="${listabox}">
<label value="${each.link}"/>
<label value="${each.preview}"/>
<label value="${each.slide}"/>
<label value="${each.title}"/>
</zk>
</window>
</div>
</zk>
Please Can U help me? What's my mistake?
Asked: 2008-12-01 12:25:09 +0800
Seen: 659 times
Last updated: Jan 17 '09