0

I have a map which contains a list as its value.I am able to populate a list of values via the option box in a jsp page.But when i am trying to print a single value from the list it is not showing anything.

List<UOM> uomList=objectiveDelegate.getUOMList();

System.out.println("------->>"+uomList.size());

for(UOM temp:uomList){

    System.out.println("tepmp result is"+temp.getId());
}
dataArr.put("uomList", uomList);
return SUCCESS;

this dataArr is a map which contains a key and as a list as a value.So when i am doing

<div class="form-control div-pad">
    <div class="divhalf1">UOM</div>
    <div class="divhalf2">
        <s:select name="uom.name" id="uom_name" requiredLabel="true" 
                  list="%{dataArr['uomList']}" listValue="name" 
                  headerValue="Select UOM ">
        </s:select>
</div>

the list is populating,but when i am doing

<div class="form-control div-pad">
    <div class="divhalf1" >UOM ID </div>
    <div class="divhalf2" >
        <s:textfield name="uom.id" id="id" ></s:textfield
    </div>                             
</div>

the id is not populating.

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
lucifer
  • 2,297
  • 18
  • 58
  • 100

1 Answers1

0

In a textfield, name attribute is used both to read the value from the source Action (is value attribute is not specified) and to set the value to the destination Action.

In a select, it's used only to set the value to the destination Action, because the source comes from the list attribute:

<s:select name="uom.name" 
          list="%{dataArr['uomList']}" 
     listValue="name" 
   headerValue="Select UOM ">

(Note that you are missing listKey attribute)

Then here

<s:textfield name="uom.id" />

you are finding nothing, because reading from uom object, that doesn't exist in source Action. You need an iterator too, porbably:

<s:iterator value="%{dataArr['uomList']}" var="current">
    <s:textfield name="uom.id" value="current.uom.id" />
</s:iterator>

But remember, don't nest Lists and Maps too much, use objects instead.

Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243