• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Spring web flow: session access from model validator

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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]

THE QUESTION:
¿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
SCJP6

 
Seriously Rick? Seriously? You might as well just read this tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!