RE: [flexcoders] Re: Cairngorm microarchitecture. 2 instances of view with different data.

2006-05-16 Thread Steven Webster



Hey,

 1. Using this approach i'm loosing all advantages of flex 
 data binding, cause if i make decomposition (i did) of my 
 view, binding to specific property will be really painfull 
 thing and has to be done by hands.

So I don't *quite* follow your example ... If you could even give some
psuedo-code of the difficulty you perceive, that might help me grasp
what you see as a problem. To me, the idea of achieving reuse is that
the same component can be used multiple times within one application,
and between different applications.

However, at the highest level of abstraction (within the Application
tag for instance), it's acceptable for me that a reusable component
receive it's data from some application-specific data store (the
ModelLocator in this sense), while any dependant children (components
that you decompose) receive their data directly from their parent.

Imagine (from my previous example) that you have:

MyView.mxml
 |
 +-- MySubViewA.mxml
 |
 +-- MySubViewB.mxml
 |
 +-- MySubViewC.mxml
 |
 +-- MySubSubView.mxml 

So we have our MyView.mxml component from my previous email, but now we
can look deeper at it's implementation and recognise that it decomposes
into several dependant children.

Now if what you're telling me is that your MySubViewB and MySubSubView
components also need to fetch that data from the ModelLocator, then the
approach I'd suggest is:

view:MyView.mxml instanceSpecificData={
ModelLocator.getInstance().theData } /

But then if you look inside MyView.mxml, it would contain:

view:MySubViewB data="" /

Rather than:

view:MySubViewB data="" ModelLocator.getInstance().theData } /

So only the parent container (MyView) interacts with the ModelLocator -
once it has the data, it's dependant child objects My(Sub)+(View)*.mxml
- there's a reg-exp for you - simply receive that data from their
parent. 

For me, this is the correct abstraction of when to get data from a
parent, versus when to get it from the model.

Make sense ?


 2. What about different set of delegates for every view 
 (depends on server architecture)??

While I don't necessarily subscribe to the idea that delegates should
have a one-to-one mapping with views (I don't know your app, so I can't
comment specifically), I see no reason why the delegate layer should
impact on this model/view binding strategy.

 3. Don't u think that restriction and freedom seems different?

Hey, I'm just a guy from the RIA practice. I'm not sure we have a
metaphysics practice. :-)

Best,

Steven

--
Steven Webster
Practice Director (Rich Internet Applications)
Adobe Consulting
Westpoint, 4 Redheughs Rigg, South Gyle, Edinburgh, EH12 9DQ, UK
p: +44 (0) 131 338 6108
m: +44 (0) 7917 428 947 
[EMAIL PROTECTED] 







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



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  












RE: [flexcoders] Re: Cairngorm microarchitecture. 2 instances of view with different data.

2006-05-15 Thread Dimitrios Gianninas




Hi,

Unless I don't fully understand your problem, the solution is simple. You don't need to create 2 different models for the same data. You create the variable to hold your data on the ModelLocator (ex.: ModelLocator.messages) and then bind this variables to controls on our 2 views. First part done.

Now, when the owner logs in, you will get his messages and assign them to this variable, OR when a visitor logs in, you do exactly the same thing. You don't need 2 FrontControllers, always use one.

I think your question has more to do with controlling what a visitor can do as opposed to a owner, which has more power. Yes?

Dimitrios Gianninas

-Original Message-
From: flexcoders@yahoogroups.com on behalf of maxym.hryniv
Sent: Mon 5/15/2006 3:29 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Cairngorm microarchitecture. 2 instances of view with different data.
 
Thanx for reply Tim, but you didnt't understand my question.
If i bind the same value object (data) to more than one 
view(component) i'll have the same information in both views, but i 
must have different information. 
Before you change the view state, you dispatch the getMessages event 
(to return messages based on the user's role) - It's called HARDCODE 
and it's unacceptable. 
And i have to display different information at the same time in 
different instances of one view thats why your suggestion will not 
work. However thank you.
Btw i have different delegates for different states cause of server 
side architecture. It's another one reason why it will not work.

Waiting for reply.

--- In flexcoders@yahoogroups.com, Tim Hoff [EMAIL PROTECTED] wrote:

 
 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 mokus@ 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
  copypaste.
  Btw it's all about flex

RE: [flexcoders] Re: Cairngorm microarchitecture. 2 instances of view with different data.

2006-05-15 Thread Dimitrios Gianninas





Ok, maybe if you can provide some sample code or a 
screenshot of what these two views look like would help. Is it that the two 
views are going to update the data in two different 
fashions?

Dimitrios 
Gianninas
RIADeveloper
Optimal 
Payments Inc.



From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On Behalf Of 
maxym.hrynivSent: Monday, May 15, 2006 8:04 AMTo: 
flexcoders@yahoogroups.comSubject: [flexcoders] Re: Cairngorm 
microarchitecture. 2 instances of view with different data.
True, You don't understand my problem.I have1. 2 different 
set of delegates (different classes)2. 2 different data instances (the same 
data class)3. 2 instances of ONE view that support 2 modes.I have to see 
in THE SAME TIME one instance of view with one set of data and another with 
second set of data.Waiting for reply.--- In 
flexcoders@yahoogroups.com, "Dimitrios Gianninas" 
dimitrios.[EMAIL PROTECTED] wrote:  Hi, 
 Unless I don't fully understand your problem, the solution is 
simple. You don't need to create 2 different models for the same 
data. You create the variable to hold your data on the ModelLocator 
(ex.: ModelLocator.messages) and then bind this variables to controls on 
our 2 views. First part done.  Now, when the owner logs in, you 
will get his messages and assign them to this variable, OR when a visitor 
logs in, you do exactly the same thing. You don't need 2 FrontControllers, 
always use one.  I think your question has more to do with 
controlling what a visitor can do as opposed to a owner, which has more 
power. Yes?  Dimitrios Gianninas  -Original 
Message- From: flexcoders@yahoogroups.com on behalf of 
maxym.hryniv Sent: Mon 5/15/2006 3:29 AM To: 
flexcoders@yahoogroups.com Subject: [flexcoders] Re: Cairngorm 
microarchitecture. 2 instances of view with different data. 
 Thanx for reply Tim, but you didnt't understand my question. If 
i bind "the same value object (data) to more than one  view(component)" 
i'll have the same information in both views, but i  must have different 
information.  "Before you change the view state, you dispatch the 
getMessages event  (to return messages based on the user's role)" - 
It's called HARDCODE  and it's unacceptable.  And i have to 
display different information at the same time in  different instances 
of one view thats why your suggestion will not  work. However thank 
you. Btw i have different delegates for different states cause of server 
 side architecture. It's another one reason why it will not 
work.  Waiting for reply.  --- In 
flexcoders@yahoogroups.com, "Tim Hoff" TimHoff@ wrote: 
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, bu

RE: [flexcoders] Re: Cairngorm microarchitecture. 2 instances of view with different data.

2006-05-15 Thread Dimitrios Gianninas





I am one of the committee members :)

The cairngorm micro-architecture wasn't build to 
handlemultiple instances of the same view because in standard web apps, 
this is not required (usually you have one instance of a particular view). So 
this is the best way to accomplish this for now.

Of course, because of Flex and the fact that you can pop-up 
multiple instances of the same view, this might be something that we will have 
to review in the future.

Dimitrios 
Gianninas
RIADeveloper
Optimal 
Payments Inc.



From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On Behalf Of 
maxym.hrynivSent: Monday, May 15, 2006 9:32 AMTo: 
flexcoders@yahoogroups.comSubject: [flexcoders] Re: Cairngorm 
microarchitecture. 2 instances of view with different data.
Yeah i thought about that way, but it sounds like work-around and 
doesn't fit to cairngorm architecture. Maybe someone of cairngorm 
authors can describe clean and logical solution?--- In 
flexcoders@yahoogroups.com, "Dimitrios Gianninas" 
dimitrios.[EMAIL PROTECTED] wrote: I asked for 
screenshot because an image can help understand exactly what you are 
getting at. Actually I missed the word "instance" in your previous 
post... so you can have X instances of the same view that can 
appear, each with its own set of data. That's similar to the a user 
admin app I created (screenshot below).  In these cases, 
you can't use data binding, you will have to pass the view helper 
instance to the command object, so it can use the view helper instance 
to update the appropriate view. This is the way I did it and it 
works, there might be a better way, others can comment.  
Does that help?
 Dimitrios Gianninas RIA Developer Optimal Payments 
Inc.    
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] 
On Behalf Of maxym.hryniv Sent: Monday, May 15, 2006 8:58 
AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: 
Cairngorm microarchitecture. 2 instances of view with different 
data.   Dimitrios, thank you for quick reply, but please 
don't post reply if  you are not in context. It's a question about 
architecture and i'm  wondering why you are asking for a screenshot? 
I'll try to clarify my  question I have 1. 2 
different set of delegates (different classes) 2. 2 different data 
instances (the same data class) 3. 2 instances of ONE view (the same 
class) that support 2 modes. I have to see in THE SAME TIME one instance 
of view with one set of  data (received by the first set of delegates - 
my guestbook messages)  and another with second set of data 
(received by the second set of  delegates - my friend guestbook 
messages). And probably i'll have a possibility to see 3 or X guestbooks 
in the  same screen (depends on UI team solution - i don't care about 
UI)  eachone with another set of data (different people 
guestbooks).  Waiting for reply.  --- In 
flexcoders@yahoogroups.com, "Dimitrios Gianninas" dimitrios. 
gianninas@ wrote:   Ok, maybe if you can provide 
some sample code or a screenshot of  what  these two views 
look like would help. Is it that the two views are  going  
to update the data in two different fashions?
Dimitrios Gianninas  RIA Developer  Optimal Payments 
Inc.  
From: 
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]com]  
On  Behalf Of maxym.hryniv  Sent: Monday, May 15, 2006 
8:04 AM  To: flexcoders@yahoogroups.com  Subject: 
[flexcoders] Re: Cairngorm microarchitecture. 2 instances  of 
 view with different data.  True, 
You don't understand my problem.  I have  1. 2 different 
set of delegates (different classes)  2. 2 different data instances 
(the same data class)  3. 2 instances of ONE view that support 2 
modes.  I have to see in THE SAME TIME one instance of view with one 
set of   data and another with second set of data.  
  Waiting for reply.--- In 
flexcoders@yahoogroups.com, "Dimitrios Gianninas" dimitrios. 
 gianninas@ wrote:   
 Hi,  Unless I don't fully understand 
your problem, the solution is   simple. You don't need to 
create 2 different models for the same   data. You create the 
variable to hold your data on the ModelLocator   (ex.: 
ModelLocator.messages) and then bind this variables to  controls 
  on our 2 views. First part done. 
 Now, when the owner logs in, you will get his messages and assign 
  them to this variable, OR when a visitor logs in, you do exactly 
the   same thing. You don't need 2 FrontControllers, always use 
one.  I think your question has more to do 
with controlling what a  visitor   can do as opposed to a 
owner, which has more power. Yes?  Dimitrios 
Gianninas  -Original 
Message-   From: flexcoders@yahoogroups.com on behalf of 
maxym.hryniv   Sent: Mon 5/15/2006 3:29 AM   To: 
flexcoders@yahoogroups.com   Subject: [flexcoders] Re: Cairngorm 
microarchitecture. 2 instances   of view with different 
data.   

RE: [flexcoders] Re: Cairngorm microarchitecture. 2 instances of view with different data.

2006-05-15 Thread Steven Webster



If I'm understanding this thread correctly, you have a component
MyView.mxml that renders some data, we'll call it myData. You want to
have multiple instances of MyView.mxml that render different instances
of myData - eg myData1, myData2, myData3, etc.

So I'm not sure why you can't manage:

view:MyView instanceSpecificData={ ModelLocator.getInstance().myData1
} /
view:MyView instanceSpecificData={ ModelLocator.getInstance().myData2
} /
view:MyView instanceSpecificData={ ModelLocator.getInstance().myData3
} /

Cairngorm as an architecture is not trying to address how you structure
your view - we're leaving the developer complete flexibility to
implement the view however they choose. What you are citing as a
restriction, is one of the degrees of freedom we are offering.

I wouldn't be using ViewHelpers here at all, I'd be using the
ModelLocator at an application level, holding data that different views
(whether they're multiple instances of the same view, or different views
altogether) are able to bind to and display.

Steven

--
Steven Webster
Practice Director (Rich Internet Applications)
Adobe Consulting
Westpoint, 4 Redheughs Rigg, South Gyle, Edinburgh, EH12 9DQ, UK
p: +44 (0) 131 338 6108
m: +44 (0) 7917 428 947 
[EMAIL PROTECTED] 

 

 -Original Message-
 From: flexcoders@yahoogroups.com 
 [mailto:[EMAIL PROTECTED] On Behalf Of maxym.hryniv
 Sent: 15 May 2006 15:47
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Re: Cairngorm microarchitecture. 2 
 instances of view with different data.






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



  Visit your group "flexcoders" on the web.
  To unsubscribe from this group, send an email to:[EMAIL PROTECTED]
  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  











RE: [flexcoders] Re: Cairngorm microarchitecture. 2 instances of view with different data.

2006-05-15 Thread Dimitrios Gianninas





Actually come to think of it, in the command, once the data 
comes back from the server, it can create the view (if its a pop-up window like 
in my case) and pass it the data. Don't know why I didn't think of this 4 
months ago, but hey, we learn as we go along and this would be even cleaner. I'm 
going to change it next time I get the chance.

Dimitrios 
Gianninas
RIADeveloper
Optimal 
Payments Inc.



From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On Behalf Of Tim HoffSent: 
Monday, May 15, 2006 11:56 AMTo: 
flexcoders@yahoogroups.comSubject: [flexcoders] Re: Cairngorm 
microarchitecture. 2 instances of view with different data.
Communication is often difficult to achieve when cultural and 
language differences exist. I must applaud Dimitrios for his 
restraint. If I understand you correctly, you need to be able 
to show multiple instances of the same screen, with different data, at the 
same time. If that is true, you can still use a single VO (cast to an 
ArrayCollection) for all of the data and use a different filterFunction, 
for each instance of the screen. Since the screen is the same, I'm 
guessing that you are using a custom component and are creating a new 
instance for each new version of the screen. However, if you are only 
viewing one version of the screen at a time (view states), my original 
suggestion works. You just have to refill the VO, with new data, each 
time the view state changes. As far as your comment that I am 
suggesting that you HARDCODE event names, that's how Cairngorm defines that 
part of your application's structure. The names of your events and 
commands are hard coded in the FrontController. Unless your 
application is creating dynamic AS files, on-the-fly, I don't see a way 
around this. As far as the delegates are concerned it's almost 
impossible to suggest anything without knowing the server-side architecture 
and how you are retrieving data. It sounds like you have a pretty 
complex application, good luck working-out the details.Not Waiting 
for Reply,Tim Hoff--- In flexcoders@yahoogroups.com, 
"maxym.hryniv" [EMAIL PROTECTED] wrote: Dimitrios, thank you for 
quick reply, but please don't post reply if  you are not in context. 
It's a question about architecture and i'm  wondering why you are asking 
for a screenshot? I'll try to clarify my  question I 
have 1. 2 different set of delegates (different classes) 2. 2 
different data instances (the same data class) 3. 2 instances of ONE 
view (the same class) that support 2 modes. I have to see in THE SAME 
TIME one instance of view with one set of  data (received by the 
first set of delegates - my guestbook messages)  and another with 
second set of data (received by the second set of  delegates - my friend 
guestbook messages). And probably i'll have a possibility to see 3 or X 
guestbooks in the  same screen (depends on UI team solution - i 
don't care about UI)  eachone with another set of data (different people 
guestbooks).  Waiting for reply.  --- In 
flexcoders@yahoogroups.com, "Dimitrios Gianninas" dimitrios. 
gianninas@ wrote:   Ok, maybe if you can provide 
some sample code or a screenshot of  what  these two views 
look like would help. Is it that the two views are  going 
 to update the data in two different fashions?   
 Dimitrios Gianninas  RIA Developer  Optimal 
Payments Inc.  
From: 
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]  
On  Behalf Of maxym.hryniv  Sent: Monday, May 15, 2006 
8:04 AM  To: flexcoders@yahoogroups.com  Subject: 
[flexcoders] Re: Cairngorm microarchitecture. 2 instances  
of  view with different data. 
 True, You don't understand my problem.  I have  1. 
2 different set of delegates (different classes)  2. 2 different 
data instances (the same data class)  3. 2 instances of ONE view 
that support 2 modes.  I have to see in THE SAME TIME one instance 
of view with one set of   data and another with second set of 
data.Waiting for reply.
--- In flexcoders@yahoogroups.com, "Dimitrios Gianninas" 
dimitrios.  gianninas@ wrote:   
 Hi,  Unless I 
don't fully understand your problem, the solution is   simple. 
You don't need to create 2 different models for the same   data. 
You create the variable to hold your data on the ModelLocator   
(ex.: ModelLocator.messages) and then bind this variables to  controls 
  on our 2 views. First part done. 
 Now, when the owner logs in, you will get his messages and assign 
  them to this variable, OR when a visitor logs in, you do exactly 
the   same thing. You don't need 2 FrontControllers, always use 
one.  I think your question has more to do 
with controlling what a  visitor   can do as opposed to a 
owner, which has more power. Yes?  Dimitrios 
Gianninas  -Original 
Message-   From: flexcoders@yahoogroups.com on behalf of 
maxym.hryniv   Sent: Mon 5/15/2006 3:29 AM   To: 
flexcoders@yahoogroups.