Re: [flexcoders] Re: Switching Item Renderers

2010-09-02 Thread Johannes Nel
it does.

Another approach which i have taken (and I find neater, faster and more
memory efficient with less emphasis on binding) is the concept of one 1
itemrenderer and several layouts which you can swop out depending on the
model. This allows you to control shared resources (meaning i create the
least number of fields i have to across several different itemrenderers) and
get extremely intelligent about a lot more with less overhead.
but hey, its personal flavour, spice of life stuff, ya know.

On Wed, Sep 1, 2010 at 8:14 PM, Wesley Acheson wrote:

>
>
> True. I'm not sure if that recycles well though?
>
> On Wed, Sep 1, 2010 at 3:01 PM, Johannes Nel wrote:
>
>>
>>
>> set your renderer to an IFactory. this is a pretty standard way of doing
>> things.
>>
>>
>> On Wed, Sep 1, 2010 at 1:19 PM, valdhor wrote:
>>
>>>
>>>
>>> The only computation I see is determining which component to use. With
>>> your original idea you would still need the same computation to figure out
>>> which (sub) item renderer to use. I still think you are trying to hide the
>>> woods using more trees.
>>>
>>>
>>> --- In flexcoders@yahoogroups.com , Wesley
>>> Acheson  wrote:
>>> >
>>> > Yeah thats the way I've done it previously. I thought that this way
>>> would
>>> > cut out on some additional computation.
>>> >
>>> >
>>> >
>>> > On Tue, Aug 31, 2010 at 6:04 PM, valdhor wrote:
>>>
>>> >
>>> > >
>>> > >
>>> > > That seems overly complicated to me. What I would try is create two
>>> custom
>>> > > components then instantiate the appropriate one based on the data and
>>> add it
>>> > > in the updateDisplayList method.
>>> > >
>>> > >
>>> > > --- In flexcoders@yahoogroups.com 
>>> > > >> 40yahoogroups.com>, Wesley
>>>
>>> > > Acheson  wrote:
>>> > > >
>>> > > > Since nobody has replied I'm continueing to try this. I currently
>>> think I
>>> > > > may need to override all methods in UI component.
>>> > > >
>>> > > >
>>> > > > Is it clear what I'm trying to do?
>>> > > >
>>> > > > Is this the wrong way of doing it?
>>> > > >
>>> > > > I think its probably lighter than wrapping to components in a fully
>>> > > fledged
>>> > > > UI component?
>>> > > > *
>>> > > > Some Thoughts*
>>> > > >
>>> > > > Also a comment on ListItemRenderer, theres an awful lot of methods
>>> that
>>> > > need
>>> > > > to be implemented to make this work. I doubt all of them are used
>>> in a
>>> > > List
>>> > > > Senario. Even implementing them all theres still a dependency on
>>> > > > DisplayObject (who's methods seem to be implemented). It does feel
>>> to me
>>> > > > like the architecture seems a bit off. I mean if all of those
>>> methods are
>>> > > > implemented why is there still a dependency on DisplayObject.
>>> > > >
>>> > > > Its not just enough to implement IListRenderer which seems to
>>> defeat the
>>> > > > purpose of an interace
>>> > > >
>>> > > > On Wed, Aug 18, 2010 at 11:42 PM, Wesley Acheson
>>> > > > wrote:
>>> > >
>>> > > >
>>> > > > > *Disclaimer:* This is a cross post with Stack Overflow. I know at
>>> least
>>> > > > > one person on this list saw it there.
>>> > > > >
>>> http://stackoverflow.com/questions/3507313/flex-switch-item-renderer
>>> > > > >
>>> > > > > Hi
>>> > > > >
>>> > > > > I was wondering if anyone had any luck with the following senario
>>> in
>>> > > flex.
>>> > > > >
>>> > > > > I'd like to be able to have a custom item renderer which
>>> delegates to
>>> > > > > another renderer inside.
>>> > > > >
>>> > > > > The reason for this would be in a datagrid for instance
>>> displaying a
>>> > > > > checkbox if the dataprovider for the row had a boolean value.
>>> Using the
>>> > > > > default item renderer when the value was a non boolean.
>>> > > > >
>>> > > > > Basically I was hoping to use a proxy object (though not
>>> necessarily
>>> > > the
>>> > > > > proxy class) so that I could a renderer which delegated all of
>>> its
>>> > > > > responsibilties to a sub renderer.
>>> > > > >
>>> > > > > Hard to explain.
>>> > > > >
>>> > > > > *Edit 1*
>>> > > > >
>>> > > > > I think the following gives a clearer idea of what I had in mind.
>>> This
>>> > > is
>>> > > > > only knocked up quickly for the purpose of showing the idea.
>>> > > > >
>>> > > > > *SwitchingRenderer.as*
>>> > > > >
>>> > > > > package com.example
>>> > > > > {
>>> > > > > import mx.controls.CheckBox;
>>> > > > >
>>> > > > > import mx.controls.dataGridClasses.DataGridItemRenderer;
>>> > > > >
>>> > > > > import mx.controls.listClasses.BaseListData;
>>> > > > >
>>> > > > > import mx.controls.listClasses.IDropInListItemRenderer;
>>> > > > >
>>> > > > > import mx.core.IDataRenderer;
>>> > > > >
>>> > > > > import mx.core.UIComponent;
>>> > > > >
>>> > > > > public class SwitchingRenderer extends UIComponent implements
>>> > > IDataRenderer, IDropInListItemRenderer
>>> > > > >
>>> > > > > {
>>> > > > > private var checkboxRenderer:CheckBox;
>>> > > > >
>>> > > > > private var defaultRenderer:DataGridItemRenderer;
>>> > > > >
>>> > > > > private var curr

Re: [flexcoders] Re: Switching Item Renderers

2010-09-01 Thread Wesley Acheson
True. I'm not sure if that recycles well though?

On Wed, Sep 1, 2010 at 3:01 PM, Johannes Nel  wrote:

>
>
> set your renderer to an IFactory. this is a pretty standard way of doing
> things.
>
>
> On Wed, Sep 1, 2010 at 1:19 PM, valdhor wrote:
>
>>
>>
>> The only computation I see is determining which component to use. With
>> your original idea you would still need the same computation to figure out
>> which (sub) item renderer to use. I still think you are trying to hide the
>> woods using more trees.
>>
>>
>> --- In flexcoders@yahoogroups.com , Wesley
>> Acheson  wrote:
>> >
>> > Yeah thats the way I've done it previously. I thought that this way
>> would
>> > cut out on some additional computation.
>> >
>> >
>> >
>> > On Tue, Aug 31, 2010 at 6:04 PM, valdhor wrote:
>>
>> >
>> > >
>> > >
>> > > That seems overly complicated to me. What I would try is create two
>> custom
>> > > components then instantiate the appropriate one based on the data and
>> add it
>> > > in the updateDisplayList method.
>> > >
>> > >
>> > > --- In flexcoders@yahoogroups.com 
>> > > > 40yahoogroups.com>, Wesley
>>
>> > > Acheson  wrote:
>> > > >
>> > > > Since nobody has replied I'm continueing to try this. I currently
>> think I
>> > > > may need to override all methods in UI component.
>> > > >
>> > > >
>> > > > Is it clear what I'm trying to do?
>> > > >
>> > > > Is this the wrong way of doing it?
>> > > >
>> > > > I think its probably lighter than wrapping to components in a fully
>> > > fledged
>> > > > UI component?
>> > > > *
>> > > > Some Thoughts*
>> > > >
>> > > > Also a comment on ListItemRenderer, theres an awful lot of methods
>> that
>> > > need
>> > > > to be implemented to make this work. I doubt all of them are used in
>> a
>> > > List
>> > > > Senario. Even implementing them all theres still a dependency on
>> > > > DisplayObject (who's methods seem to be implemented). It does feel
>> to me
>> > > > like the architecture seems a bit off. I mean if all of those
>> methods are
>> > > > implemented why is there still a dependency on DisplayObject.
>> > > >
>> > > > Its not just enough to implement IListRenderer which seems to defeat
>> the
>> > > > purpose of an interace
>> > > >
>> > > > On Wed, Aug 18, 2010 at 11:42 PM, Wesley Acheson
>> > > > wrote:
>> > >
>> > > >
>> > > > > *Disclaimer:* This is a cross post with Stack Overflow. I know at
>> least
>> > > > > one person on this list saw it there.
>> > > > >
>> http://stackoverflow.com/questions/3507313/flex-switch-item-renderer
>> > > > >
>> > > > > Hi
>> > > > >
>> > > > > I was wondering if anyone had any luck with the following senario
>> in
>> > > flex.
>> > > > >
>> > > > > I'd like to be able to have a custom item renderer which delegates
>> to
>> > > > > another renderer inside.
>> > > > >
>> > > > > The reason for this would be in a datagrid for instance displaying
>> a
>> > > > > checkbox if the dataprovider for the row had a boolean value.
>> Using the
>> > > > > default item renderer when the value was a non boolean.
>> > > > >
>> > > > > Basically I was hoping to use a proxy object (though not
>> necessarily
>> > > the
>> > > > > proxy class) so that I could a renderer which delegated all of its
>> > > > > responsibilties to a sub renderer.
>> > > > >
>> > > > > Hard to explain.
>> > > > >
>> > > > > *Edit 1*
>> > > > >
>> > > > > I think the following gives a clearer idea of what I had in mind.
>> This
>> > > is
>> > > > > only knocked up quickly for the purpose of showing the idea.
>> > > > >
>> > > > > *SwitchingRenderer.as*
>> > > > >
>> > > > > package com.example
>> > > > > {
>> > > > > import mx.controls.CheckBox;
>> > > > >
>> > > > > import mx.controls.dataGridClasses.DataGridItemRenderer;
>> > > > >
>> > > > > import mx.controls.listClasses.BaseListData;
>> > > > >
>> > > > > import mx.controls.listClasses.IDropInListItemRenderer;
>> > > > >
>> > > > > import mx.core.IDataRenderer;
>> > > > >
>> > > > > import mx.core.UIComponent;
>> > > > >
>> > > > > public class SwitchingRenderer extends UIComponent implements
>> > > IDataRenderer, IDropInListItemRenderer
>> > > > >
>> > > > > {
>> > > > > private var checkboxRenderer:CheckBox;
>> > > > >
>> > > > > private var defaultRenderer:DataGridItemRenderer;
>> > > > >
>> > > > > private var currentRenderer:IDataRenderer;
>> > > > >
>> > > > > public function SwitchingRenderer()
>> > > > >
>> > > > > {
>> > > > > this.checkboxRenderer = new CheckBox();
>> > > > >
>> > > > > this.defaultRenderer = new DataGridItemRenderer();
>> > > > >
>> > > > > this.currentRenderer = defaultRenderer();
>> > > > >
>> > > > > super();
>> > > > > }
>> > > > >
>> > > > > public function get data():Object
>> > > > >
>> > > > > {
>> > > > > //If the data for this cell is a boolean
>> > > > > // currentRender = checkBoxRenderer
>> > > > >
>> > > > > // otherwise
>> > > > > // currentRenderer = defaultRenderer
>> > > > > }
>> > > > >
>> > > > > public function set data(value:Object):void
>> > > > >
>> > > > > {
>> > 

Re: [flexcoders] Re: Switching Item Renderers

2010-09-01 Thread Johannes Nel
set your renderer to an IFactory. this is a pretty standard way of doing
things.

On Wed, Sep 1, 2010 at 1:19 PM, valdhor  wrote:

>
>
> The only computation I see is determining which component to use. With your
> original idea you would still need the same computation to figure out which
> (sub) item renderer to use. I still think you are trying to hide the woods
> using more trees.
>
>
> --- In flexcoders@yahoogroups.com , Wesley
> Acheson  wrote:
> >
> > Yeah thats the way I've done it previously. I thought that this way would
> > cut out on some additional computation.
> >
> >
> >
> > On Tue, Aug 31, 2010 at 6:04 PM, valdhor wrote:
>
> >
> > >
> > >
> > > That seems overly complicated to me. What I would try is create two
> custom
> > > components then instantiate the appropriate one based on the data and
> add it
> > > in the updateDisplayList method.
> > >
> > >
> > > --- In flexcoders@yahoogroups.com 
> > >  40yahoogroups.com>, Wesley
>
> > > Acheson  wrote:
> > > >
> > > > Since nobody has replied I'm continueing to try this. I currently
> think I
> > > > may need to override all methods in UI component.
> > > >
> > > >
> > > > Is it clear what I'm trying to do?
> > > >
> > > > Is this the wrong way of doing it?
> > > >
> > > > I think its probably lighter than wrapping to components in a fully
> > > fledged
> > > > UI component?
> > > > *
> > > > Some Thoughts*
> > > >
> > > > Also a comment on ListItemRenderer, theres an awful lot of methods
> that
> > > need
> > > > to be implemented to make this work. I doubt all of them are used in
> a
> > > List
> > > > Senario. Even implementing them all theres still a dependency on
> > > > DisplayObject (who's methods seem to be implemented). It does feel to
> me
> > > > like the architecture seems a bit off. I mean if all of those methods
> are
> > > > implemented why is there still a dependency on DisplayObject.
> > > >
> > > > Its not just enough to implement IListRenderer which seems to defeat
> the
> > > > purpose of an interace
> > > >
> > > > On Wed, Aug 18, 2010 at 11:42 PM, Wesley Acheson
> > > > wrote:
> > >
> > > >
> > > > > *Disclaimer:* This is a cross post with Stack Overflow. I know at
> least
> > > > > one person on this list saw it there.
> > > > >
> http://stackoverflow.com/questions/3507313/flex-switch-item-renderer
> > > > >
> > > > > Hi
> > > > >
> > > > > I was wondering if anyone had any luck with the following senario
> in
> > > flex.
> > > > >
> > > > > I'd like to be able to have a custom item renderer which delegates
> to
> > > > > another renderer inside.
> > > > >
> > > > > The reason for this would be in a datagrid for instance displaying
> a
> > > > > checkbox if the dataprovider for the row had a boolean value. Using
> the
> > > > > default item renderer when the value was a non boolean.
> > > > >
> > > > > Basically I was hoping to use a proxy object (though not
> necessarily
> > > the
> > > > > proxy class) so that I could a renderer which delegated all of its
> > > > > responsibilties to a sub renderer.
> > > > >
> > > > > Hard to explain.
> > > > >
> > > > > *Edit 1*
> > > > >
> > > > > I think the following gives a clearer idea of what I had in mind.
> This
> > > is
> > > > > only knocked up quickly for the purpose of showing the idea.
> > > > >
> > > > > *SwitchingRenderer.as*
> > > > >
> > > > > package com.example
> > > > > {
> > > > > import mx.controls.CheckBox;
> > > > >
> > > > > import mx.controls.dataGridClasses.DataGridItemRenderer;
> > > > >
> > > > > import mx.controls.listClasses.BaseListData;
> > > > >
> > > > > import mx.controls.listClasses.IDropInListItemRenderer;
> > > > >
> > > > > import mx.core.IDataRenderer;
> > > > >
> > > > > import mx.core.UIComponent;
> > > > >
> > > > > public class SwitchingRenderer extends UIComponent implements
> > > IDataRenderer, IDropInListItemRenderer
> > > > >
> > > > > {
> > > > > private var checkboxRenderer:CheckBox;
> > > > >
> > > > > private var defaultRenderer:DataGridItemRenderer;
> > > > >
> > > > > private var currentRenderer:IDataRenderer;
> > > > >
> > > > > public function SwitchingRenderer()
> > > > >
> > > > > {
> > > > > this.checkboxRenderer = new CheckBox();
> > > > >
> > > > > this.defaultRenderer = new DataGridItemRenderer();
> > > > >
> > > > > this.currentRenderer = defaultRenderer();
> > > > >
> > > > > super();
> > > > > }
> > > > >
> > > > > public function get data():Object
> > > > >
> > > > > {
> > > > > //If the data for this cell is a boolean
> > > > > // currentRender = checkBoxRenderer
> > > > >
> > > > > // otherwise
> > > > > // currentRenderer = defaultRenderer
> > > > > }
> > > > >
> > > > > public function set data(value:Object):void
> > > > >
> > > > > {
> > > > > currentRenderer.data = value;
> > > > >
> > > > > }
> > > > >
> > > > > public function get listData():BaseListData
> > > > >
> > > > > {
> > > > > return currentRenderer.listData;
> > > > >
> > > > > }
> > > > >
> > > > > public function set listData(value:BaseListData):v

[flexcoders] Re: Switching Item Renderers

2010-09-01 Thread valdhor
The only computation I see is determining which component to use. With your 
original idea you would still need the same computation to figure out which 
(sub) item renderer to use. I still think you are trying to hide the woods 
using more trees.

--- In flexcoders@yahoogroups.com, Wesley Acheson  wrote:
>
> Yeah thats the way I've done it previously. I thought that this way would
> cut out on some additional computation.
> 
> 
> 
> On Tue, Aug 31, 2010 at 6:04 PM, valdhor wrote:
> 
> >
> >
> > That seems overly complicated to me. What I would try is create two custom
> > components then instantiate the appropriate one based on the data and add it
> > in the updateDisplayList method.
> >
> >
> > --- In flexcoders@yahoogroups.com , Wesley
> > Acheson  wrote:
> > >
> > > Since nobody has replied I'm continueing to try this. I currently think I
> > > may need to override all methods in UI component.
> > >
> > >
> > > Is it clear what I'm trying to do?
> > >
> > > Is this the wrong way of doing it?
> > >
> > > I think its probably lighter than wrapping to components in a fully
> > fledged
> > > UI component?
> > > *
> > > Some Thoughts*
> > >
> > > Also a comment on ListItemRenderer, theres an awful lot of methods that
> > need
> > > to be implemented to make this work. I doubt all of them are used in a
> > List
> > > Senario. Even implementing them all theres still a dependency on
> > > DisplayObject (who's methods seem to be implemented). It does feel to me
> > > like the architecture seems a bit off. I mean if all of those methods are
> > > implemented why is there still a dependency on DisplayObject.
> > >
> > > Its not just enough to implement IListRenderer which seems to defeat the
> > > purpose of an interace
> > >
> > > On Wed, Aug 18, 2010 at 11:42 PM, Wesley Acheson
> > > wrote:
> >
> > >
> > > > *Disclaimer:* This is a cross post with Stack Overflow. I know at least
> > > > one person on this list saw it there.
> > > > http://stackoverflow.com/questions/3507313/flex-switch-item-renderer
> > > >
> > > > Hi
> > > >
> > > > I was wondering if anyone had any luck with the following senario in
> > flex.
> > > >
> > > > I'd like to be able to have a custom item renderer which delegates to
> > > > another renderer inside.
> > > >
> > > > The reason for this would be in a datagrid for instance displaying a
> > > > checkbox if the dataprovider for the row had a boolean value. Using the
> > > > default item renderer when the value was a non boolean.
> > > >
> > > > Basically I was hoping to use a proxy object (though not necessarily
> > the
> > > > proxy class) so that I could a renderer which delegated all of its
> > > > responsibilties to a sub renderer.
> > > >
> > > > Hard to explain.
> > > >
> > > > *Edit 1*
> > > >
> > > > I think the following gives a clearer idea of what I had in mind. This
> > is
> > > > only knocked up quickly for the purpose of showing the idea.
> > > >
> > > > *SwitchingRenderer.as*
> > > >
> > > > package com.example
> > > > {
> > > > import mx.controls.CheckBox;
> > > >
> > > > import mx.controls.dataGridClasses.DataGridItemRenderer;
> > > >
> > > > import mx.controls.listClasses.BaseListData;
> > > >
> > > > import mx.controls.listClasses.IDropInListItemRenderer;
> > > >
> > > > import mx.core.IDataRenderer;
> > > >
> > > > import mx.core.UIComponent;
> > > >
> > > > public class SwitchingRenderer extends UIComponent implements
> > IDataRenderer, IDropInListItemRenderer
> > > >
> > > > {
> > > > private var checkboxRenderer:CheckBox;
> > > >
> > > > private var defaultRenderer:DataGridItemRenderer;
> > > >
> > > > private var currentRenderer:IDataRenderer;
> > > >
> > > > public function SwitchingRenderer()
> > > >
> > > > {
> > > > this.checkboxRenderer = new CheckBox();
> > > >
> > > > this.defaultRenderer = new DataGridItemRenderer();
> > > >
> > > > this.currentRenderer = defaultRenderer();
> > > >
> > > > super();
> > > > }
> > > >
> > > > public function get data():Object
> > > >
> > > > {
> > > > //If the data for this cell is a boolean
> > > > // currentRender = checkBoxRenderer
> > > >
> > > > // otherwise
> > > > // currentRenderer = defaultRenderer
> > > > }
> > > >
> > > > public function set data(value:Object):void
> > > >
> > > > {
> > > > currentRenderer.data = value;
> > > >
> > > > }
> > > >
> > > > public function get listData():BaseListData
> > > >
> > > > {
> > > > return currentRenderer.listData;
> > > >
> > > > }
> > > >
> > > > public function set listData(value:BaseListData):void
> > > >
> > > > {
> > > > currentRenderer.listData = value;
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > > }
> > > > }
> > > >
> > > >
> > > >
> > >
> >
> >  
> >
>




Re: [flexcoders] Re: Switching Item Renderers

2010-08-31 Thread Wesley Acheson
Yeah thats the way I've done it previously. I thought that this way would
cut out on some additional computation.



On Tue, Aug 31, 2010 at 6:04 PM, valdhor wrote:

>
>
> That seems overly complicated to me. What I would try is create two custom
> components then instantiate the appropriate one based on the data and add it
> in the updateDisplayList method.
>
>
> --- In flexcoders@yahoogroups.com , Wesley
> Acheson  wrote:
> >
> > Since nobody has replied I'm continueing to try this. I currently think I
> > may need to override all methods in UI component.
> >
> >
> > Is it clear what I'm trying to do?
> >
> > Is this the wrong way of doing it?
> >
> > I think its probably lighter than wrapping to components in a fully
> fledged
> > UI component?
> > *
> > Some Thoughts*
> >
> > Also a comment on ListItemRenderer, theres an awful lot of methods that
> need
> > to be implemented to make this work. I doubt all of them are used in a
> List
> > Senario. Even implementing them all theres still a dependency on
> > DisplayObject (who's methods seem to be implemented). It does feel to me
> > like the architecture seems a bit off. I mean if all of those methods are
> > implemented why is there still a dependency on DisplayObject.
> >
> > Its not just enough to implement IListRenderer which seems to defeat the
> > purpose of an interace
> >
> > On Wed, Aug 18, 2010 at 11:42 PM, Wesley Acheson
> > wrote:
>
> >
> > > *Disclaimer:* This is a cross post with Stack Overflow. I know at least
> > > one person on this list saw it there.
> > > http://stackoverflow.com/questions/3507313/flex-switch-item-renderer
> > >
> > > Hi
> > >
> > > I was wondering if anyone had any luck with the following senario in
> flex.
> > >
> > > I'd like to be able to have a custom item renderer which delegates to
> > > another renderer inside.
> > >
> > > The reason for this would be in a datagrid for instance displaying a
> > > checkbox if the dataprovider for the row had a boolean value. Using the
> > > default item renderer when the value was a non boolean.
> > >
> > > Basically I was hoping to use a proxy object (though not necessarily
> the
> > > proxy class) so that I could a renderer which delegated all of its
> > > responsibilties to a sub renderer.
> > >
> > > Hard to explain.
> > >
> > > *Edit 1*
> > >
> > > I think the following gives a clearer idea of what I had in mind. This
> is
> > > only knocked up quickly for the purpose of showing the idea.
> > >
> > > *SwitchingRenderer.as*
> > >
> > > package com.example
> > > {
> > > import mx.controls.CheckBox;
> > >
> > > import mx.controls.dataGridClasses.DataGridItemRenderer;
> > >
> > > import mx.controls.listClasses.BaseListData;
> > >
> > > import mx.controls.listClasses.IDropInListItemRenderer;
> > >
> > > import mx.core.IDataRenderer;
> > >
> > > import mx.core.UIComponent;
> > >
> > > public class SwitchingRenderer extends UIComponent implements
> IDataRenderer, IDropInListItemRenderer
> > >
> > > {
> > > private var checkboxRenderer:CheckBox;
> > >
> > > private var defaultRenderer:DataGridItemRenderer;
> > >
> > > private var currentRenderer:IDataRenderer;
> > >
> > > public function SwitchingRenderer()
> > >
> > > {
> > > this.checkboxRenderer = new CheckBox();
> > >
> > > this.defaultRenderer = new DataGridItemRenderer();
> > >
> > > this.currentRenderer = defaultRenderer();
> > >
> > > super();
> > > }
> > >
> > > public function get data():Object
> > >
> > > {
> > > //If the data for this cell is a boolean
> > > // currentRender = checkBoxRenderer
> > >
> > > // otherwise
> > > // currentRenderer = defaultRenderer
> > > }
> > >
> > > public function set data(value:Object):void
> > >
> > > {
> > > currentRenderer.data = value;
> > >
> > > }
> > >
> > > public function get listData():BaseListData
> > >
> > > {
> > > return currentRenderer.listData;
> > >
> > > }
> > >
> > > public function set listData(value:BaseListData):void
> > >
> > > {
> > > currentRenderer.listData = value;
> > >
> > > }
> > >
> > >
> > >
> > > }
> > > }
> > >
> > >
> > >
> >
>
>  
>


[flexcoders] Re: Switching Item Renderers

2010-08-31 Thread valdhor
That seems overly complicated to me. What I would try is create two custom 
components then instantiate the appropriate one based on the data and add it in 
the updateDisplayList method.

--- In flexcoders@yahoogroups.com, Wesley Acheson  wrote:
>
> Since nobody has replied I'm continueing to try this. I currently think I
> may need to override all methods in UI component.
> 
> 
> Is it clear what I'm trying to do?
> 
> Is this the wrong way of doing it?
> 
> I think its probably lighter than wrapping to components in a fully fledged
> UI component?
> *
> Some Thoughts*
> 
> Also a comment on ListItemRenderer, theres an awful lot of methods that need
> to be implemented to make this work.  I doubt all of them are used in a List
> Senario. Even implementing them all theres still a dependency on
> DisplayObject (who's methods seem to be implemented). It does feel to me
> like the architecture seems a bit off.  I mean if all of those methods are
> implemented why is there still a dependency on DisplayObject.
> 
> Its not just enough to implement IListRenderer which seems to defeat the
> purpose of an interace
> 
> On Wed, Aug 18, 2010 at 11:42 PM, Wesley Acheson
> wrote:
> 
> > *Disclaimer:* This is a cross post with Stack Overflow. I know at least
> > one person on this list saw it there.
> > http://stackoverflow.com/questions/3507313/flex-switch-item-renderer
> >
> > Hi
> >
> > I was wondering if anyone had any luck with the following senario in flex.
> >
> > I'd like to be able to have a custom item renderer which delegates to
> > another renderer inside.
> >
> > The reason for this would be in a datagrid for instance displaying a
> > checkbox if the dataprovider for the row had a boolean value. Using the
> > default item renderer when the value was a non boolean.
> >
> > Basically I was hoping to use a proxy object (though not necessarily the
> > proxy class) so that I could a renderer which delegated all of its
> > responsibilties to a sub renderer.
> >
> > Hard to explain.
> >
> > *Edit 1*
> >
> > I think the following gives a clearer idea of what I had in mind. This is
> > only knocked up quickly for the purpose of showing the idea.
> >
> > *SwitchingRenderer.as*
> >
> > package com.example
> > {
> > import mx.controls.CheckBox;
> >
> > import mx.controls.dataGridClasses.DataGridItemRenderer;
> >
> > import mx.controls.listClasses.BaseListData;
> >
> > import mx.controls.listClasses.IDropInListItemRenderer;
> >
> > import mx.core.IDataRenderer;
> >
> > import mx.core.UIComponent;
> >
> > public class SwitchingRenderer extends UIComponent implements 
> > IDataRenderer, IDropInListItemRenderer
> >
> > {
> > private var checkboxRenderer:CheckBox;
> >
> > private var defaultRenderer:DataGridItemRenderer;
> >
> > private var currentRenderer:IDataRenderer;
> >
> > public function SwitchingRenderer()
> >
> > {
> > this.checkboxRenderer = new CheckBox();
> >
> > this.defaultRenderer = new DataGridItemRenderer();
> >
> > this.currentRenderer = defaultRenderer();
> >
> > super();
> > }
> >
> > public function get data():Object
> >
> > {
> > //If the data for this cell is a boolean
> > //  currentRender = checkBoxRenderer
> >
> > // otherwise
> > //  currentRenderer = defaultRenderer
> > }
> >
> > public function set data(value:Object):void
> >
> > {
> > currentRenderer.data = value;
> >
> > }
> >
> > public function get listData():BaseListData
> >
> > {
> > return currentRenderer.listData;
> >
> > }
> >
> > public function set listData(value:BaseListData):void
> >
> > {
> > currentRenderer.listData = value;
> >
> > }
> >
> >
> >
> > }
> > }
> >
> >
> >
>




[flexcoders] Re: Switching Item Renderers

2010-08-19 Thread Wesley Acheson
Since nobody has replied I'm continueing to try this. I currently think I
may need to override all methods in UI component.


Is it clear what I'm trying to do?

Is this the wrong way of doing it?

I think its probably lighter than wrapping to components in a fully fledged
UI component?
*
Some Thoughts*

Also a comment on ListItemRenderer, theres an awful lot of methods that need
to be implemented to make this work.  I doubt all of them are used in a List
Senario. Even implementing them all theres still a dependency on
DisplayObject (who's methods seem to be implemented). It does feel to me
like the architecture seems a bit off.  I mean if all of those methods are
implemented why is there still a dependency on DisplayObject.

Its not just enough to implement IListRenderer which seems to defeat the
purpose of an interace

On Wed, Aug 18, 2010 at 11:42 PM, Wesley Acheson
wrote:

> *Disclaimer:* This is a cross post with Stack Overflow. I know at least
> one person on this list saw it there.
> http://stackoverflow.com/questions/3507313/flex-switch-item-renderer
>
> Hi
>
> I was wondering if anyone had any luck with the following senario in flex.
>
> I'd like to be able to have a custom item renderer which delegates to
> another renderer inside.
>
> The reason for this would be in a datagrid for instance displaying a
> checkbox if the dataprovider for the row had a boolean value. Using the
> default item renderer when the value was a non boolean.
>
> Basically I was hoping to use a proxy object (though not necessarily the
> proxy class) so that I could a renderer which delegated all of its
> responsibilties to a sub renderer.
>
> Hard to explain.
>
> *Edit 1*
>
> I think the following gives a clearer idea of what I had in mind. This is
> only knocked up quickly for the purpose of showing the idea.
>
> *SwitchingRenderer.as*
>
> package com.example
> {
> import mx.controls.CheckBox;
>
> import mx.controls.dataGridClasses.DataGridItemRenderer;
>
> import mx.controls.listClasses.BaseListData;
>
> import mx.controls.listClasses.IDropInListItemRenderer;
>
> import mx.core.IDataRenderer;
>
> import mx.core.UIComponent;
>
> public class SwitchingRenderer extends UIComponent implements 
> IDataRenderer, IDropInListItemRenderer
>
> {
> private var checkboxRenderer:CheckBox;
>
> private var defaultRenderer:DataGridItemRenderer;
>
> private var currentRenderer:IDataRenderer;
>
> public function SwitchingRenderer()
>
> {
> this.checkboxRenderer = new CheckBox();
>
> this.defaultRenderer = new DataGridItemRenderer();
>
> this.currentRenderer = defaultRenderer();
>
> super();
> }
>
> public function get data():Object
>
> {
> //If the data for this cell is a boolean
> //  currentRender = checkBoxRenderer
>
> // otherwise
> //  currentRenderer = defaultRenderer
> }
>
> public function set data(value:Object):void
>
> {
> currentRenderer.data = value;
>
> }
>
> public function get listData():BaseListData
>
> {
> return currentRenderer.listData;
>
> }
>
> public function set listData(value:BaseListData):void
>
> {
> currentRenderer.listData = value;
>
> }
>
>
>
> }
> }
>
>
>