0

Access particular elememt in a list

asked 2009-11-14 06:37:47 +0800

kyc gravatar image kyc
54 1

Hello,

I am using zk 3.6.3 version with spring. I can bind the arraylist from zul and composer componenet. Also I can iterate the arraylist and printout the element in the listbox in the front end.

However, I don't want iterate to get all the elements sequentially. I just want to get a particular element wih index i of the list ListA and put it in a Textbox. i found many document and still don't know how to do. Also, I can't find zuml tag support to do the basic looping without UI control (ListBox) help. Anyone can help?

This kind of problem is from the unfamiliar of basic part of the ZK language. I believe somewhere should have comprehensive guide or example. Can anyone send me useful link for reference.

Thanks a lot.




Thanks.

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2009-11-14 08:03:11 +0800

baskaraninfo gravatar image baskaraninfo
536 2 2 9

" I just want to get a particular element wih index i of the list ListA and put it in a Textbox."

Listbox.getItemAtIndex(index) may help you.

link publish delete flag offensive edit

answered 2009-11-15 04:34:52 +0800

kyc gravatar image kyc
54 1

I want to get Collection ListA element in zul page not listbox element in java

link publish delete flag offensive edit

answered 2009-11-15 20:07:41 +0800

iantsai gravatar image iantsai
2755 1

What do you mean in ZUL page but not in Java?

And you mentioned you want to put something like a "listitem" in a textbox, what's that mean?

maybe you can write a small piece of sample code to illustrate what you want.

link publish delete flag offensive edit

answered 2009-11-15 21:11:10 +0800

kyc gravatar image kyc
54 1

Thank you for your patience to listen to me. Here is some of my program

Domain class relationship:

public class Channel implements java.io.Serializable {
private SortedSet<Osd> osds = new TreeSet<Osd>(new OsdComparator());

//getter and setter here
}

public class Osd implements java.io.Serializable {
private String osdName;
//getter and setter here
}


In Composer class:

private Channel selectedChannel;

public void setSelectedChannel(Channel selectedChannel) {
this.selectedChannel = selectedChannel;
}

public Channel getSelectedChannel() {
return selectedChannel;
}



In the zul page, there is a listbox to show the search result

<listbox rows="10"
selectedItem="@{channelComposer.selectedChannel}"
model="@{channelComposer.searchChannelList, load-after='search.onClick'}">
<listhead>

<listheader label="Osd Name" sort="auto" />

</listhead>
<listitem self="@{each=searchChannel}">
<listcell label="@{searchChannel.osdStr}" />
</listitem>
</listbox>

After user select one of the channel, I want to show the channel's osd name in the textbox. But the channel to osd relationship is one to many
But the number of group of textbox is fixed to two set or a number I defined in another place.

<hbox>
<textbox id="cfOsdName0" value="" width="200px" />
<textbox id="cfOsdNameX0" value="" width="50px" />
<textbox id="cfOsdNameY0" value="" width="50px" />
</hbox>

<hbox>
<textbox id="cfOsdName1" value="" width="200px" />
<textbox id="cfOsdNameX1" value="" width="50px" />
<textbox id="cfOsdNameY1" value="" width="50px" />
</hbox>

Here is my question:
1 ) It seems can't use cfOsdName[0] as the textbox id for binding to the composer Textbox [] cfOsdName

2) I try to use @{channelComposer.selectedChannel.osd[0].osdName} to retrieve the osd set element but seems can't.

3) If I want to loop 2 times of the hbox group, how to represent the for loop in the zul page Since the number of hbox with textbox does not tie to the number of osd elements


Thanks a lot.

link publish delete flag offensive edit

answered 2009-11-17 01:06:58 +0800

iantsai gravatar image iantsai
2755 1

updated 2009-11-17 01:07:46 +0800

Annotated Data Binding is some kind of meta programming, it's not EL.
So ther's no "array" concept support.

Just focus on this:
How does ZK know to display the first osd object's "osdName" in channel's osdList while channel selected?

I think the simplest answer is:
@{selectedChannel.firstOsdName}

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-11-14 06:37:47 +0800

Seen: 514 times

Last updated: Nov 17 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More