You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andras Balogh <an...@reea.net> on 2001/12/05 16:26:00 UTC

using String[] for an ActionForm value

Hi Struts users,

I have a from in wich i generate with logic:iterate textfields with the
same name, let say 'desc'. 

In the corresponding ActionForm i have created a String array and two
methods

public void setDesc(String d[])
{
 desc=d;
} 

public String[] getDesc()
{
 return desc;
}

Struts populates the desc String array with the correct values, but it
can't redisplay them correctly (i can understand why because it only
support String values not String arrays)
So i have made the following methods:

public String[] getDesc()
{
 return null;
}

public String getOneDesc()
{
  if(desc_index>=desc.length) desc_index=0;
  String s=desc[desc_index];
  desc_index++;
  return s;  
}

and in my form
<html:text property="desc" size="20" value="<%=mybean.getOneDesc()%>"/>

This way my textfields are populated correctly but i fill like i am
forcing something.

I have looked upon the indexed property but i can't see how can help in
my situation.
Has anybody have an example of using the indexed property?
How does the corresponding ActionForm look like?
In general how should an ActionForm deal with form elements generated
dynamically?


Thanx,

Andras.






--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>