Using Stateless Components

Now that we've had a look at stateful components, I think we have a better understanding of when a component is not stateful, more commonly known as stateless.

Making a Component Stateless

To set a component that isn't stateful as stateless is simple. Make sure the accessor isStateless() returns true. Let's return to WOMappedRolloverTest and set both reusable components WOMappedRollover and WOArea as stateless:

public boolean isStateless() {
    return true;
}

After this is completed build and run.

There should not to be any observable difference. So what's all the fuss about?

Observing Singleton Component Instantiation

When a component is set to stateless, only one such component is created in every application. It is ...

Get WebObjects® Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.