• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Programatically calling Direct Actions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programatically calling Direct Actions


  • Subject: Re: Programatically calling Direct Actions
  • From: LD <email@hidden>
  • Date: Thu, 14 Jul 2005 14:48:48 +1000

Hi there,

On 14/07/2005, at 11:12 AM, Jonathan Miller wrote:

Is there a way to call a redirect using Direct Actions?

Yes. All directAction methods return an object implementing the WOActionResults interface. e.g., WOComponent, WORedirect, etc.


i.e. in my constructor for main can I put something like
    if(true) {
       go to component X
    } else {
         doNothing()
    }

No. Your Main constructor is not a direct action, but a possible returned result. i.e., It will instantiate for the caller a WOComponent (which is a WOActionResults compatible object).


It sounds like you're either wanting to
1) redirect the user, based on some input data that either fails or succeeds __OR__
2) select the component to display based on some condition.


The latter is simple and doesn't require a redirect. Use a WOSwitchComponent element in your page and display the desired component based on the condition.

The former is better achieved by storing the validation result in a boolean and testing for this condition in your DirectAction method.

Some examples...

-- DirectAction.java --

// called before any action (overridden from parent)
public WOActionResults performActionNamed(String anActionName) {
    WOActionResults result;
    try {
        result = super.performActionNamed(anActionName);
    } catch (Exception e) {
        WORedirect redirect;

        redirect = new WORedirect(context());
        redirect.setUrl(redirect.application().directConnectURL());
        result = redirect;
    }
    return result;
}

public WOActionResults defaultAction() {
    WOComponent nextPage;
    Boolean condition;

    nextPage = pageWithName("Main");
    condition = (Boolean) nextPage.valueForKey("isCondition");
    if (condition == null || !condition.booleanValue()) {
        WORedirect redirect;

        redirect = new WORedirect(context());
        redirect.setURL(...);
        <...>
        nextPage = redirect;
    }
    return nextPage;
}

with regards,
--

LD


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Programatically calling Direct Actions (From: Jonathan Miller <email@hidden>)

  • Prev by Date: Automator workflows for Build and Upload .WOA apps...Enjoy!
  • Next by Date: Model Cross Pollinating
  • Previous by thread: Re: Programatically calling Direct Actions
  • Next by thread: Automator workflows for Build and Upload .WOA apps...Enjoy!
  • Index(es):
    • Date
    • Thread