This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Now First i go to first.jsp through CreateCustomerFirst method and display first.jsp with some prepopulated data(Example: list of home type).
When the user does not enter any data and press submit it has to show validation message.
If i specify first.jsp in my input attribute it shows the validation message.
But the prepopulated data is vanished.
If i specify CreateCustomerFirst.action in input attribute it shows the prepopulated data.
but the validation message vanishes.
Please guide me what is the solution for this.
Actions are instantiated per-request, and error messages are stored in the action. Without knowing anything more about your application flow it'll be hard to help more. Please UseCodeTags.
Joined: Oct 27, 2006
Sorry for the long question. In simple what i wanted is in Struts 2 ...
How to pre-populate the contents of jsp (select box) when we display validation message.
Since iam directly forwarding to jsp in input attribute there is no way i can prepopulate the select box
since the logic for bringing pre-populate data is in action.
Have you looked at the Prepare interceptor and its cousin Preparable?
Joined: Oct 27, 2006
I also tried with preapre and preparable..
Prepare method gets called when input get called.. and it populates my select box... and also displays validation messages.
But the problem is same prepare method gets called When i successfully entered all the fields also which i dont want to do.
Iam really stuck up with this validation From 2 weeks
So now iam trying with MessageStoreInterceptor....
prepareXxx, where xxx is a method name is also called--you *could* do that if it meets other requirements... although the additional performance hit caused by a single unnecessary prepare call may not be worth the bother.
Setting the message store interceptor's mode to automatic will handle most use-cases for preserving messages across redirects.
All that said I've never had that many problems with messages etc., but I try to work within the framework's limitations.
Did you get any solution for this?? I am also facing the similar problem.
Mine is In the index.jsp , I need to populate a select box and then fill the data in the form and submit. On submit of it, it will invoke another action at this time if validation defined fails, it cant populate the data for select box along with the error messages.
Could anyone who already got the solution for this, can you please help us???