2

I have this dropdown in the JSP:

<s:select name = "destination"
         label = "the destination" 
          list = "drop" 
     listValue = "nameDest" 
     headerKey = "0" 
   headerValue = "chose a destination" />

and there is the destination object in the action class:

private Destination destination;
//getters and setters

but when I submit, I get this error:

No result defined for action com.iticsys.GBO.actions.UserAction and result input

When I removed the dropdown, everything worked fine. So I think that Struts is trying to put the value of the selected value from nameDest, which is a string, into the destination object in the action class.

So how could I get the selected object?

UPDATE :

destination is an object instanced from Destination class :

@Entity
public class Destination {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int idDest;
private String nameDest;

drop is a list of Destination :

private List<Destination> drop;
public List<Destination> getDrop() {
    return drop;
}
public void setDrop(List<Destination> drop) {
    this.drop = drop;
}

After some modification (suggested by Andrea Ligios ) on the drop down:

        <tr>
            <td>
                <s:select 
                name="destination.idDest"
                label="the destination" 
                list="drop" 
                listKey="idDest"
                listValue="nameDest" 
                headerKey="0" 
                headerValue="Chose a destination" />
           </td>
        </tr>

I got this error

1.tag 'select', field 'list', name 'destination.idDest': The requested list key 'drop' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name}

Mohamed Elalami
  • 149
  • 2
  • 12

1 Answers1

1

Yes, you're sending a String to a Destination variable, the types don't match and hence the interceptor stack is raising the error and changing the workflow from the normal execution of the action method you've called, to the INPUT result defined for your action.

Since you've not defined any INPUT result, it raises the error message you're seeing.

Read how the INPUT result works (the pattern is common both to conversion and validation).

Then you need

  1. to define an INPUT result
  2. to specify in your select the listKey
  3. to specify in your select the name attribute including the key.

If, for example, Destination has id and nameDest fields, you need to set:

<s:select name = "destination.id"
         label = "the destination" 
          list = "drop" 
       listKey = "id" 
     listValue = "nameDest" 
     headerKey = "0" 
   headerValue = "chose a destination" />
Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
  • I made the modifications you suggested and now I got this error, 1.tag 'select', field 'list', name 'destination.idDest': The requested list key 'drop' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name}. AND I want to add that the drop list is a list – Mohamed Elalami May 11 '16 at 13:34
  • You must've changed something else, because you had `drop` before and it should have given you this error message back then. Feel free to post your source list definition and getter, and the pojo content to get more help – Andrea Ligios May 11 '16 at 13:53
  • Everything is fine. Please add also the new select code, the one adapted from my answer... the problem is most likely there – Andrea Ligios May 11 '16 at 14:39
  • Are you using ModelDriven ? – Andrea Ligios May 11 '16 at 16:28
  • I restarted eclipse, and now it's working, I don't know why. – Mohamed Elalami May 11 '16 at 22:06