This module implements a WSF Component for switching between components. Usually this is used for navigating between different dialogs.object WsfSwitch WsfComponent
This WSF Component provides an easy infrastructure for switching between components. In most cases, one will derive another object from this one and use that instead. The children["content"] (see WsfComponent.children) contains the current content of this component. Additional children may be defined and are not handled specially by this component. An example: object Foobar WsfSwitch { var cases = [ [ 'title' => 'Goto Demo A', 'code' => function() { return new WsfDisplay("Demo A"); } ], [ 'title' => 'Goto Demo B', 'code' => function() { return new WsfDisplay("Demo B"); } ] ]; method get_html() { switch_reset(); return <> <div id="$id"> <spl:foreach var="i" list="cases"> <a ${switch_href(i)}>${cases[i].title}</a> </spl:foreach> $( if (declared children["content"]) return children["content"].get_html_cached(); ) </div> </>; } } This Object is derived from WsfComponent.
var WsfSwitch.cases;
This variable is a hash or array of the possible choices. Each element is a hash and has an element with the key 'code' which is a function pointer. This function must return the new component which should replace the current children["content"]. Additional keys might be defined in addition to the 'code' key. Usually keys such as 'title' or 'admin_only' are added. This object creates the key 'isactive' to store information about a choice beeing given the user and later only allows the user entering those choices.
method WsfSwitch.main() ;
Overloaded WsfComponent.main().
method WsfSwitch.switch_code(code);
This method is executed when one of the choices are selected. But it is also possible to call this method from outside and so forcing a switch to another component (possibly not in the choices given by the elements of the cases variable).
method WsfSwitch.switch_href(i) ;
Used to add the href attriuted in a link to one of the choices. See the generic description of this object WsfSwitch for a usage example.
method WsfSwitch.switch_reset() ;
Reset the 'isactive' flags (see cases). This should be called by the get_html() method in derived objects. (see WsfComponent.get_html())
Generated by SPLDOC. | http://www.clifford.at/spl/ |