user2353827
user2353827

Reputation: 33

In struts2 framework, DTO consists of list<String>. Its not getting populated from S:select tag

I am new to struts2 and looking at the existing code and elsewhere in the net, I thought my below code should work. I am trying to select some user ids in s:select box in JSP and I want to use these ids in my action class. I am using modelDriven for it and users are in a list

JSP code snippet

<s:select id="selectedAgents" 
          name="selectedUserList"
          multiple="true"               
          list="selectedUserList"
 />

the selected user ids in the page comes to this box. and when the form is submitted, I expect to see the selectUserList in action.

In the action I have

public class WorkLoadReportAction extends GenericAction implements ModelDriven<WorkloadReportDTO> 
...

private WorkloadReportDTO userReportInputData = new WorkloadReportDTO();

...
@Override
    public WorkloadReportDTO getModel() {
        return userReportInputData;
    }

the WorkloadReportDTO has List<String> selectedUserList and its getter and setter.

Now in the method of the action(called from submit), I dont see the selectedUserList populated.

What am I missing?

Upvotes: 3

Views: 604

Answers (1)

Nimmagadda Gowtham
Nimmagadda Gowtham

Reputation: 270

In your Jsp :

<s:select id="selectedAgents" 
      name="selectedUserList"
      multiple="true"               
      list="selectedUserList"

/>

You have name attribute value and list attribute value as same . Try changing the value of either name attribute or list attribute .

Hope this Solves your problem

Upvotes: 1

Related Questions