• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ActionForm and View's initialization

 
Alan Mikes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,

Cheers!
 
Iftikhar Arain
Ranch Hand
Posts: 95
Flex Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldn't understand your problem. You want to initialize JSP only one time. Next time when you reach this page you don't want these values.

And what is your path.

1) Browser---> JSP1 ---->Action---->JSP2(View you want to intialize one time only)

2) Browser---->Action---->JSP2(View you want to intialize one time only)
Regards.
 
Alan Mikes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is ActionForm between jsp and Action.

Okey, let's explain this detailed.

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.

So, this is my case. How should it be handled?

Cheers!
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Alan Mikes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Cheers!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic