List Info

Thread: Re: OT: CellRenderer API & setValue




Re: OT: CellRenderer API & setValue
country flaguser name
United States
2007-02-20 15:24:57
>>inherited functions aren't automatically 
>>called (except in the case of no-arg constructors).

Well, not true as I understand it in inheritance, it depends
on what it
inherits from - i.e., if I put a trace in setValue in my
class, compile
my file, the method fires every time the checkbox is cliked
in the
datagrid cell - I make no calls to super.  Here is my
class:

import mx.controls.CheckBox;

class com.boa.projects.iqrcgenerator.components.CheckBoxCell
extends
mx.core.UIComponent
{
    private var owner; // The row that contains this cell.
    private var listOwner; // The List, data grid or tree
containing
this cell.
    private var cb; //the checkbox instance
    private static var PREFERRED_HEIGHT_OFFSET = 4; // Cell
height
offset from the row height total & preferred cell
width.
    private static var PREFERRED_WIDTH = 100;
    private var startDepth:Number = 1;  // Starting depth.

    public function CheckBoxCell()
    {
    }

    public function createChildren():Void
    {
		cb = this.createClassObject(mx.controls.CheckBox,
"cb",
1);
		cb.addEventListener("click", this);
		size();
    }

    public function size():Void
    {
        cb.setSize(__width, __height);
		cb._x = (__width-20)/2;
		cb._y = (__height-16)/2;
    }

    public function getPreferredHeight():Number
    {

        return owner.__height - PREFERRED_HEIGHT_OFFSET;
    }

	function setValue(str:String, item:Object, sel:Boolean) :
Void
	{

		cb._visible = (item!=undefined);
		if(item[getDataLabel()] == "Y") { cb.selected =
true }
else { cb.selected = false };
	}
	
};


Jason Merrill
Bank of America 
Learning & Organizational Effectiveness
 
 
 
 
 
 

>>-----Original Message-----
>>From: osflash-bouncesosflash.org 
>>[mailto:osflash-bouncesosflash.org] On Behalf Of
Ian Thomas
>>Sent: Tuesday, February 20, 2007 4:19 PM
>>To: Open Source Flash Mailing List
>>Subject: Re: [osflash] OT: CellRenderer API &
setValue
>>
>>My assumption was that you were wanting to update
the 
>>underlying value stored in your dataProvider - thus
fixing 
>>the problem with the rendering. Am I wrong? It looks
a bit to 
>>me like your code is correctly rendering what's
stored in 
>>dataProvider, but clicking on your checkbox doesn't
actually 
>>_alter_ what's in dataProvider, which is where your
problem 
>>is coming from. And, randomly guessing, I'd guess
that needs 
>>to be done in dataProvider.
>>
>>You say "Already being done as this is an
inherited 
>>function." with regards to calling your
superclasses version 
>>of setValue(). Not sure I understand how that
happens in the 
>>code you supplied - inherited functions aren't
automatically 
>>called (except in the case of no-arg constructors).
You'd 
>>generally need to call:
>>
>>// overriding function
>>function myFunction():Void
>>{
>>  // call parent implementation
>>  super.myFunction();
>>  // do extra stuff here
>>  . . .
>>}
>>
>>to make sure your superclass gets a chance to act.
But then I 
>>don't know whether your superclass does anything
sensible 
>>with setValue either.
>>
>>Don't really know what your setup is - just making a
few 
>>guesses, so may be way off-base!
>>
>>Ian
>>
>>On 2/20/07, Merrill, Jason <jason.merrillbankofamerica.com> wrote:
>>> Thanks for your respone.  Explain what you mean
by, 
>>"underlying value" ?
>>>
>>>
>>> I am setting the checkbox to be checked or not
by doing:
>>>
>>> if(item[getDataLabel()] == "Y") {
cb.selected = true } else { 
>>> cb.selected = false };
>>>
>>> >>   Perhaps you need to call the
superclass version of
>>> >>setValue() somewhere in there?
>>>
>>> Already being done as this is an inherited
function.  I am 
>>getting the 
>>> label of the current cell and using that to
select the 
>>checkbox. But 
>>> this probably shouldn't be done inside this
function as the 
>>setValue 
>>> function is called every time the datagrid cell
is 
>>interacted with.  
>>> Not sure how this is normally done, and how to
do this 
>>better, this is 
>>> my first experience with the CellRenderer API. 
Thanks for 
>>any advice.
>>>
>>> Jason Merrill
>>> Bank of America
>>> Learning & Organizational Effectiveness
>>>
>>
>>_______________________________________________
>>osflash mailing list
>>osflashosflash.org
>>http://osflash.org/mailman/listinfo/osflash_osflash.org
>>

_______________________________________________
osflash mailing list
osflashosflash.org
http://osflash.org/mailman/listinfo/osflash_osflash.org

Re: OT: CellRenderer API & setValue
user name
2007-02-20 15:53:23
On 2/20/07, Merrill, Jason <jason.merrillbankofamerica.com> wrote:
> >>inherited functions aren't automatically
> >>called (except in the case of no-arg
constructors).
>
> Well, not true as I understand it in inheritance, it
depends on what it
> inherits from - i.e., if I put a trace in setValue in
my class, compile
> my file, the method fires every time the checkbox is
cliked in the
> datagrid cell - I make no calls to super.  Here is my
class

I think we're talking at cross purposes.

What I'm trying to say is that the _parent class's_
implementation of
setValue() - i.e. the default one that would get called if
you hadn't
written your own - might do something that sets a value in
the
dataProvider.

Because you have _overridden_ setValue, you are skipping
your parent
class's implementation. The parent code for setValue will
never get
called _unless_ you use super.setValue in your function.
That's how
inheritance works. So it might be worth trying that. But I
may be
wrong in guessing that the parent class does something
useful for you.

If it doesn't, I think you explicitly need to set a value
within your
dataProvider in your setValue() function. Which is why,
instead, I
suggested something along the lines of:

item[getDataLabel()]=(sel)?'Y':'N';

which explicitly sets the value that you are using to
populate your
checkbox, which, I'm guessing, comes straight out of your
dataProvider. If the reference to item doesn't work, you may
have to
reference dataProvider directly.

Other than that, I don't have enough context to go further,
I'm
afraid. Just trying to suggest obvious routes. Apologies if
I'm being
obscure.

Ian

_______________________________________________
osflash mailing list
osflashosflash.org
http://osflash.org/mailman/listinfo/osflash_osflash.org

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )