If I want to initialize my view only once with initial values, where should I do it?
ActionForm's reset-method seems not to be the right place because it is called every time if the view has e.g. a submit button. Action class seems to be called too late. Where should I handle first initialization of the view? Can anyone please tell me,
I want that my view which uses ActionForm and validation (validation.xml) get default values when the view is first time shown. Those values are allowed to be something else than validation accepts, because I will make a default query from database and show that default data in view.
After that validation should be performed in view's components when user presses e.g. submit button.
Perhaps I have misunderstood your question. Anyway, consider putting java initialization code (constructor or variable initializer) for the your ActionForm's property and put you ActionForm in session scope. Then your ActionForm's property is initialized once in the current session. Is that what you want?
Joined: Oct 31, 2005
Yes, but there are two things that I don't actually like 1. Validator (xml based) gives sometimes error messages and putting "flag" variables to prevent validation in some cases does not look good in code 2. Like to use request as much as possible.
But, thanks anyway. If some have good ideas or best practices, please share them.