-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all,
How do I get listbox from listbox'id ?
<zk>
public class TestVM {
How do I get listbox from listbox'id ?
}
Thanx.
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
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);
}
}
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());
}
}
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
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
Asked: 2014-07-25 04:28:43 +0800
Seen: 39 times
Last updated: Jan 03 '16