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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:33:18+00:00 2026-06-06T21:33:18+00:00

I’ve been researching this for a while. I’ve read How to update a the

  • 0

I’ve been researching this for a while. I’ve read
How to update a the contents of a list displayed on JSP using Struts2?
and it is very close to what I need, but I’m still not quite able to get my problem resolved.

I have a java.util.Set of objects. The class is ‘Event’, and the name of the set is ‘events’. I want to present a form in a JSP that allows the user to modify attributes of the Event objects, but I want to update more than one at a time. Here is my JSP snippet :

<s:form theme="simple">
  <table>
    <s:iterator value="events" var="ev">
    <tr>
      <td> <s:textfield name="?????" value="%{#ev.price}" </td>
      <td> <s:textfield name="?????" value="%{#ev.amount}" </td>
     </tr>
     </s:iterator>
     <tr><td colspan="2">
       <s:submit value="Apply" action="EditEventsAction_save" ></s:submit>
     </td></tr>
  </table>
</s:form>

My problem is (I think) what needs to go in the name of the texfield in order to update my Set.

How can I specify that the data in the textfield is supposed to update a member of my Set?

Is this possible?

UPDATE

This is my latest (simplified) attempt, based largely on what I read in the type conversion docs.

The form is populated correctly, but changes entered in the textfield are not captured on submit.

Action class:

public class TestAction extends ActionSupport implements Preparable {

    private static HashMap<Integer, AssetId> assetMap = new HashMap<Integer, AssetId>();

    public String execute () {
        return SUCCESS;
    }   

    public void prepare() throws Exception {
        AssetId a1 = new AssetId(1, "Asset 1");
        AssetId a2 = new AssetId(2, "Asset 2");
        AssetId a3 = new AssetId(3, "Asset 3");
        assetMap.put(1, a1);
        assetMap.put(2, a2);
        assetMap.put(3, a3);
    }

    public String save () {
        return SUCCESS;
    }

    public static HashMap<Integer, AssetId> getAssetMap() {
        return assetMap;
    }

    public static void setAssetMap(HashMap<Integer, AssetId> assetMap) {
        TestAction.assetMap = assetMap;
    }
}

JSP:

<%@ taglib uri="/struts-tags" prefix="s" %>

<html>
  <body>      
    <s:form theme="simple">
      <table>
        <s:iterator value="assetMap" var="asset">
          <tr>
            <td><s:textfield name="assetMap[key].clientId"  /></td>
          </tr>
        </s:iterator>
        <tr><td colspan="2"><s:submit value="Apply!" action="TestAction_save" /></td></tr>
      </table>
    </s:form>
  </body>
</html>

AssetId class:

public class AssetId implements java.io.Serializable {
    private int assetId;
    private String clientId;
    // And public getters/setters
}

TestAction-conversion.properties

Key_assetMap=java.lang.Integer
Element_assetMap=AssetId
CreateIfNull_assetMap=false
  • 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-06T21:33:20+00:00Added an answer on June 6, 2026 at 9:33 pm

    There are a number of issues; you should have seen stack traces in your log file.

    Most important: you didn’t check the rendered HTML. If you had, you’d have seen key rendering as-is–unevaluated. My fault (comment was incomplete), although the docs show the OGNL escape.

    <s:textfield name="assetMap[%{key}].clientId" />
    

    Since you’re trying to evaluate the key of the current object of iteration you must wrap it in the OGNL escape sequence–you don’t want to evaluate the rest. This renders:

    <input type="text" name="assetMap[1].clientId" value="foo" id="map_save_assetMap_1__clientId"/>
    

    Always check the rendered HTML.

    Eventually the static map will be an issue. It should be an instance property (or, I suppose, a ThreadLocal, but IMO you’d struggle to justify that).

    You should not need the type conversion file at this point; that’s largely a legacy artifact. You should have seen an exception about not being able to find the AssetId class, too.

    Once those things are taken care of if I log the asset map in my submit method, I see:

    {1=foo.AssetId@502c06b2, 2=foo.AssetId@7a6bb93c, 3=foo.AssetId@364e50ee}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... 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.