# Render arraylist items vertically

ajamardo
21 2

I am building a message system (something really similar to a mailbox), and I will allow the users to attach files.

When they attach a file, it will show a small file icon in the down part, but I want them to be able to attach several files, and I'd like all the icons, one per file horizontally aligned in the same hlayout.

I've been trying to use listbox and grid to do that, but per item, it sets them vertically, so, I don't know how to do that... thanks in advance.

Last code I tested (witht the file names instead the icon, but still the same problem)

 <hlayout hflex="1"> <grid hflex="1" vflex="1" model="@load(vmApp.messageInput.files)"> <template name="model" var="tObj"> <label value="@load(tObj.file.title)"/> </template> </grid> </hlayout> 

delete retag edit

Sort by » oldest newest most voted

cor3000
3690 1 7

Grid and Listbox produce a table layout with a for each item/row. So they are not the suitable component for that. Since ZK 8 (EE) the shadow elements (esp. <foreach>) were added that allow leveraging a list model with any kind of component.

<forEach items="@load(vmApp.messageInput.files)" var="tObj">
<label value="@init(tObj.file.title)"/>
</forEach>


You can try them out using the EE-Eval version 8.0.5-Eval (don't forget to add the zuti jar/artifact to your dependencies).

With ZK CE you can use MVVM children binding which allows a similar thing

<div children="@load(vmApp.messageInput.files)">
<template name="children" var="tObj">
<label value="@init(tObj.file.title)"/>
</template>
</div>


Robert