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 8822967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:14:16+00:00 2026-06-14T06:14:16+00:00

I am using Strust2 for the presentation layer.I have struts form with drop down

  • 0

I am using Strust2 for the presentation layer.I have struts form with drop down which binds with the java object(Application) list.
Drop down displays application object list, user can select one Application and submit.When retrieve the user input value in the Action class, receiving value type is “String”, Can’t we retrieve objects directly from the struts drop down,In my case “Application” objects

   private List<Application> applicaionList = new ArrayList<Application>();
   @Autowired
   private ApplicationService applicationService;
   private Application application;

   public void loadTheForm(){
       applicationList = applicationService.findAll();
   }

   public void submitForm(){
       Document doc = new Document();
       doc.setApplication(application);

   }
   //Getter Setters...

}

application.jsp

<s:form action ="submitForm">
    <s:select list ="applicationList" headerValue="---Select---" headerKey="-1" name="application"/>
</s:form>

struts.xml

   <action name="submitForm" class="com.ActionSupport" method="submitForm">
            <result name="success" type="tiles">/newAdminDocumentRequired.tiles</result>
   </action>

When user select the value from the drop down and submit, the submitted value is string,
Can’t we take the object directly in Struts, if we can’t how we can get the object of the selected value?

Thank you,
Udeshika

  • 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-14T06:14:17+00:00Added an answer on June 14, 2026 at 6:14 am

    What I got from your question is

     1. You have to show list of applications as drop-down.
     2. User selects one application and submit the form.
     3. You have to retrieve the selected application and perform some action with it.
    

    I assume your Application class has a property ‘id’ which is unique to all applications. And a applicationName, which you have to show to the users.
    So now, I would have solved this issue as follows

      <s:form action ="submitForm">
            <s:select list ="applicationList" headerValue="---Select---" headerKey="-1" key="application" listKey="id" listValue="applicationName"/>
        </s:form>
    

    Now, this tag will create a drop-down like follows

    <select name="application">
        <option value="-1" selected="selected">---Select---</option>
        <option value="1">Demo 1 App</option>
        <option value="2">Demo 2 App</option>
        <option value="3">Demo 3 App</option>
        <option value="4">Demo 4 App</option> 
       </select>
    

    Note that values(1,2,3,4) in OPTION elements are application.id and titles(Demo 1 App, Demo 2 App,etc) are application.applicationName.

    Now, user will select and submit. The id of selected application will be sent to struts action in parameter “application”.
    In Action, you can do this

    public MyClass extends ActionSupport{
    
       private List<Application> applicaionList = new ArrayList<Application>();
       @Autowired
       private ApplicationService applicationService;
       private **String** application;
    
       public void loadTheForm(){
           applicationList = applicationService.findAll();
       }
    
       public void submitForm(){
           Application varApp = applicationService.findApplicationById(getApplication());
           Document doc = new Document();
           doc.setApplication(varApp);
    
       }
       //Getter Setters...
    
    }
    

    Please note that I have changed type of application to String. And yes, I don’t think you can pass directly object from drop-down.

    Hope it helps.

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

Sidebar

Related Questions

I am using strust2 for my web application development. My struts.xml file will be
I am using struts2 for developing a web application. I have include the required
I am using strut2 in my project in which in jsp pages i have
I'm using struts2 and have a long running process which utilizes the execAndWait interceptor.
I am using Struts2 for a web application development. i have this particular problem
I am using struts2 and hibernate. I have a jsp page which is loaded
I am using Struts2 in my application. In my application I have one login
i am using Struts2. I have a dialog box with a list of persons
I am using struts2 to build a web application and I use struts2 tags
I needed to create an application using Struts2 as MVC,Hibernate for data access and

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.