0

listbox can not select Issues

asked 2013-06-25 08:15:07 +0800

wiker gravatar image wiker
1

updated 2013-06-25 10:31:24 +0800

Steps to Reproduce:

  1. Selected service Type of Plan 30.
  2. Select Network dropdown listitem label="Out Network"
  3. Selected other service of "222 2"

Expected: Selected seconde index Listitem(label = '22222') on Network . Actual: Selected Network is not default first index.

test.zul

<zk>

<window apply="com.emdeon.entity.TestWinController" id="testWin" width="200px" position="center">

    <grid>
        <rows>
            <row>
                <label value="Service Type:" />
                <listbox id="lbService" mold="select" rows="1"
                    width="100%" model="@{testWin$composer.serviceTypeOption}">
                </listbox>
            </row>
            <row>
                <label value="Network:" />
                <listbox id="lbNetwork" mold="select" rows="1"
                    width="100%">
                    <listitem label="In Network" selected="true"
                        value="IN" />
                    <listitem label="Out Network" value="OUT" />
                    <listitem label="Not Provided" value="UNK" />
                </listbox>
            </row>
            <row>
                <label value="Coverage:" />
                <listbox id="lbCoverage" mold="select" rows="1"
                    width="100%">
                    <listitem label="Individual" selected="true"
                        value="Individual" />
                    <listitem label="Family" value="Family" />
                    <listitem label="ALL" value="ALL" />
                </listbox>
            </row>
        </rows>
    </grid>
</window>

</zk>

TestWinController.java

import java.util.ArrayList; import java.util.Iterator; import java.util.List;

import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.ForwardEvent; import org.zkoss.zk.ui.util.GenericForwardComposer; import org.zkoss.zkplus.databind.AnnotateDataBinder; import org.zkoss.zul.Listbox; import org.zkoss.zul.Listitem; import org.zkoss.zul.Window;

public class TestWinController extends GenericForwardComposer<window> {

private static final long serialVersionUID = 880002401824364938L;
AnnotateDataBinder binder; 
Listbox lbService,lbNetwork,lbCoverage;
private List<String> serviceTypeOption = new ArrayList<String>();

public TestWinController(){
    serviceTypeOption.add("Plan 30");
    serviceTypeOption.add("Coverage 1");
    serviceTypeOption.add("222 2");
    serviceTypeOption.add("333 3");
}



@Override
public void doAfterCompose(Window comp) throws Exception {
    // TODO Auto-generated method stub
    super.doAfterCompose(comp);
    binder = new AnnotateDataBinder(comp);

// lbNetwork.getItems().clear(); // lbCoverage.getItems().clear(); binder.loadAll(); }

public void onSelect$lbService(ForwardEvent event){
    lbNetwork.getItems().clear();
    lbCoverage.getItems().clear();

    Listitem item1 = new Listitem();
    item1.setLabel("111");
    item1.setValue("11111");

    lbNetwork.appendChild(item1);

    Listitem item2 = new Listitem();
    item2.setLabel("222");
    item2.setValue("22222");
    lbNetwork.appendChild(item2);

    lbNetwork.selectItem(item2);

}
delete flag offensive retag edit

Comments

ListModelList<String> tstModel = new ListModelList<String>();

tstModel.clear(); tstModel.add("11111"); tstModel.add("22222"); tstModel.add("33333");
tstModel.addToSelection(tstModel.get(2));

tstModel.addToSelection(index) can resolve this issue.

Thanks.

wiker ( 2013-06-27 07:02:02 +0800 )edit

So you resolved issue?

sjoshi ( 2013-06-27 07:35:53 +0800 )edit

yes , thanks.

wiker ( 2013-07-09 06:31:03 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-06-25 10:10:14 +0800

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

updated 2013-06-25 13:52:32 +0800

Wire your Listbox in ViewModel ,See a Demo Of Listbox In MVVM Architecture http://zkframeworkhint.blogspot.in/2013/02/zk-set-desire-selection-in-listbox-model.html

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-06-25 08:15:07 +0800

Seen: 37 times

Last updated: Jun 25 '13

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