• 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: Action Method Not Invoked Inside of Conditional
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Action Method Not Invoked Inside of Conditional


  • Subject: Re: Action Method Not Invoked Inside of Conditional
  • From: Jonathan Rochkind <email@hidden>
  • Date: Fri, 03 Jan 2003 11:23:31 -0600

The way WO works, an action inside a conditional CAN NOT be invoked if the conditional evaluates to false. Now, if the conditional evaluates to false at the page display, the action isn't available for the user to click on anyway, so you have no problem. If it's true at the page display, the user clicks on it, and it's still true at the action invocation time, everything is good, the action fires.

But what if the conditional evaluates to true when the page is generated, but then evaluates to false at the point the action is invoked? Perhaps becuase of variables changing value from a form submit----the new values from the form submit get taken BEFORE the action is invoked. Then you've got the problem you ran into.

Explaining why this happens is complex, but you could look at it either as an unfortunate but neccesary byproduct of the whole way WO works (it is), or as a security feature. Bug or feature, your choice, but that's how it is.

When I run into problems like this, here's my sort of workaround. Make a new variable that controls whether the conditional displays, and set that variable only at the beginning of appendToResponse. This new variable is set, maybe, based on user-enterable data, but the new variable itself can only be modified by your explicit code which is only called BEFORE append to response. Like so:

public void appendToResponse(WOResponse r, WOContext c) {
evaluateConditionalDisplay();
super.appendToResponse(r, c);
}
public void evaluateConditionalDisplay() {
//just for example; put whatever condition based on whatever state information
//you want here.
conditionalShouldDisplay = (someOtherVariable != null);
}


Now bind the conditional the 'conditionalShouldDisplay' variable, instead of the state it depends on. Since the conditionalShouldDisplay variable is ONLY changed BEFORE an appendToResponse, you know if it was true for page display, it will be true for the action invocation too, and your action will fire properly.

--Jonathan

At 09:10 AM 1/3/2003 -0600, you wrote:
Hi,

I am having the strangest problem occur. I have a form that contains a field and a button inside of a conditional. The variable that the conditional is bound to is the same as the form field. This way if the variable is not populated then the field and button are shown and the user can edit and submit data. The submit button invokes the action method as expected when the field has nothing in it, but if I enter data in the field, then the variable gets the value but the action method does not get invoked. Its as if the conditional is being re-evaluated at submit, but I have never seen this behaviour before. I am backtracking now to figure out what I changed that has started this behaviour, but if anyone has any ideas please let me know. The only things I can think of that I have done lately is to create a couple of superclasses for my components, i.e.

WOComponent <---- ValidationComponent <--- EditComponent <---- FinalComponent

WO 5.1.3 on Win2K

Thanks,
Tony


_______________________________________________ WebObjects-dev mailing list email@hidden http://www.omnigroup.com/mailman/listinfo/webobjects-dev
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: String conversion with HTML entities
  • Next by Date: no database channel available exception?
  • Previous by thread: Re: A 3-level relation: JavaClient DONT WORK FINE!!!!
  • Next by thread: no database channel available exception?
  • Index(es):
    • Date
    • Thread