>From: Hermod Opstvedt <[EMAIL PROTECTED]> > > Hi > > I have the following situation: I have a page with some buttons on it, which > leads to actions that are handled by navigation rules. This is working ok > for all but one of the pages. > > This page uses the same viewcontroller as the originating page. On the > originating page I have a hidden input that holds a value that is supposed > to be used by the viewcontroller for getting data for the destination page. > Now, what I see is the following when I press the Button > > The hidden value is set on the viewcontroller (instance 1) by > ViewViewHandler.restoreView. The value is null. > Then the value is set on the viewcontroller (instance 1) by > Clay.processUpdates. The value is now the correct one. > The method that is backed by the button is called on the viewcontroller > (instance 1). This method returns an outcome which is mapped to the > destination page by the navigation rules. > > So far so good. > > Now, what happens next is not what I expected: > The setter method for the hidden value is called again on the viewcontroller > (instance 2!!) by ViewViewHandler.renderView, and with a value of null. > And finally the method that backs the data for the destination page is > called on the viewcontroller (instance 2!!) by ViewViewHandler.renderView. > > I would have thought that since this is one request, that the to pages would > share the same instance of the viewcontroller, and not that a new instance > of it would be created for the second page. Have I misunderstood something, > or I am just way out on the field with this one. >
I don't think that both pages can share the same view controller instance because they are registered as managed beans based on the name of the page/ view id. This could happen if page1 and page2 are both identified by the same URI (same page). Even then, the view controller would have to be in session scope to keep state between the first and second page requests. Now the shale subview component would allow you to tie multiple pages to the same view controller instance if placed in session scope. The "id" attribute is the name of the view controller. page 1: <span jsfid="subview" id="commonbean"> page content </span> page 2: <span jsfid="subview" id="commonbean"> page content </span> <managed-bean> <managed-bean-name>commonbean</managed-bean-name> <managed-bean-class>org.acme.MyBean</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> I've not actually tried this but can't see why it wouldn't work. Gary > Hermod > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] >