Bambookit Home    Bambookit GUI Tutorial

Back    Next   

IV. Advanced Features

Chapter 17. Set Data Attribute



What is setData?
setData is an attribute of the Widget element.

Definition of setData

Its function is to collect all the widget labels that have been defined in it's parameter list and submit them to a URI. This process only occurs on a loadUrl or loadGui method invocation.

setData="widget1,widget2,widget3"

(Note: in the older versions of Bambookit GUI, prior to build 375, the commas had to be URL encoded, when defining more than a single parameter, i.e. setData="widget1%2cwidget2%2cwidget3")

Let's create a more complete example to demonstrate it's basic usage

<Widget> <Edit setName="widget1" setLabel="one"/> <Edit setName="widget2" setLabel="two"/> <Edit setName="widget3" setLabel="three"/> <Button setData="widget1,widget2,widget3" addActionTarget="action,this,loadUrl='page2.jsp'"/> </Widget>
>From the example above note that the each Edit element is named, widget1, widget2 and widget3. In the Button element, we call setData and we pass the 3 Edit widgets by name to this Button Widget. The addActionTarget invokes the loadUrl method which would request the values from the widgets defined in setData.

Location of setData

(Note that, when the TARGET of the addActionTarget changes, then the setData MUST be moved to the new widget location.)

<Widget setName="main" setData="widget1,widget2,widget3"> <Edit setName="widget1" setLabel="one"/> <Edit setName="widget2" setLabel="two"/> <Edit setName="widget3" setLabel="three"/> <Button addActionTarget="action,main,loadUrl='page2.jsp'"/> </Widget>
>From the example above you note that we have now named the parent widget 'main'. We also moved the setData to this widget. Why? because in the button, addActionTarget, the execute method is on the main widget.
..addActionTarget="action,main,loadUrl='page2.jsp'"..

loadUrl and loadGui

The only time setData is needed is when a loadUrl or a loadGui is invoked
What is the URI output?
>From the previous example we would get the following URI request

page2.jsp?widget1=one&widget2=two&widget3=three

There is a difference between the two methods loadGui and loadUrl beyond simply loading an XML file into the applet or loading a new URL into the web browser. The ability to POST data! You can ONLY POST data via the loadGui attribute, the loadUrl can ONLY use the GET protocol and is thus limited to the URL lenght that gets submitted (about 1Kb)



Back    Next