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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:09:04+00:00 2026-06-08T21:09:04+00:00

I’m using the struts2-jquery plugin I need to set a default value for the

  • 0

I’m using the struts2-jquery plugin I need to set a default value for the sj:select drop-down widget.

The widget currently works and will display all the appropriate values (from a map, where the value is the value to be displayed on the menu). It is called from an action class that handles the appropriate methods.

<s:url id="menu" action="getListofObjects" />
<sj:select name="list" href="%{getListofObjects}" list="objects"/>

Lets say the object is blue and its ID is 3. Currently I have a .jsp page where all the objects are listed. If I click on the ‘3’ it calls an action, which finds the object (blue) and saves both ‘3’ and blue inside the action. Then, it calls a new .jsp page which displays info about the object.

What I want is to have an sj:select drop-down menu that will default to the object I selected (in this case, the colour blue), but when clicked will display the rest of the objects. When I call the widget with value="%{object}" I will get the same object displayed twice.

Does anyone have a solution for this? I’ve seen people using jQuery to scrub the dropdown of duplicates but I want to know if there is a true solution where I can set the default based upon what the dropdown menu returns.

Also, I’m using sj:select because I have some double/triple select methods so I cannot switch to s:select.

Thanks.

Update -> More Code

page1.jsp

<s:iterator value="penList">
<tr class="detail">
<td class="detail">
<s:url action="penUpdate" var="urlTag">
<s:param name="penId"><s:property value="penId"/></s:param></s:url>
<a href="<s:property value="#urlTag" />"><s:property value="penId" /></a></td>

penUpdateAction.java

public String execute(){
    getPen();
    return Action.SUCCESS;
}
public PenVO getPen(){
penVO = penService.searchPens(penId);
name = penVO.getName();
    id = penVO.getPenId();
return penVO;
}

Page1 calls the penUpdateAction which calls page2

Page2.jsp

<s:url id="nameList" action="getNames" />
<sj:select name="name" href="%{nameList}" list="names" onChangeTopics="reloadsecondlist"/>

This is a dropdown menu that shows all available names. It is working but I want it to DEFAULT to the value stored in the penUpdateAction class. Then the user can change the value or leave it as is.

  • 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-08T21:09:05+00:00Added an answer on June 8, 2026 at 9:09 pm

    Try this. I have not tested it but i think it should work:

    <sj:select name="list" href="%{getListofObjects}" list="objects" listKey="id" listValue="name" value="%{id}"/>
    

    Note: The value of listKey and listValue must be properties of the Object in the list you are populating the sj:select with.

    The id property set in value attribute should be a property in your action class which carries the default value that you want to set. Let say the value is 3, and you have a select list like this

    <select>
        <option value="1">Yellow</option>
        <option value="2">Black</option>
        <option value="3">Blue</option>
    </select>
    

    When the page loads, the select will display by default Blue.
    Let me know if u have issues doing this.

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

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

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.