0

How to get listbox id from VM ?

asked 2014-07-25 04:28:43 +0800

unitcell gravatar image unitcell
28 4

Hi all,

How do I get listbox from listbox'id ?

<zk>

<listbox id="lb" width="400px" model="@load(vm.itemModel)" itemrenderer="ItemRenderer" <listhead=""> <listheader label="nc"/> <listheader label="name"/> <listheader label="amount"/> </listhead>
</listbox>
</zk>

public class TestVM {

How do I get listbox from listbox'id ?

}

Thanx.

delete flag offensive retag edit

5 Answers

Sort by ยป oldest newest most voted
1

answered 2014-07-25 07:46:38 +0800

cyiannoulis gravatar image cyiannoulis
1201 10

Another way is to use the special @SelectorParam annotation. For example let's say you have a page like this:

<listbox id="lb">
    ....
    ....
</listbox>

<button label="Do Something" onClick="@command('my-command')" />

Then in your view model you can do the following:

@Command("my-command")
public void onMyCommand(@SelectorParam("#lb") Component myListbox) {
    ... do whatever you want with the listbox ...
}

I think this is a more elegant way but it's just my opinion. Hope that helps

Costas

link publish delete flag offensive edit

Comments

+1 for better idea

sitansu ( 2014-07-25 09:51:29 +0800 )edit
0

answered 2014-07-25 05:38:25 +0800

sitansu gravatar image sitansu
2254 13
http://java91.blogspot.in...

Just Try it in your VM:

   @Wire("#lb")
    private Listbox lb;
    public class TestVM {

    @AfterCompose
    public void afterCompose(@ContextParam(ContextType.VIEW) Component view) {

            Selectors.wireComponents(view, this, true);
    }

    }
link publish delete flag offensive edit
0

answered 2016-01-03 06:51:52 +0800

windeyu gravatar image windeyu flag of United States
288 3

I asked myself the same question and found my own answer. Try this.

public class TestVM {
  @Init
  public void init(@ContextParam(ContextType.COMPONENT) Component inComponent) {
    System.out.println("componentID: " + inComponent.getId());
  }
}
link publish delete flag offensive edit
0

answered 2016-01-03 10:39:44 +0800

Darksu gravatar image Darksu
1991 1 4

Hello,

For more information on how to get the id of a component and info regarding the id space please refer to the following document:

http://books.zkoss.org/wiki/ZKDeveloper'sReference/UIComposing/IDSpace

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2016-01-03 10:42:50 +0800

Darksu gravatar image Darksu
1991 1 4

Hello,

For more information on how to get the id of a component and info regarding the id space please refer to the following document:

http://books.zkoss.org/wiki/ZKDeveloper'sReference/UIComposing/IDSpace

Best Regards,

Darksu

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: 2014-07-25 04:28:43 +0800

Seen: 39 times

Last updated: Jan 03 '16

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