File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Spring web flow: session access from model validator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Spring web flow: session access from model validator" Watch "Spring web flow: session access from model validator" New topic

Spring web flow: session access from model validator

Felipe Vega

Joined: Dec 05, 2008
Posts: 1
Good evening to all!!!

It's been a while since I post in javaranch and I really appreciate your effort of helping and continue learning.

I have been learning Spring, to be more specific Spring Web Flow... Everithing was perfect and documentation helped a lot until a found the following situation:

I am using what documentation call "model validate method" however, I am facing a situation where I need to access the session to validate if a value exists in the database. My question may be so simple... ¿How can I access the session from a bean's validate${state} method?

Please look at the following code and its description:

What I want to explain for this flow configuration is:
1) I am using the <result="flowScope.carInfo"> to pass a bean to the form when first loading so I can have my form with values loaded from the database.
2) I am using the <model="flowScope.carInfo"> to indicate the model so I can create a validate<model> method in the carInfo bean.

Now please look the validator<model> method in the carInfo bean:

The point to describe here are:

1) The code is pointing ok to the method and the validation in the first condition success and returns as expected to the view.
2) In the else statement, I need to access a DAO method of another bean. (car != carInfo)
3) The other bean (car) has not been initialized within the scope of the flow.
4) I can initialize the DAO using the session. [solution]

¿How can I get the Session to validate a value in the database when using the Spring Web Flow Validator Model?

The official doc I found is the official one for spring, just search for "Implementing a model validate method" (Please just google it since I am not sure if I can paste the link here)

I hope this question to be trivial for experts.... THANK YOU VERY VERY MUCH IN ADVANCE...

Kind Regards

Luis Felipe

I agree. Here's the link:
subject: Spring web flow: session access from model validator
Similar Threads
Web Flow: Neither BindingResult nor plain target object for bean name available as request attribute
collection getting appended on refresh of page
Spring web flow: Not proceeding from first page to second page
"Document root element "beans", must match DOCTYPE root" problem
How do you pass command related parameters from page to page in Spring Web Flow