0

Problem listbox get selected item every time same value is returned

asked 2013-09-12 12:17:15 +0800

sajidaslam gravatar image sajidaslam
1

updated 2013-09-12 12:59:47 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

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();
}
}
delete flag offensive retag edit

Comments

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

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-09-13 11:47:40 +0800

sajidaslam gravatar image sajidaslam
1

updated 2013-09-14 07:27:23 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

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>
link publish delete flag offensive edit
0

answered 2013-09-14 07:33:08 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

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

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2013-09-12 12:17:15 +0800

Seen: 34 times

Last updated: Sep 14 '13

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