tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/564-linking-a-skinclass-to-a-viewRobotlegs: Discussion 2018-10-18T16:35:27Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/74913802011-05-27T09:21:56Z2011-05-27T09:21:56ZLinking a skinclass to a view?<div><p>Hi Samuel, there are a few threads on this already, so it would
be worth searching around in the forum as there are some quite long
discussions.</p>
<p>Some options are:</p>
<p>1) Mediate the view and use the mediator to pass the skin to the
view.<br>
2) Use a factory to create your views and set the skin property
there.<br>
3) Use a double-decoupled static reference for skins (ie, a static
reference to a skin holder which is then injected with the correct
concrete version to use).</p>
<p>I prefer 2 or 3 - I don't think it's necessary to involve the
framework in skinning unless the skin is loaded at runtime based on
data.</p>
<p>But it's definitely work checking out the conversations around
view config that have happened before.</p>
<p>Main rule of robotlegs is that most of the time you should "Just
code normal". So I'd handle this as if you weren't using Robotlegs
at all.</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/74913802011-05-27T11:28:21Z2011-05-27T11:28:21ZLinking a skinclass to a view?<div><p>I am sorry, i couldn't find annything while searching, now i
have a little more to go by. I'm not so well read in using factorys
but it looks like the way to go. the main problem is i allready
have a mediator for this view and the parent view that is adding it
inside my main library. i would like not having to assign multiple
mediators to every project using the views.</p>
<p>I found this <a href=
"http://knowledge.robotlegs.org/discussions/questions/22-item-renderers-injection-and-event-handling">
this</a> searching for factory.</p>
<p>I will give this a bit of reading, thanks!</p></div>eldamartag:robotlegs.tenderapp.com,2009-10-18:Comment/74913802011-05-27T12:00:50Z2011-05-27T12:04:58ZLinking a skinclass to a view?<div><p>A bit of update, sorry for spaming.. i have tried to make a
factory for the skin PageViewSkinFactor</p>
<pre>
<code> public class PageViewSkinFactory implements IFactory
{
public function newInstance():*
{
var skin:PageViewSkin = new PageViewSkin; // pageview mxml skin
return skin;
}
}</code>
</pre>
<p>And in the view i added this:</p>
<pre>
<code>[Inject(name="PageViewSkinFactory")]
[Bindable]
public var pageViewSkinFactory:IFactory;
public function PageView()
{
super();
this.setStyle('skinClass',pageViewSkinFactory);
}</code>
</pre>
<p>And in project context:</p>
<pre>
<code>injector.mapSingletonOf(IFactory,PageViewSkinFactory,'PageViewSkinFactory');</code>
</pre>
<p>But i get an error saying that the view cannot find anny skin?
I'm not really sure on how to work with this factory business . Any
pointers to the previous discussions you were talking about? I
can't seem to find anything when searching.</p></div>eldamartag:robotlegs.tenderapp.com,2009-10-18:Comment/74913802011-05-27T12:21:34Z2011-05-27T12:21:34ZLinking a skinclass to a view?<div><p>Hi Samuel, your view won't, by default, be injected into.</p>
<p>So - I'm not sure that adding the [Inject] tag to the view is
going to help. I was suggesting using a "Just-code-normal!"
approach - so using a normal factory to construct your views. I
didn't necessarily mean implementing IFactory.</p>
<p>Sorry if I've confused you.</p>
<p>What I mean is that when the parent view adds this view, it
could use a factory to create it.</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/74913802011-05-27T12:39:18Z2011-05-27T12:39:18ZLinking a skinclass to a view?<div><p>I'm not sure i follow, the parent view is inside the library as
well so how would that make the skin dynamic per project using the
library. I can't access parent view function where the view is
added from the projects. Not sure what you mean by factory? Sorry
if I'm a bit novice to this.</p>
<p>Wouldn't it be nice to be able to assign skins in the context
like mediatorMap.mapView(PageView,PageViewMediator,PageViewSkin);
?</p></div>eldamartag:robotlegs.tenderapp.com,2009-10-18:Comment/74913802011-06-08T10:05:23Z2011-06-08T10:05:23ZLinking a skinclass to a view?<div><p>That would give the mediatorMap mixed responsibilities - but
easier skinning is definitely on our radar for Robotlegs 2 - no
idea yet what the solution will look like, but yes, it would be
great to have a more intuitive method for achieving it.</p>
<p>But - seriously - the mediatorMap is very easy to understand
inside, and very easy to extend, so you should think about making
an alternative one that has the Skin functionality you're riffing
on there.</p>
<p>I'd wade in and help happily - but I don't use flex so I don't
know enough about how skins could be set... but if you want to
share your view / skin code with me I'm thinking we could put it
together quite quickly.</p>
<p>Stray</p></div>Straytag:robotlegs.tenderapp.com,2009-10-18:Comment/74913802011-06-08T11:19:29Z2011-06-08T11:19:29ZLinking a skinclass to a view?<div><p>I haven't thought about checking inside the mediatorMap, i might
be able to achieve something like that, help would be very
appreciated.<br>
I have a quite tight deadline right now so i wont be able to dig
into this quite yet but it's definitely something that would make
the project I'm working on allot easier.</p></div>eldamartag:robotlegs.tenderapp.com,2009-10-18:Comment/74913802011-06-08T11:55:03Z2011-06-08T11:55:03ZLinking a skinclass to a view?<div><p>Great - well, give me a shout when you're ready to tinker, and I
can help with it.</p></div>Stray