Managed Bean

Hi,
I’m using MWS 7.1.3 version.
I want to create a managed bean of a custom java class in all the views of my portlet.
What i want to know is, if i set values to my managed bean in default.view, will the managed bean persist values in a different view in the same portlet.

Please let me know if anymore info is needed.

Thanks,
Sravan

I think the quick answer is “yes”. If you share a managed bean between three different views in the same portlet, the managed bean data will remain in memory (per session). Please see the attached project for an example.

As you navigate between each view, the value of the shared managed bean is available to each view.

Hope this helps,
–mark
SharedManagedBeanApp.zip (17 KB)

Thanks for the sample Mark!
I see that the managed bean scope is set to session and the expireWithPageFlow is set to true. What i would like to know is, when is the managed bean object removed from MWS memory. As the managed bean scope is set to session, i think that the object will be present in the memory through out the user’s session but at the same expireWithPageFlow as true indicates to remove the object once we navigate way from the page.

Which of these properties will take the highest priority?

And what will be your recommendation related to scope if a managed bean(webservice connector) is used.

The page flow setting will reset the managed bean the next time it is requested. You can see for yourself by doing the following:

  1. Open up the MyPortletData class and modify the release() function:

    protected void release() {
    	for (int index = 0; index < 10; index++) &#123;
    		LogUtils.log(LogUtils.LEVEL_ERROR, "releasing instance of MyPortletData");
    	}
    };
  1. Redeploy the sample app and browse to the default view.
  2. Browse to other folders (such as Public Folders, My Folders, etc…)
  3. Browse back to the default.view.

You’ll see that only when you browse back to the default.view does the expirePageBean logic get triggered and the old version of the managed bean is released.

Regards,
–mark

So, whenever expireWithPageFlow is set to true, it resets the managed bean. But the object is still present in the session as the scope is set to session.
Is my understanding right?

And, if i’m using webservice connectors in my application, what should be the scope of these managed beans, any suggestions?

That’s correct, and i think session scope is a reasonable choice for your web service connectors.
Regards,
–mark