You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Miller <po...@gmail.com> on 2007/02/22 00:39:44 UTC

Nested tags confusion

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>

Re: Nested tags confusion

Posted by Nuwan Chandrasoma <my...@gmail.com>.
hi,

try remvoing the 'name' attribute from the nested text tasg.

eg: <nested:text  property="description" indexed="true" />

Regards,

Nuwan.

----- Original Message ----- 
From: "David Miller" <po...@gmail.com>
To: <us...@struts.apache.org>
Sent: Wednesday, February 21, 2007 11:39 PM
Subject: Nested tags confusion


> 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>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org