struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Miller" <possum....@gmail.com>
Subject Nested tags confusion
Date Wed, 21 Feb 2007 23:39:44 GMT
Greetings.

I'm having extreme difficulty getting my application to work with nested
tags.

My form is very simple: it consists of a string and a DTO Object. The DTO
Object in turn contains a List that holds another DTO Object: Form -> Bean
-> List.
Currently I can display data with no trouble but updating data does not
work. I get a variety of very informative errors but and occasionally get no
errors at all. In either case, I am not able to retrieve any updated data in
my Action.

My guess is that I need something to help Struts auto-populate the form. I'm
very new to Struts though so all of this is still pretty mysterious.

Additionally I'm stuck with Struts 1.1x and am unable to update/change/add
any jars.

code:

*The Form*
public class UserInfoForm extends ActionForm
{
 private String callType;
 private UserInfoDTO userInfoDTO = new UserInfoDTO();

 public UsocMaintenanceForm() {
  super();
 }

 public UserInfoDTO getUsocMaintenanceDTO() {
  return userInfoDTO;
 }

 public void setUserInfoDTO(UserInfoDTO userInfoDTO) {
  this.userInfoDTO = userInfoDTO;
 }

 public void setCallType(String callType) {
  this.callType = callType;
 }

 public String getCallType() {
  return callType;
 }
}

*UserInfoDTO*
public class UserInfoDTO
{
  private String userName;
  private List gadgetList;

  public UserInfoDTO() {
  }

  public String getUserName() {
    return userName;
  }

  public void setUserName(List gadgetList) {
    this.gadgetList= gadgetList;
  }

  public List getGadgetList() {
    return gadgetList;
  }

  public void setGadgetList(String userName) {
    this.userName = userName;
  }

  public GadgetDTO getCreateGadgetDTO( int index )
  {
 while( gadgetList.size() <= index )
 {
  gadgetList.add( new GadgetDTO() );
 }

 return (GadgetDTO)gadgetList.get( index );
  }
}

*GadgetDTO
*public class GadgetDTO
{
 private String description;
 private String cost;

 public String getDescription() {
   return description;
 }

 public void setDescription( String description ) {
   this.description = description;
 }

 public void setCost( String cost ) {
   this.cost = cost;
 }

 public String getCost() {
   return cost;
 }
}
*Part of the JSP*
<html:form action="/gadgetAction.do">
...
<nested:nest property="userInfoDTO">
  <nested:iterate property="gadgetList" type="com.foo.dto.GadgetDTO"
id="createGadgetDTO">
    <tr>
      <td><nested:text name="createGadgetDTO" property="description"
indexed="true" /></td>
    </tr>
      <td><nested:text name="createGadgetDTO" property="cost" indexed="true"
/></td>
    <tr>
    </tr>
  </nested:iterate>
</nested:nest>
...
<%-- buttons --%>
...
</html:form>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message