• 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: Override synchronizesVariablesWithBindings() or isStateless()?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Override synchronizesVariablesWithBindings() or isStateless()?


  • Subject: Re: Override synchronizesVariablesWithBindings() or isStateless()?
  • From: Jonathan Rochkind <email@hidden>
  • Date: Thu, 18 Mar 2004 15:19:12 -0600

At 3:06 PM -0500 3/18/04, Kieran Kelleher wrote:
In the Apple examples, we have ExampleBody in the ExamplesHarness (code shown below).

I notice they are overriding synchronizesVariablesWithBindings and returning false. Am I correct in assuming that this is the way this example implements a stateless component?

No. Two different things. A stateless component is indicated by isStateless()==true, yes. synchronizesVariablesWithBindings() indicates something else entirely---it's somewhat confusingly named, but it indicates whether the WO framework will use it's own built-in way of providing binding values between the parent and child component (in both directions) (if synchronizes... returns 'true', which is it's default). Or, when you over-ride synchronizes... to return true, the WO framework will NOT set variables to equal binding values on it's own---you need to write the code to do that yourself, using the valueForBinding and setValueForBinding methods. Which is not that hard, is more flexible, and will usually end up being a lot more efficient than the WO framework's method of doing it.


Two different things. isStateless() defaults to false, and tells the WO framework whether to share the same instance of your component for multiple uses or not. (If it is stateless, than the framework can share it; otherwise, it needs to instantiate a new component for every request it's needed in). synchornizesVariablesWithBindings() defaults to true, and tells the WO framework whether it should, at multiple points in the request-response loop, automatically set variables in parent and child components to hold values provided through bindings. If false, the WO framework won't automatically do that, you need to grab and set binding values yourself with the methods provided.

All four combinations of these two binary settings are possible: 1. not stateless, let the WO framework synchronize bindings (which is default); 2. stateless but still let the WO framework synchronize bindings; 3. stateless and you synch bindings manually; 4. not stateless and you synch bindings manually.

--Jonathan



Does not overriding the isStateless method and returning true do the same thing? In fact would I be more correct to override isStateless and returning true rather than overriding synchronizesVariablesWithBindings and returning false?

The sentence

"This method returns false for stateless components (unless you override isStateless and return true), and true otherwise"

at

	http://developer.apple.com/documentation/WebObjects/Reference/API/
index.html

is confusing to me?!

Is it saying I should override isStateless to return true and the synchronizesVariablesWithBindings will automatically return false? (the "unless" word does not clarify)

- Kieran

/*
  * WOExampleBody.java
  * [WOExamplesHarness Project]
  */

package webobjectsexamples.examplesharness;

import com.webobjects.foundation.*;
import com.webobjects.appserver.*;


public class WOExampleBody extends WOComponent {

     public WOExampleBody(WOContext context) {
         super(context);
     }

	public boolean synchronizesVariablesWithBindings() {
		return false;
	}


}



________________________________________________________________
Config = OS X 10.3.2 / Java 1.4.1 / WO 5.2.2 / MySQL 4.0.18 / Connector-J 3.0.11
Blog: http://webobjects.webhop.org/
_______________________________________________
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.
_______________________________________________
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.


References: 
 >Override synchronizesVariablesWithBindings() or isStateless()? (From: Kieran Kelleher <email@hidden>)

  • Prev by Date: Re: Losing my mind
  • Next by Date: Re: Losing my mind
  • Previous by thread: Override synchronizesVariablesWithBindings() or isStateless()?
  • Next by thread: refreshesRefetchedObjects significant hit on efficiency
  • Index(es):
    • Date
    • Thread