presentation model login

53 views
Skip to first unread message

matiasxx

unread,
Mar 26, 2014, 12:42:18 PM3/26/14
to swiz-fr...@googlegroups.com
Hi,

I'm trying to understand and use PM with my flex app.
I'm trying this with a simple login, but a don't know if is a best practice to do this in my click event on the Button control on my LoginView:

<s:Button label="Login" click = "{model.validateData(txtUser.text, txtPassword.text)}" />

and in my PM define validateData:

public function validateData(user:String, pass:String):void{

  //verify data
}

In the other hand (the way a liky but it's not working) i have this:

<mx:TextInput id = "txtUser" text = "{model.user}" />
<mx:TextInput id = "txtPassword" text ="{model.password}" />
<s:Button label="Login" click = "{model.validateData()}" />

I defined user and password vars in my PM ( Bindable both) but they are empty when validateData() execute. I assume that  " text = "{model.user}"  " is empty so that's the razon.
But i'd like to proceed the second way but my vars are empty. (in PM a call controllers and so on).
So that's the razon why 'im asking if the first approche it's ok

Thanks in advance






Margo Powell

unread,
Mar 26, 2014, 4:02:30 PM3/26/14
to swiz-fr...@googlegroups.com, mati...@gmail.com
You can make your first approach work.

In your current version, when model.user is changed in your presentation model the TextInput component will be updated. 

When the user inputs text into the TextInput component, you are not updating the model.user value. There is not a two way binding occuring.

I did a quick google and found the following link which provides you with an example.
View the section on Dispatching and Handling Events:







--
You received this message because you are subscribed to the Google Groups "Swiz Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swiz-framewor...@googlegroups.com.
To post to this group, send email to swiz-fr...@googlegroups.com.
Visit this group at http://groups.google.com/group/swiz-framework.
For more options, visit https://groups.google.com/d/optout.

Matias Gutierrez

unread,
Mar 27, 2014, 9:00:57 AM3/27/14
to Margo Powell, swiz-fr...@googlegroups.com
Hi Margo,

I saw this on Swiz documentation pdf. Thanks.
My point was if two way binding but i want to do the logic on PM.

The example seems to usa AS3 en a form view. I want do that but in my PM and i can't update model.user.
i'll try to see how to implement this.
Thanks !!
--
Matias Gutierrez

Matias Gutierrez

unread,
Mar 27, 2014, 9:34:25 AM3/27/14
to Margo Powell, swiz-fr...@googlegroups.com
the "@" char seems to do the work, because a try the similar way without it and didn't work.

Thank you!

--
Matias Gutierrez
Reply all
Reply to author
Forward
0 new messages