-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm trying to set maxlength attribute via viewmodel...
But it doesnt work.
Here is my lines.
.... .... @Init public void onCreateDialog(@ContextParam(ContextType.VIEW) Component view, @ExecutionArgParam("rrheader") RrHeader arg1, @ExecutionArgParam("listBoxWarehouse") Listbox arg2, @ExecutionArgParam("objListCtrl") ReceivingItemVM arg3, @ExecutionArgParam("msgLabel") Map<String, String> arg4) { Selectors.wireComponents(view, this, false); Textbox tb_AAA = (Textbox) view.getFellowIfAny("tb_AAA"); tb_AAA.setMaxlength(5); } .... ....
What's wrong?
Hi, here is another method to bind component attribute via ViewModel
<textbox maxlength="@bind(vm.maxlength)" />
.... public int getMaxlength() { return 5; } ....
remove getFellowIfAny("tb_AAA")
add @wire textbox then it's work
@arivwd,
Not sure what you are trying to do. It is not good to set component attribute and wire component within ViewModel.
However, you can refer to this document.
You have to use the @wire annotation ,this will wire your textbox(zul) to your viewmodel,from there you can set its attributes(example maxlength).
@wire("tb_AAA")
Textbox textbox;
and remove the line:
Textbox tb_AAA = (Textbox) view.getFellowIfAny("tb_AAA");
instead do
textbox.setMaxLenth(5);
Asked: 2012-12-28 09:28:08 +0800
Seen: 268 times
Last updated: Oct 16 '17