0

Reset of value in listbox using ListitemRenderer very long

asked 2015-03-17 02:23:57 +0800

onsir gravatar image onsir
132 2

updated 2015-03-17 04:59:20 +0800

Hello, I have a window that contains components listbox, In listbox used for data input. Once completed, the data input and i going to do that on the reset the listbox

but when i click reset button The process has required a long time in about three seconds

How did to faster so that at the time of resetting listbox not long ?

this my code

zul file

<zk><window id="win" width="1200px"  border="normal" apply="${Controller},render.InvoiceRenderer" >
  <listbox id="listboxDetailEntry" sizedByContent="true" rows="200"  
          mold="paging" pageSize="10000" height="350px"  nonselectableTags=""/></window></zk>

Controller file

public class InvoiceController extends GenericForwardComposer {

@Override
public void doAfterCompose(Component comp) throws Exception {
     super.doAfterCompose(comp);

     invRenderer=new InvoiceRenderer();
     invRenderer.doAfterCompose(comp);
     setListDetailEntry(new ArrayList<Tmp1>());

     ListModelList listModel = new ListModelList(getListDetailEntry()); 
     listboxDetailEntry.setModel(listModel);
     listboxDetailEntry.setItemRenderer(invRenderer);
     listboxDetailEntry.setMultiple(true);
     listModel.setSelection(listModel);

 }


 //for empty value
 public void setEmptyRow(){
 for(int i=0;i<75;i++){
    Tmp1 tmp=new Tmp1();
    tmp.setField1(null);
    tmp.setField2(null);
    getListDetailEntry().add(tmp);
}


//reset listbox with empty value
public void onClick$btnReset(){

 setListDetailEntry(new ArrayList<ReportTmp1>());
 setEmptyRow();
 ListModelList listModel=new ListModelList(getListDetailEntry()); 
 listboxDetailEntry.setModel(listModel);
 listboxDetailEntry.setItemRenderer(invRenderer);
 listboxDetailEntry.setMultiple(true);
 listboxDetailEntry.renderAll();
 listboxDetailEntry.setSelectedIndex(0);

}

class Renderer

public class InvoiceRenderer extends GenericForwardComposer implements Serializable,ListitemRenderer<Tmp1>{

  @Override
  public void doAfterCompose(Component comp) throws Exception {
       super.doAfterCompose(comp);
}

  public void render(final Listitem listitem, Tmp1 tmp1, int index)throws Exception {

            Tmp1 tmp= tmp1;

            final Listcell codeCell = new Listcell();
            final Textbox txtCode= new Textbox();
            codeCell.appendChild(txtCode);

            final Listcell qtyCell = new Listcell();
            final Intbox intQty = new Intbox();
            qtryCell.appendChild(intQt);
            .
            .
            //about 25cell

            listitem.appendChild(codeCell);
            listitem.appendChild(qtyCell);
            listitem.setSelected(true);
            listitem.setValue(tmp);

  }

thanks

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-03-18 05:37:32 +0800

echarish gravatar image echarish flag of Japan
1809 7
http://jp.linkedin.com/in...

by resetting i am guessing you want to make you listbox to its original state as you display it when doing first display, as far as i can think you don't need to fetch list model again by calling getListDetailEntry() because i think it is being fetched from DB that is what taking time, if you just want to reset it to original unselected state simply set selected index to 0 or -1.

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: 2015-03-17 02:23:57 +0800

Seen: 10 times

Last updated: Mar 18 '15

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