Hi Salva,

When you say new ULCPieChart(400, 300), the values for width and height are
set in the object. When the object is uploaded on becoming visible, these
values are sent to the client proxy by the saveState() method.

        protected void saveState(Anything a) {
        super.saveState(a);
        saveState(a, PieChartConstants.PIECHART_WIDTH_KEY, fWidth, -1);
        saveState(a, PieChartConstants.PIECHART_HEIGHT_KEY, fHeight, -1);
          ...
        }

On the client side, these values are available to createBasicObject(Anything
args):

        protected Object createBasicObject(Anything args) {
        return new PieChart(
>>>                args.get(PieChartConstants.PIECHART_WIDTH_KEY, 200),
>>>                args.get(PieChartConstants.PIECHART_HEIGHT_KEY, 150));
        }

The values that were set in the ctr on server can thus be set on your widget
when it is instantiated on the client side. If those values were not set on
the server then default values 200, 150 are used.

If you don't wish to set the values set by ctr in createBasicObject, then
you can implement restoreState() method in the client side proxy class (e.g.
as in UIPieChart) and extract those value from the Anything args and set it
on the BasicObject (your widget).

        public void restoreState(Anything args) {
        super.restoreState(args);

        int width = args.get(PieChartConstants.PIECHART_WIDTH_KEY, 200);
        getBasicPieChart().setWidth(width);
        ...
      }

I hope this helps.

Thanks and regards,

Janak


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of salva vilarrasa
Sent: Monday, March 27, 2006 4:49 PM
To: [EMAIL PROTECTED] Com
Subject: [ULC-developer] Extending ULC


Hi all,
I am a bit confused about extending ULC. I would like to know how can i pass
an attribute in the constructor. I have read chapter 5 in the Essentials
Guide and have built the Pie example. The pie example implements the width
and height in the constructor but as I look in the code I found that in the
UI object it puts default values (for instance 200,150) so if I create the
object like new pie(400,300) it never gets those values? how this is
achieved? thanks everybody.

_______________________________________________
ULC-developer mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/ulc-developer

Reply via email to