WebObjects/Web Applications/Development/Stateless Components

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Implement isStateless in your WOComponent and you will be able to manage the state yourself:

 public boolean isStateless() {
   return true;
 } 

Chuck Hill[edit | edit source]

There is some fairly OK information on stateless and nonsynchronizing components in Practical WebObjects. In a nutshell you need to use valueForBinding/setValueForBinding to access bound values and implement a public void reset() method that nulls all instance variables. This often requires design changes to your component.

Jean-François Veillette[edit | edit source]

Sometimes for stateless component, you need to keep variables values between the 3 phases, from takeValueFromRequest all the way to appendToResponse. Since ivars in a stateless component can't handle this case (reset() will be called after each phase), you have to store the information somewhere. Just use context.userInfo dictionary, and put whatever value in there. As the name imply, the value will only be good for this request only.