开发者

clearing session data in JSF

Let's say I have a transactional application that consists of four pages:

  1. An origination page which uses POST parameters to initialize the application
  2. A transaction page where data additional data is captured
  3. A review page where data is reviewed
  4. A confirmation page where submitted data is confirmed

Assume request parameters via POST are passed from (1) to initialize the session which is c开发者_运维知识库reated upon (2).

The application has both a cancel button and a submit button on pages (2) - (3). Both actions should trigger a data reset where any previous values held in request/session/page should be reset.

The obvious solution is to clear out session values in an actionListener on the submit button (3) in but if I do that, I will not have those values to display in the confirm page (4).

Another solution is to clear out data prior to entry to the application but if I do that, I potentially lose the request parameters.

Am I missing something obvious here? What is the best place to reset data in a transactional application such as mine.


For the cancel button, setting immediate true on the correspond "Cancel" UICommand button allowed me to associate a corresponding ActionListener which would clear the "value" of any bound data beans on consentual exit. This ActionListener simply invalidated the managed bean.

For the confirm issue, I ended up using a custom "navigator" framework which guarantees that a user can not navigate back to the confirmation page (or any sub-flow) once they navigate away from it (i.e. by clicking a link on the confirmation page).

The cleanup in this case takes place on entry instead of exit since it's very easy for a user to simply change the url to something else in which case any javascript of jsf hooks would not apply. The "navigator" framework ensures that a user can not go back into a flow that has been invalidated or enter into the middle of a flow.

I understand a lot of this has been simplified with JSF 2.0 assuming FlashScope. I also understand that Spring WebFlow can provide similar functionality as well. Unfortunately, the problem domain I speak of is using jsf 1.1 where using spring in the UI is not an option.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜