0

combobox setSelectedIndex problem

asked 2010-07-28 03:00:08 +0800

adamzk gravatar image adamzk
207 1

Hi all

I am creating a listbox programatically:

	       final Combobox combo = new Combobox();
		combo.setReadonly(true);
		combo.setConstraint("no empty");
		
		List<Dict> dict =factory.getAllDicts();
		ListModel dictModel = new BindingListSubModelList(dict, true);		

		combo.setVisible(true);		

		Comboitem comboitem = new Comboitem();
		ZKCompUtil.createDataBindingAnnotation(comboitem,"self", "each=e",null,false);
		ZKCompUtil.createDataBindingAnnotation(comboitem,"label","e.getLabel",null,false);
		ZKCompUtil.createDataBindingAnnotation(comboitem,"value","e.getId",null,false);
		combo.appendChild(comboitem);

		combo.setModel(dictModel);
		combo.setItemRenderer(new DictComboitemRenderer());

This code is invoked on listbox row, when it is being edited, and labels are changing to edit fields, some of them to comboboxes.
When the row is changing to edit state and my listbox is being shown there is no value selected. I am able to retrieve the underlying value and its index, but invoking setSelectedIndex on combobox results in ArrayIndexOfBoundsException. I think i should bind the data in some way, but don't know how.
Maybe you can provide some example.
I was thininking about changing to listbox (mold=select) but I was getting the same error.

Regards.

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-07-29 02:50:19 +0800

adamzk gravatar image adamzk
207 1

up

link publish delete flag offensive edit

answered 2010-07-29 06:11:21 +0800

vinhvo gravatar image vinhvo
369 3

try to use this event to setselectedIndex for combo box:

	public void onInitRenderLater$cbLine(Event evt) {
		try {
			ListModelList lml = (ListModelList) cbLine.getModel();
			cbLine.setSelectedIndex(ZkossUtil.getLineIndex(lineId, lml));
		} catch (Exception e) {

		}
	}

link publish delete flag offensive edit

answered 2010-07-29 07:13:20 +0800

adamzk gravatar image adamzk
207 1

Thnak you very much.
It works :)

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: 2010-07-28 03:00:08 +0800

Seen: 321 times

Last updated: Jul 29 '10

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