File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts ActionForm help" Watch "Struts ActionForm help" New topic

Struts ActionForm help

Shriyan San

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

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>

<html:text name="staticform" property="marketForm.marketId"/>
Shriyan San

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.
I agree. Here's the link:
subject: Struts ActionForm help
jQuery in Action, 3rd edition