tags:

views:

360

answers:

1

Hi,

I am a newbie to Struts and have inherited a problem. I am trying to pass 3 values contained in the same table cell from a JSP to my ActionForm class. The first value (and others in the JSP) work fine, but for some reason the other two do not. I have the appropriate getters and setters, but only the first (newrecnum) shows up, the other two are null. Is there a limitation to only pass the first value? Or is there something else wrong? Here is the JSP code:

<td>
<html:text size="10" maxlength="10" property="newrecnum"/><br>
<html:text size="5" maxlength="5" property="newrectime"/>
<html:select property="newreccode" disabled="true">
    <html:option value="YES">YES</html:option>
    <html:option value="NO">NO</html:option></html:select>
</td>

I can include the ActionForm code as well if needed. Thanks!

+1  A: 

The first thing that strikes me is the fact that you have disabled="true" on the select field. Any input that is disabled is not sent to the server when you submit the form. No parameter on the request means Struts has nothing to bind in your ActionForm instance (so the properties will remain untouched, in your case null).

About the other field, check to see if you really defined the getters and setters right (are they public, the name matches exactly). It should be something like this (I am going with type String for simplicity):

public void setNewrectime(String val) {...}
public String getNewrectime() {...}

public void setNewreccode(String val) {...}
public String getNewreccode() {...}

Since you say that you inherited this thing, are you sure that Struts does the binding of the form parameters to your ActionForm instance or is it done by hand and you have to add code to some method that does this (I am asking because over the years I have seen Struts applications abused to the max).

dpb
Thank you for the response dpb. I have found the error. The disable field is actually changed to "false" after a certain value is entered in another field, so that wasn't the issue.It was a case of the setters names not matching correctly. I swear I checked this a million times yesterday. I guess I just needed a nudge and some time away from it to see it. Thanks again!
tacotime