• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts ActionForm help

 
Shriyan San
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an action form like this
public class StationForm extends ValidatorForm {
private int stationId=-1;
private MarketForm marketForm=null;

public MarketForm getMarketForm() {
return marketForm;
}

public void setMarketForm(MarketForm marketForm) {
this.marketForm = marketForm;
}

public int getStationId() {
return stationId;
}

public void setStationId(int stationId) {
this.stationId = stationId;
}

}
then the MarketForm has getters and setters etc,

public class MarketForm extends ValidatorForm{
private int marketId =-1;

public int getMarketId() {
return marketId;
}

public void setMarketId(int marketId) {
this.marketId = marketId;
}
}

When i use the html form how do i insert values for marketId, ?
should i use <input type="text" name="stationForm.marketForm.marketId"> , this is not working
Can someone please help me with this???
 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am wondering why u r having another form bean as instance variable (ofcourse struts supports nested properties too its a good thing) .rather than u could have extended the second form for this (howveer this extends validatorform)

its ok even if u plan to use in the same way ..ur code should look like this

<html:text property="marketForm.marketId"/> if this is nexted inside <html:form>

else
<html:text name="staticform" property="marketForm.marketId"/>
 
Shriyan San
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help, the problem was i didn't instantiated the 2nd object from the 1st one. After doing it, i was able to reference it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic