Skip to Content
0
Former Member
Oct 18, 2004 at 07:50 AM

Scope of ComponentContext

31 Views

Sorry to bother again... As soon as I have one thing figured out, the next issue arises. Now my problem is, that I am not very sure if the objects stored in the

IPortalComponentRequest request =
	(IPortalComponentRequest) this.getRequest();
IPortalComponentContext myContext = request.getComponentContext();

are accessible only for the current logged on user. For me it looks like it is shared for any user logged on to the portal.

To trace this problem I created a very simple Java iView which has two buttons. The first sets a new values in my bean, the second is just for refreshing. The thing I do in the doInitialization() is to put my bean in the ComponentContext. After that I work with the bean object and set and get things in it. This works very fine for one user. But as soon as another user (on a different computer) accesses my iView the two bean objects get mixed up. Results from one user appear on the other users output fields, eg: user A clicks on Click1 and sets the bean Results to "onClick1". If user B starts the same iView from a differnt computer the first thing he gets is the initial value "Start". But when user A clicks on Refresh he now gets the "Start" value. I can continue with this. If user A now clicks on Click1 and B refreshes he sees "onClick1", ...

Can somebody tell me what I am doing wrong?

Here is the code:

public class TestBean extends PageProcessorComponent {

	public DynPage getPage() {
		return new TestBeanPage();
	}


	public class TestBeanPage extends JSPDynPage {
		Bean myBean;
		
		public void doInitialization() {
			IPortalComponentRequest request =
				(IPortalComponentRequest) this.getRequest();
			IPortalComponentContext myContext = request.getComponentContext();			

			Bean myBean = new Bean();
			myBean.setResults("Start");
			myContext.putValue("myBeanName", myBean);

		}

		public void doProcessAfterInput() throws PageException {
			 IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
			 IPortalComponentContext myContext = request.getComponentContext();
			 myBean = (Bean) myContext.getValue("myBeanName");
		}
		
		public void onClick1(Event event) throws PageException {
			myBean.setResults("onClick1");			
		}

		public void onClick3(Event event) throws PageException {
			// Just refresh
		}

		public void doProcessBeforeOutput() throws PageException {
			setJspName("myTestJsp.jsp");
		}
	}
}

Thanks for any help on this!

Best regards,

Holger.