Ok, there are certainly more qualified people on this list (especially the creators of Cairngorm) that could give you some sage advice.  But let me throw out a couple of ideas and try to help you.  It's a little difficult to know what your use-case is exactly without seeing the code, but here is a simple scenario.  There are two things to keep in mind.  In Cairngorm, there is only one control class; the FrontController.  Also, you shouldn't need to maintain two sets of data in the ModelLocator.  You can bind the same value object (data) to more than one view (component).  For example, let's say that you have:

2 views - visitorView and ownerView (view)
3 events - getMessages, insertMessage, updateMessage (control - FrontController)
3 commands - getMessagesCommand, insertMessageCommand, updateMessageCommand (commands)
3 delegates - getMessagesDelegate, insertMessageDelegate, updateMessageDelegate (business)
2 valueObjects - messageVO, selectedMessage (vo and model - ModelLocator)

The views dictate which user gestures (events) are allowed to be dispatched; based on the role of the user (vistor or owner)  For instance, both views allow the user to read messages (getMessages) and post messages (insertMessage).  While only the owner view allows the user to edit messages (editMessage).  Before you change the view state, you dispatch the getMessages event (to return messages based on the user's role).  The event causes the getMessagesCommand to execute, which in turn instantiates the getMessagesDelegate class.  The result from the service call is then cast to the messageVO, which resides in the modelLocator.  The messageVO can then be bound to both views, since they both allow the user to read messages.  Even though the VO is bound to both views, the user will only see the view that is associated with their role.  The same scenario can be used for posting messages, because it is a common user gesture for both views.  For the gestures that are unique to a view, like editing a message in the ownerView, you would only dispatch the appropriate event (updateMessage) that is allowed for the user's role.  Simply stated, the ownerView would have an edit button and the visitor view wouldn't  I know that this isn't your exact use-case, but hopefully it will give you some ideas.

Regards,
Tim Hoff

 


--- In flexcoders@yahoogroups.com, "maxym.hryniv" <[EMAIL PROTECTED]> wrote:
>
> Hy, coders.
> I have a question:
> We are creating social network portal. Any user of our network must
> have a possibility to create his own guestbook.
> I have questbook control that supports 2 states: Owner and visitor
> (created using viewstates mechanism). In owner mode you have full
> control of your guestbook and in visitor mode you can only post
> messages. When you open your own blog it uses one set of server
> Delegates and when you open another person blog it uses another set.
> If i use standart cairngorm approach i have to create 2 different sets
> of data in ModelLocator for owner view and for visitor view and then i
> have to create 2 different control classes. Can someone suggest me how
> to resolve this problem, cause i want to use the same control class.
> I'll probably have superuser mode, and i don't want to make a
> copy&paste.
> Btw it's all about flex 1.5, Cairngorm 0.99.
>



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to