Project Wonder 5.0.0.8787

er.extensions.components.conditionals
Class ERXWOSwitch

java.lang.Object
  extended by com.webobjects.appserver.WOElement
      extended by com.webobjects.appserver.WODynamicElement
          extended by er.extensions.components.conditionals.ERXWOSwitch

public class ERXWOSwitch
extends WODynamicElement

Adds a "multiple if" element to the WO templates. You'd use them to wrap "ERXWOCase" elements with their case bound to a value.

 ==========================
 Example.wo/Example.html
 ==========================
 <webobject name=Switch>
    <webobject name=CaseOne>
        <h2>One: <webobject name=ChosenCaseString></webobject></h2>
    </webobject>

    <webobject name=CaseTwo>
        <h2>Two: <webobject name=ChosenCaseString></webobject></h2>
    </webobject>

    <webobject name=CaseThree>
        <h2>Three: <webobject name=ChosenCaseString></webobject></h2>
    </webobject>

    <webobject name=CaseFour>
        <h2>Four: <webobject name=ChosenCaseString></webobject></h2>
    </webobject>    

    <webobject name=DefaultCase>
        <h2>Default: <webobject name=ChosenCaseString></webobject></h2>
    </webobject>    
</webobject>

 ==========================
 Example.wo/Example.wod
 ==========================

Switch: ERXWOSwitch {
    case = chosenCase;
}

CaseFour: ERXWOCase {
    case = "Fourth";
}

CaseOne: ERXWOCase {
    case = "First";
}

CaseThree: ERXWOCase {
    case = "Third";
}

CaseTwo: ERXWOCase {
    case = 2;
}

DefaultCase: WXCase {
    case = "default";
}

ChosenCaseString: WOString {
    value = chosenCase;
}

 ==========================
 Example.java
 ==========================

public Object chosenCase() {
    Object objects = new Object[] {"Fourth", "Third", "First", new Integer(2), "dummy"};
    return objects[(new Random()).nextInt(objects.length)];
}

 

Author:
ak (Java port), Charles Lloyd

Field Summary
 
Fields inherited from class com.webobjects.appserver.WODynamicElement
_ConstructorParameters
 
Constructor Summary
ERXWOSwitch(String name, NSDictionary associations, WOElement template)
           
 
Method Summary
 void appendToResponse(WOResponse woresponse, WOContext wocontext)
           
protected  WOElement childCaseInContext(WOContext context)
           
 WOActionResults invokeAction(WORequest worequest, WOContext wocontext)
           
 void takeValuesFromRequest(WORequest worequest, WOContext wocontext)
           
 
Methods inherited from class com.webobjects.appserver.WODynamicElement
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ERXWOSwitch

public ERXWOSwitch(String name,
                   NSDictionary associations,
                   WOElement template)
Method Detail

childCaseInContext

protected WOElement childCaseInContext(WOContext context)

appendToResponse

public void appendToResponse(WOResponse woresponse,
                             WOContext wocontext)
Overrides:
appendToResponse in class WOElement

invokeAction

public WOActionResults invokeAction(WORequest worequest,
                                    WOContext wocontext)
Overrides:
invokeAction in class WOElement

takeValuesFromRequest

public void takeValuesFromRequest(WORequest worequest,
                                  WOContext wocontext)
Overrides:
takeValuesFromRequest in class WOElement

Last updated: Wed, Jan 7, 2009 • 04:35 AM EST

Copyright © 2002 – 2007 Project Wonder.