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

  • Home
  • SEARCH
  • 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 8537955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:01:32+00:00 2026-06-11T11:01:32+00:00

I am working on a struts2 project that has interdependent forms. I found struts2-conversation,

  • 0

I am working on a struts2 project that has interdependent forms.
I found struts2-conversation, stepped through their simple-example
and understood the conversation mechanism this far (please correct me if I got something wrong):

  • The Controller is mapped in the struts.xml
  • It holds the serializable ConversationContext and the Storing-Service
  • The ConversationContext holds POJOs mapped on forms by naming convention

Now my question is where to put the validation?

In this structure the controller is only one extending ConversationSupport and thereby ActionSupport supplying the validate, prepare and addField- & ActionError methods.
But validating within the controller would mean to validate the whole context, which does not really serve the issue.

I tried validation through annotation within the POJOs, within the context as described above which gives me some NullPointerException as if the context wasn’t flushed and I think the xml-validation approach of struts2 is just too stiff. (btw how to let the generated javascripts be minified before being served? And why is there so many options?)

Mark’s conversation-interceptor approach had similar problems coming up which’s workarounds I didn’t really get. Maybe you can help me there.

  • 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-11T11:01:34+00:00Added an answer on June 11, 2026 at 11:01 am

    If you would like to use annotations on your model classes, it works fine with the plugin (as do the other validation approaches).

    To validate your model, add @VisitorFieldValidator to the getModel() method in your controller. In the example app, you would then also add @VisitorFieldValidator to the getContact() and getPreferences() methods. Then you can use the validation annotations on the fields you wish to validate.

    The service in the example is just there as a simple example of using an injected service in a Struts2 controller and how that can integrate easily with the conversation framework, but it is not directly related or needed (and I would recommend using either Spring, Guice, or CDI for dependency injection in the real world).

    The ConversationContext class is intended mostly for internal use by the framework. You should be able to avoid interacting with it by using the annotations and conventions. Unless you simply wish to be adventurous.

    To use XML validation in the example app, you would have to change the package name to remove the “struts2” word in order for the Struts2 resource loading tool to load the XML.

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

Sidebar

Related Questions

I am using Struts2 for my project. Working on simple registration project. When user
I am working on a project that requires that i implement a mechanism for
I am working on a project which uses Java,MySql,Struts2 MVC and Hibernate. I tried
I'm working on a project that's having us replace an old struts 1 application
I seem to be having the same problem that everyone has with Struts2 and
I am currently working on a struts2 project. In my project the user is
i am working on a struts2 project. in the view layer i need to
I am working on a struts2 project. I have created url with in my
I have just started working on a struts2 project. I have seen the power
I am working on struts2. I have an interceptor that executes before my action

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.