Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8312613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:13:21+00:00 2026-06-08T20:13:21+00:00

I have an Action, called ShowData that recovers data from the database and put

  • 0

I have an Action, called ShowData that recovers data from the database and put it in the jsp.

struts.xml

...
<action name="ShowData" class="foo">
   <result>foo.jsp</result>
</action>
...

In the foo.jsp page I have a form and the data that I have obtained with the ShowData action.

foo.jsp

...
<s:form action="DoSomething">
   <s:input key="email" />
   <s:submit/>
</s:form>
<s:iterator value="data_recovered_in_ShowData">
   ...
</s:iterator>
...

Now I want to add some validation to data. If the return type of DoSomething is something like this: <result name="input">foo.jsp</result> I will lose the data that I recover in ShowData action, but the validation works perfectly and the previous input of the user and the error will be showed in the jsp page.

On the other hand, I know that I can use chain, to do something like <result name="input" type="chain">ShowData</result> and then use MessageStoreInterceptor to recover the data (but I still don’t know how to recover the previous data that the user had introduced in the input). But this is a solution that I’m trying to avoid since I read that using chain is not a good idea.

So then, how do I add some validation in this case without losing any data and without using chain?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:13:23+00:00Added an answer on June 8, 2026 at 8:13 pm

    If your concern is just retrieving DB data in the first action you have a few options.

    1. Use Preparable and have both actions retrieve the data using the appropriate service.
    2. Same, but have both actions inherit the prepare method from a superclass.
    3. Keep the data in session until not needed (can be done manually, using an interceptor, etc.)

    If your concern is previous form data (not indicated in the question) then you have similar options:

    1. Hidden fields (as Tapan’s answer), but you’d still need to validate it if it’s not already in the DB. (If it’s in the DB you can retrieve it. If it’s not and you have a validation error on the hidden data you’d need to redirect back to the previous form.)
    2. Keep that data in session, avoiding revalidation. Remove the data on successful submit. (Again doable via existing or new interceptor, or manually.)

    There are likely a few other options for either scenario as well.

    Ultimately, if you’re using chain only for data retrieval, that’s a bad idea–that’s precisely the scenario that Preparable is for, and eliminates the coupling between actions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a action on my controller (controller name is 'makemagic') called 'dosomething' that
I have a class that has an Action<string> called DisplayData ; In various points
I have an action method VerifyNewUser() that gets called when the user clicks a
I have code that I want to be executed before every action is called.
Actually im doing a home page that only have an action called Index() that
I have the action: UPDATED Action in Item Controller. Action called from ajaxLink in
I have the following action which is called from a screen with a list
I have a controller named AccountController and action called ResetPassword. From the html markup
I have an action called List that shows the results of a search. It
I have a rails action called index that renders the content for my page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.