-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Problem Listbox get selected item every time same value is returned even different value is selected my code is
private final int _pageSize = 20;
private int _startPageNumber = 0;
private int _totalSize = 0;
private boolean _needsTotalSizeUpdate = true;
private Listbox gonline;
private Paging userPaging;
onlinepagingmodel model = null;
Textbox l;
@Override
public void doAfterCompose(Component comp) throws Exception
{
super.doAfterCompose(comp);
gonline.setItemRenderer(new ListitemRenderer(){
public void render( Listitem li,Object data,int i ) throws Exception {
onlinekwh usr = (onlinekwh)data;
li.setValue(usr);
li.appendChild(new Listcell("" + usr.getId()));
li.appendChild(new Listcell(usr.getCurrentA()+""));
li.appendChild(new Listcell(usr.getCurrentB()+""));
li.appendChild(new Listcell(usr.getCurrentC()+""));
li.appendChild(new Listcell(usr.getkwh()+""));
gonline.appendChild(li);
}
});
refreshModel(this._startPageNumber);
}
public void onPaging$userPaging(ForwardEvent event) {
PagingEvent pe = (PagingEvent)event.getOrigin();
this._startPageNumber = pe.getActivePage();
refreshModel(this._startPageNumber);
}
private void refreshModel(int activePage) {
this.userPaging.setPageSize(20);
this.model = new onlinepagingmodel(activePage, 20);
if (this._needsTotalSizeUpdate) {
this._totalSize = this.model.getTotalSize();
this._needsTotalSizeUpdate = false;
}
this.userPaging.setTotalSize(this._totalSize);
this.gonline.setModel(this.model);
}
public void onSelect$gonline() throws Exception
{
Listitem i=new Listitem();
i=gonline.getSelectedItem();
String a=i.getLabel();
}
}
My zul page is here
<?xml version="1.0" encoding="UTF-8"?>
<zk xmlns="http://www.zkoss.org/2005/zul">
<window border="normal" width="100%" height="100%" apply="demo.onlinecontrol">
<listbox id="gonline" width="100%" height="">
<listhead>
<listheader label="Meter Serial Number" style="background:black;color:yellow" hflex="2"/>
<listheader label="Current A" style="background:black;color:yellow" hflex="1"/>
<listheader label="Current B" style="background:black;color:yellow" hflex="1"/>
<listheader label="Current C" style="background:black;color:yellow" hflex="1"/>
<listheader label="kWh Data" style="background:black;color:yellow" hflex="2"/>
</listhead>
</listbox>
<paging id="userPaging" pageSize="30" style="background:black;color:yellow"/>
</window>
</zk>
See how SelectedItem define
<listbox id="listUsers"
model="@{myWin$ListItemOnSelectSoSomeThingCtrl.users}" selectedItem="@{myWin$ListItemOnSelectSoSomeThingCtrl.selected}">
For detail you can check list-item-on-select-show-more-details
Asked: 2013-09-12 12:17:15 +0800
Seen: 34 times
Last updated: Sep 14 '13
ANy specific reason you are using MVC with the Help of MVVM its easily done? Also did you used selectitem attribute in your zul please share zul code as well
sjoshi ( 2013-09-12 13:02:27 +0800 )edit