Gianfranco Gianfranco - 1 year ago 134
Java Question

Select tag error Struts 2

Well, I'm blocked with this, I have a .jsp with 2 forms, one of them is to look for pets according to an id of the customer, and the other is to register a service for one of those pets, so the problem is that when I look for the pets with the following form, which is linked to a PetsAction:

<s:form action="searchPets">
<div class="col-xs-3">
<input type="text" name="" class="form-ontrol">

I have a problem with a Select Tag, that is loaded by first time with data from the Prepare method of the ServiceAction, when the data from the form "searchPets" come to the .jsp

<s:select list="employees"

This is the error that I get
tag 'select', field 'list', name 'GrooService.employee.IdEmp': The requested list key 'employees' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]

So, what should I modify? Is correct if I load the data of the Select Tag from the
too? Should I have just one action for both forms?

Answer Source

As far as both actions return the same result JSP which contains a select tag and different action classes hold the action method you have to write prepare() in both classes. Otherwise you can use one action class for both actions/methods. The exception is thrown because the list attribute of the s:select tag couldn't be null. You should properly initialize the variable used for the tag before returning a result that has references to that variable.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download