• Post Reply Bookmark Topic Watch Topic
  • New Topic

Resetting UIViewRoot

 
Dushy Inguva
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am navigating between a non JSF page and a JSFpage.
The JSF page is backed by a session scoped bean.

This is the scenario:
1. In the non JSF page, user clicks a button which navigates to a JSF page (I do a sendRedirect at the server side.. in my servlet)
2. In the JSF page, there are a few drop downs, which can be changed by the user. User changes one of them
3. User clicks "cancel" button, immediate is true, and I invoke context.responseComplete() after redirecting back to the non JSF page. No setters are invoked. I also clear the backing bean out of the JSF session scope in the action of the cancel button.
4. User is now back in the non JSF page.
5. User clicks the SAME button as in step 1
6. JSF page displays with the content that user previously selected. But, thats wrong as user had clicked on "Cancel" and the model was NOT updated. JSF creates a new instance of my backing bean (which is good and intended), but does NOT invoke any getters on it, coz it still has the previous state in UIViewRoot. (this is bad)

I tried creating a new UIViewRoot and setting it but, it does not work. Any clues?
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just before the line "context.responseComplete() "
remove your backing bean from session manually. That will solve your problem.
 
Dushy Inguva
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Varun,

Thanks for the quick reply. I am calling context.responseComplete(), and am removing the bean from the session manually (thats the reason why it is creating another instance of my session scoped bean)

But, it is never invoking the getters when i return back to the page, it is just restoring the UIViewRoot and invoking the rendering on it with the state it already contains.

To clear the state in the UIViewRoot, I wanted to recursively iterate over the UIViewRoot and invoke setSubmittedValue(null) on the EditableValueHolder(s) but, I can do that only in the validation phase which is never invoked as my button is a cancel button and has immediate="true" on it
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, this is weird.
Clearing recrusively is an option, but sounds like a really bad solution.

What's your "javax.faces.STATE_SAVING_METHOD" parameter value in web-xml file? I assume you are saving the state on "server". Try setting it to "client". Let me know if it works.
 
Dushy Inguva
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Varun,

That was some smart thinking :-)
I tried setting STATE_SAVING_METHOD to 'client', but it failed as my pages contain f:verbatim tags.

I ended up iterating through the UIViewRoot and invoking setSubmittedValue(null) on the EditableValueHolders... I am doing it in the INVOKE_APPLICATION phase, even though the spec prohibits it. It works, but i'm sure it'll fail if i change the implementation (I use RI right now).

Will get back to this later. Gotta meet a deadline :-)

And yes, this just gave me one more reason to fight against using JSF (atleast for the next 2 years, until it becomes usable) in my company :-)
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool


I tried setting STATE_SAVING_METHOD to 'client', but it failed as my pages contain f:verbatim tags.

But they claims this bug is fixed .. so it isn't?
[ April 07, 2005: Message edited by: Varun Khanna ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!