wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts ActionForm help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts ActionForm help" Watch "Struts ActionForm help" New topic
Author

Struts ActionForm help

Shriyan San
Greenhorn

Joined: Mar 15, 2005
Posts: 9
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

Joined: Sep 21, 2003
Posts: 415
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

Joined: Mar 15, 2005
Posts: 9
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.
 
Don't get me started about those stupid light bulbs.
 
subject: Struts ActionForm help
 
Similar Threads
How to use 'extends' attribute of <form-bean> tag as well as <action> tag
Validatior inside another
XML data extraction code performance....
Recover ArrayForm in Action
Another "Validator Plugin" Problem