RE: [flexcoders] Cairngorm 0.99 ViewHelper problem

2005-05-24 Thread Alistair McLeod
Hi Stephen,

A few people have asked a similar question to yours and we're still thinking
about the best solution. Here's one way

If you create the ViewHelper yourself, as in the example you gave, the
initialized() method will not be called - the Flex Framework calls that
method at component instantiation if it implements the MXMLObject interface
and is instantiated via MXML. You could try:

mx:Script
  ![CDATA[
  var viewHelper : ViewHelper = ViewHelperBuilder(this);
viewHelper.initialized( this, myViewHelperId );
  ]]
/mx:Script

This should mimic what the Flex Framework does, but I don't really like it
as a solution as it exposes the innards of the base class.

One alternative would be to change the Cairngorm framework itself. With the
ModelLocator strategy in place, the ViewLocator pattern is often not needed
at all, in which case you could remove the ViewLocator registration from the
ViewHelper base class - in that case, both instances of the view helper can
have the same id.

Another would be to change ViewHelper base class to register with the
ViewLocator not with the id alone, but with a fully qualified id. ie. Walk
up the component's parent heirarchy, and build up an id. eg. rather than
having an id of myViewHelperId, it would be
appView.componentView1.myViewHelperId. 

Of course, both of these alternatives are producing a compile time
definition of the id, not run time, and the latter is brittle in that
changes to your component heirarchy will change the id, which forces changes
elsewhere in your code if you're attempting to retrieve that view helper via
the ViewLocator.

We'll continue to give this thought.

Cheers,

Ali


--
Alistair McLeod
Development Director
iteration::two
[EMAIL PROTECTED]
 
Office:  +44 (0)131 338 6108
 
This e-mail and any associated attachments transmitted with it may contain
confidential information and must not be copied, or disclosed, or used by
anyone other than the intended recipient(s). If you are not the intended
recipient(s) please destroy this e-mail, and any copies of it, immediately.
 
Please also note that while software systems have been used to try to ensure
that this e-mail has been swept for viruses, iteration::two do not accept
responsibility for any damage or loss caused in respect of any viruses
transmitted by the e-mail. Please ensure your own checks are carried out
before any attachments are opened.
 

-Original Message-
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Stephen Inzer
Sent: 23 May 2005 16:26
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Cairngorm 0.99 ViewHelper problem

In the 0.95 version of Cairngorm the ViewHelpers were identified by their
name attribute. I could initialize the name attribute with a call to a
method. But in the 0.99 version the name attribute has gone away, and the
ViewHelper is identied by the id attribute. The id attribute cannot be
initailized at run time, it must be evaluated a compile time.

In the application I am developing I have a view that has a ViewHelper. The
view is used many times As a result I need to have many ViewHelpers. The
Views and ViewHelpers are created at runtime so I cannot hard code the ids
for these objects. Each ViewHelper must have a unique name, but since I
cannot call a method when assigning the id attribute I cannot do this. 

Will this work:

mx:Script
  ![CDATA[
  var viewHelper : ViewHelper = ViewHelperBuilder(this);
  ]]
/mx:Script

This allows me to set the id without a compiler error, but will the
initialized( document: Object, id: String) method be called with the the
correct object?


Stephen Inzer





 
Yahoo! Groups Links



 



 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




[flexcoders] Cairngorm 0.99 ViewHelper problem

2005-05-23 Thread Stephen Inzer
In the 0.95 version of Cairngorm the ViewHelpers were identified by
their name attribute. I could initialize the name attribute with a
call to a method. But in the 0.99 version the name attribute has gone
away, and the ViewHelper is identied by the id attribute. The id
attribute cannot be initailized at run time, it must be evaluated a
compile time.

In the application I am developing I have a view that has a
ViewHelper. The view is used many times As a result I need to have
many ViewHelpers. The Views and ViewHelpers are created at runtime so
I cannot hard code the ids for these objects. Each ViewHelper must
have a unique name, but since I cannot call a method when assigning
the id attribute I cannot do this. 

Will this work:

mx:Script
  ![CDATA[
  var viewHelper : ViewHelper = ViewHelperBuilder(this);
  ]]
/mx:Script

This allows me to set the id without a compiler error, but will the
initialized( document: Object, id: String) method be called with the
the correct object?


Stephen Inzer





 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/