0

How to set textbox maxlength attribute from view model?

asked 2012-12-28 09:28:08 +0800

arivwd gravatar image arivwd
6 1

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?

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2013-01-02 04:41:39 +0800

vincentjian gravatar image vincentjian
2245 6

Hi, here is another method to bind component attribute via ViewModel

<textbox maxlength="@bind(vm.maxlength)" />

....
public int getMaxlength() {
    return 5;
}
....

link publish delete flag offensive edit

answered 2013-01-11 13:05:30 +0800

arivwd gravatar image arivwd
6 1

Ok, thats the different approach....
What i really mean is to set the MaxLength of textbox component from within a ViewModel... Is it possible????

link publish delete flag offensive edit

answered 2013-01-11 13:41:39 +0800

hswain gravatar image hswain flag of India
1763 3 10
http://corejavaexample.bl...

remove getFellowIfAny("tb_AAA")
add @wire textbox then it's work

link publish delete flag offensive edit

answered 2013-01-15 01:12:59 +0800

vincentjian gravatar image vincentjian
2245 6

updated 2013-01-15 01:14:10 +0800

@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.

link publish delete flag offensive edit

answered 2013-03-16 05:36:43 +0800

nsharma gravatar image nsharma flag of India
917 1 11

updated 2013-03-16 05:38:01 +0800

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);
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: 2012-12-28 09:28:08 +0800

Seen: 268 times

Last updated: Oct 16 '17

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