2

To render Map<String, List<MyObject>> I have a jsp like this:

....
<nested:iterate property="MyMap" id="entry">
    <bean:write name="entry" property="key"/>
    <nested:iterate name="entry" property="value" indexId="count" id="myBean">
        <div class="">
            <nested:define name="myBean" id="myBeanName" property="name"/>
            <nested:hidden property="description"></nested:hidden>
            <nested:hidden name="myBean" property="name"/>
            <nested:checkbox styleId='<%="enabled-"+myBeanName%>' property="enabled"/>
            <label for="enabled-<nested:write name="myBeanName" property="name"/>"><nested:write name="myBeanName" property="description"/></label>
        </div>
    </nested:iterate>
</nested:iterate>
....

The problem here that after compilation into HTML we see wrong name attribute values although value attributes are coorect:

...
<div class="">
    <input type="hidden" name="value[0].description" value="correct_description">
    <input type="hidden" name="name" value="coorect_name">
    <input type="checkbox" name="value[0].enabled" value="on" id="correct_value">
    <label for="enabled-encDevAddr">correct_description</label>
</div>
...

How to achieve correct values for attribute name?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • 1
    I'm not an expert in struts, but this is an approach I would take trying to solve this problem: checkout the source code of struts in your IDE, run the web server with remote debug port open, start it, connect to the remote debug port from your IDE, add few breakpoints in the source code of struts and observe what's happening – Boris Pavlović Mar 31 '20 at 11:12
  • 1
    Please use [java] tag only when the problem is demonstrable using a plain Java application class with `main()` method and the question is thus answerable by [java] experts. Your question is that not, the [java] experts are not per definition [jsp] experts. Please use [jstl] tag only when the question is about JSTL tags as defined in https://docs.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/index.html. You have only Struts tags, so use [struts] instead. – BalusC Mar 31 '20 at 11:47
  • You can find the answer to your question here https://stackoverflow.com/a/37890478/573032. – Roman C Apr 03 '20 at 10:19
  • @Roman C I don't have Struts 2 – gstackoverflow Apr 03 '20 at 12:33
  • Then consider https://stackoverflow.com/q/20127369/573032 – Roman C Apr 05 '20 at 22:13
  • @Roman C It is a huge legacy project. It is really impossible to migrate to struts 2. For now at least – gstackoverflow Apr 06 '20 at 08:49
  • Unbelievable. I've used [some answers](https://stackoverflow.com/a/20130845/573032) to help with the process. – Roman C Apr 08 '20 at 18:46

0 Answers0