Welcome, Guest. Please login or register.
Did you miss your activation email?
02/07/12, 08:08
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flex, Air, FlashBuilder, Catalyst (Moderators: ..:: Mazhar Hasan ::.., kofi addaquay)
| | |-+  properly implement subviews in Cairngorm micro-architecture
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: properly implement subviews in Cairngorm micro-architecture  (Read 1722 times)
kofi addaquay
Global Moderator
Senior Programmer
*****
Posts: 450



View Profile WWW Email
« on: 04/07/10, 10:56 »

got a question on how to properly implement subviews in Cairngorm if anyone has experience building flex applications using this mvc architecture. my question is how do you implement changing component subviews in cairngorm. i know how to implement changing main views subviews, but i am not sure of how to properly change subviews which are within the main views subview. do i bind this to the modellocator as well...or implement it locally. not sure.. thanks

Kofi
Logged
kofi addaquay
Global Moderator
Senior Programmer
*****
Posts: 450



View Profile WWW Email
« Reply #1 on: 04/07/10, 14:45 »

whew Embarrassed found a way

in your model package, create a new model to hold the states of your viewstack component ...i created one like this...

Code:
package com.perfect.model
{
public class ProgrammingTabWorkflow
{
public static const PROGRAMMING_DEFAULT_VIEW:Number = 0;
public static const PROGRAMMING_MANAGE:Number = 1;

[Bindable]
public var programmingWorkflowState:Number = PROGRAMMING_DEFAULT_VIEW;
}
}

then in my panel...created a view stack and set a binding to the selectedChild. like this

Code:
selectedChild="{getSelectedChild(workflow.programmingWorkflowState)}"

getSelectedChild is a function that returns a container. the viewstack state is changed based on what is returned from the function Tongue
Logged
papachan
Systems Administrator
*****
Posts: 507


View Profile WWW
« Reply #2 on: 04/08/10, 08:29 »

Thats a cool tip Kofi. thanks.
Logged

kofi addaquay
Global Moderator
Senior Programmer
*****
Posts: 450



View Profile WWW Email
« Reply #3 on: 04/08/10, 08:47 »

great! in that case let me put the getSelectedChild here so its fully clear. below you will see what container gets called.  progDef and progTemplate and the names of the ids of the viewstack components. enjoy Smiley

Code:
private function getSelectedChild( workflowState:Number ):Container
{
switch ( workflowState )
{
case ProgrammingTabWorkflow.PROGRAMMING_DEFAULT_VIEW:
return progDef;
case ProgrammingTabWorkflow.PROGRAMMING_MANAGE:
return progTemplate;
}
throw new Error("Invalid Workflow State");
}
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #4 on: 04/08/10, 09:48 »

I found this problem while working with Cairgorm and yes, you can do some tricks to allow databinding works as expected following the rules (in fact an example for deferred instantiation in PureMVC examples use the same approach for ViewStacks) But basically I find that sometimes this not really helpful when managing lots of little details about views.
I explain this in detail here: http://www.cristalab.com/tips/cairngorm-problemas-para-actualizar-la-vista-c66243l/ ... but sorry ... is in spanish. Basically the trick is to pass an extra callback to the Event, that is carried by the controller, command, delegate and finally invoked in the view to do extra visual stuff (show a confirmation message in my example)
I have finded a lot of little visual tasks that could use this way, and in fact previous versions of Cairgorm have extra classes called ViewHelpers to do this kind of things

Jorge
Logged

kofi addaquay
Global Moderator
Senior Programmer
*****
Posts: 450



View Profile WWW Email
« Reply #5 on: 04/08/10, 10:15 »

ViewHelpers were definitely helpful. but they have be deprecated. I wish i could read spanish Smiley) i am studying it..but not good yet. Its always good to know the little tricks other people have discovered and implemented. but i can get a good idea when you say pass an extra callback to the Event.  Grin Grin
Logged
kofi addaquay
Global Moderator
Senior Programmer
*****
Posts: 450



View Profile WWW Email
« Reply #6 on: 04/14/10, 16:44 »

i thought i should put this link here...as i run into binding problems using selectedChild

http://www.russback.com/adobe-flex/binding-selectedchild-of-a-viewstack-in-mvc.html

Logged
papachan
Systems Administrator
*****
Posts: 507


View Profile WWW
« Reply #7 on: 04/15/10, 07:50 »

In Mate Framework, you dont even need to give the event callBack. The eventMap controller do the job. It map all the event handlers and directly give the right methods to be actualized. Its magic ! Wink

Logged

kofi addaquay
Global Moderator
Senior Programmer
*****
Posts: 450



View Profile WWW Email
« Reply #8 on: 04/15/10, 08:40 »

thats really sweet. !

have you heard of robotlegs?? i hear its the real deal... i think that might be the framework i choose to learn besides puremvc and cairngorm.
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #9 on: 04/15/10, 09:41 »

I have used it in my last piece, it's a nice one, and you don't need to cast all events as in pureMVC

Jorge
Logged

kofi addaquay
Global Moderator
Senior Programmer
*****
Posts: 450



View Profile WWW Email
« Reply #10 on: 04/15/10, 09:45 »

ah really Jorge?? i love puremvc thats why i choose that framework. its interesting to see actionscript adopt java design patterns..very interesting. i have been currently looking at the documentation and is it look awesome.
what is the learning curve like?
Logged
Jorge Solis
Administrator
Systems Administrator
*****
Posts: 14593


View Profile
« Reply #11 on: 04/15/10, 09:55 »

If you have worked with a couple of frameworks, Robotlegs is a couple of days away or less if you have no childrens like me Smiley

Jorge
Logged

kofi addaquay
Global Moderator
Senior Programmer
*****
Posts: 450



View Profile WWW Email
« Reply #12 on: 04/15/10, 10:04 »

haha! no children on my end Jorge.

i need to dig into the docs this weekend then! thanks Jorge...i am glad to know you have already completed a project using this. i can BUG you with questions. yaay. thanks

Kofi
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything