Hello Nico!

Once more I have followed your advises. Now the code look like this:

<html:text property="arrayForm(0).name">
<html:text property="arrayForm(1).name">
<html:text property="arrayForm(2).name">

I get the following error message:

No getter method for property arrayForm(0).name of bean
org.apache.struts.taglib.html.BEAN

Do Struts really know, that it has to call the method
"testForm.getArrayForm(i).getName()" ???? You know it is an Array of Benas
inside an Form.

Regards,

Arne

> -----Ursprüngliche Nachricht-----
> Von: Nicolas De Loof [mailto:[EMAIL PROTECTED] 
> Gesendet: Mittwoch, 2. April 2003 12:30
> An: Struts Users Mailing List
> Betreff: Re: Array of Beans used in an ActionForm
> 
> 
> use : <html:text property="arrayForm(0).name">
> 
> <html:text> is use inside a <html:form>, so it assumes the 
> current bean is the <html:form> form-bean.
> 
> Here are general Sruts tags usage :
> - "name" is the name of a bean in some scope. <html:xx> use 
> form-bean as default and doesn't need this attribute
> - "property" is the name of the bean property, with indexed / 
> dotted notation
> - "scope" can be use to define where to search for teh bean. 
> By default all scopes are used to search.
> - "id" is the name of a script variable / bean in scope that 
> tag creates for you
> 
> Nico.
> 
> 
> 
> Hello Nico!
> 
> I have tríed this with the following code:
> 
> <html:text property="testForm.arrayForm(0).name">
> <html:text property="testForm.arrayForm(1).name">
> <html:text property="testForm.arrayForm(2).name">
> 
> It resulted in the error:
> 
> No getter method for property testForm.arrayForm(0).name of 
> bean org.apache.struts.taglib.html.BEAN
> 
> Regards,
> 
> Arne
> 
> > -----Ursprüngliche Nachricht-----
> > Von: Nicolas De Loof [mailto:[EMAIL PROTECTED]
> > Gesendet: Mittwoch, 2. April 2003 12:14
> > An: Struts Users Mailing List
> > Betreff: Re: Array of Beans used in an ActionForm
> >
> >
> >
> > For your indexed properties, use arrayForm(x).name instead of 
> > arrayForm[x].name
> >
> > Try to use JSP tags instead of scriptlets, your JSP will be more 
> > readeable to other developers.
> >
> > Nico.
> >
> > ----- Original Message -----
> > From: "Clauss, Arne" <[EMAIL PROTECTED]>
> > To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
> > Sent: Wednesday, April 02, 2003 12:02 PM
> > Subject: AW: Array of Beans used in an ActionForm
> >
> >
> > Hello Nico!
> >
> > Thanks for your help. I now have got indexed getter and setters. 
> > Showing the data in the JSP works fine, but getting the data back 
> > formn the JSP in the UpdateAction didn't work.
> >
> > Please notice: I dont't want to handle an array of Strings in the 
> > ActionForm, I would like to hadle an array of Beans ( with 
> own getters 
> > and
> > setters) in the AtionForm.
> >
> > Maybee it make sence to post some code here for a better 
> understanding 
> > of the problem.
> >
> > This ist the ActionForm used in the JSP:
> >
> > public class TestForm extends ActionForm {
> >
> >
> > /**
> > * Log4j Category for this class
> > */
> > protected final static Category cat =
> > Category.getInstance(TestForm.class.getName());
> >
> > public TestForm (int size)
> > {
> > arrayForm = new DataBean[size];
> > }
> >
> > public TestForm ()
> > {
> > if (cat.isDebugEnabled())
> > {
> > cat.debug("Konstruktor Start");
> > }
> > int size=3;
> > arrayForm = new DataBean[size];
> > for (int i = 0; i<=(size-1);i++)
> > {
> > arrayForm[i]= new DataBean();
> > }
> > if (cat.isDebugEnabled())
> > {
> > cat.debug("Konstruktor Ende");
> > }
> > }
> >
> > private DataBean[] arrayForm = null;
> >
> > /**
> > * Gets the arrayForm
> > * @return Returns a ArrayForm[]
> > */
> > public DataBean getArrayForm(int i) {
> > return arrayForm[i];
> > }
> > /**
> > * Sets the arrayForm
> > * @param arrayForm The arrayForm to set
> > */
> > public void setArrayForm(int i, DataBean arrayForm) { 
> > this.arrayForm[i] = arrayForm; }
> >
> > }
> >
> > This is the Bean which is included in the array of the TestForm:
> >
> > public class DataBean extends ActionForm {
> >
> > /**
> > * Log4j Category for this class
> > */
> > protected final static Category cat =
> > Category.getInstance(TestForm.class.getName());
> >
> > /**
> > * Konstruktor
> > */
> > public DataBean(String myName, int myId) {
> > this.setName(myName);
> > this.setID(myId);
> > }
> >
> > /**
> > * Konstruktor
> > */
> > public DataBean() {
> > this.setName("");
> > this.setID(Integer.MIN_VALUE);
> > }
> >
> > private String name = "";
> > private int ID = Integer.MIN_VALUE;
> >
> > /**
> > * Gets the name
> > * @return Returns a String
> > */
> > public String getName() {
> > return name;
> > }
> > /**
> > * Sets the name
> > * @param name The name to set
> > */
> > public void setName(String name) {
> > this.name = name;
> > }
> >
> > /**
> > * Gets the iD
> > * @return Returns a int
> > */
> > public int getID() {
> > return ID;
> > }
> > /**
> > * Sets the iD
> > * @param iD The iD to set
> > */
> > public void setID(int iD) {
> > ID = iD;
> > }
> > }
> >
> > And last but not least my JSP code:
> >
> > This works fine for showing the data, but not for updating: <%
> > for (int i=0; i<=2; i++)
> > {
> > %>
> > <br><input type="text" name="testForm.arrayForm[<%=
> > i%>].name" value="<%= testForm.getArrayForm(i).getName()%>">
> >
> > <%
> > }
> > %>
> >
> > I have also tried this code int eh JSP. Than I get the following 
> > error: No getter method for property testForm.arrayForm[0].name
> >
> > <html:text property="testForm.arrayForm[0].name">
> > <html:text property="testForm.arrayForm[1].name">
> > <html:text property="testForm.arrayForm[2].name">
> >
> > Any ideas?
> >
> > Regards,
> >
> > Arne
> >
> >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Nicolas De Loof [mailto:[EMAIL PROTECTED]
> > > Gesendet: Mittwoch, 2. April 2003 10:39
> > > An: Struts Users Mailing List
> > > Betreff: Re: Array of Beans used in an ActionForm
> > >
> > >
> > > If you want to use an array for a property that your JSP uses as 
> > > indexed (i.e. property="data(n)") you will have to define indexed 
> > > getters and setters :
> > >
> > > public void setData(index i, String value) {
> > >     this.data[i] = value;
> > > }
> > >
> > > public String getData(index i) {
> > >     return this.data[i];
> > > }
> > >
> > > Struts will not create an instace of the array for you when
> > it creates
> > > or populates the formBean. Your form-bean has to create the
> > array in
> > > the "good" size before population occurs.
> > >
> > > Nico.
> > >
> > >
> > > > Hello!
> > > >
> > > > Is is possible to deal with an Array of Beans in an AtionForm?
> > > >
> > > > It should look like this:
> > > >
> > > > public class TestForm extends ActionForm {
> > > > private DataBean[] dataBeans = DataBean[size_of_array];
> > > >
> > > > getter and setter methods
> > > > }
> > > >
> > > > public class DataBean {
> > > > private String name="";
> > > > private int id = 0;
> > > >
> > > > getter and setter methods
> > > > }
> > > >
> > > > Searching the list I have found the following important facts:
> > > >
> > > > - It is important to have an default construktor in the
> > ActionForm,
> > > > which creates an instance of the Array.
> > > >
> > > > Have somebody some code example to help me?
> > > >
> > > > Kind regards,
> > > >
> > > > Arne
> > > >
> > > >
> > >
> > 
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: 
> [EMAIL PROTECTED]
> > > > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > >
> > >
> > >
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: 
> [EMAIL PROTECTED]
> > >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to