PLEASE IGNORE LAST POST!!!

Sorry, guys - please ignore my ramblings in the last post.  Was a mistake on my
part converting everything to arrays.

My iteration DOES work with arrays, as well as collections!  As follows:

public final class ParametersForm extends ActionForm
{
   // --------------------------------------------------- Instance Variables

   /**
    * The parameter list
    */
   private Parameter[] parameterList;
   // ----------------------------------------------------------- Properties

   /**
    * Return the list of parameters
    */
   public Parameter[] getParameterList()
   {
      return(this.parameterList);
   }

   /**
    * Set the list of parameters
    *
    * @param parameterList The new list
    */
   public void setParameterList(Parameter[] parameterList)
   {
      this.parameterList = parameterList;
   }

   /**
    * Get a particular parameter from the parameterList, based on index
    *
    * @param   index The index of the parameter to retrieve
    */
   public Parameter getParameter(int index)
   {
      return parameterList[index];
   }
}

In parameters.jsp:

      ....
      <logic:iterate id="parameter" name="ParametersForm"
property="parameterList">
      <TR>
         <TD WIDTH="50%">
            bean:write name="parameter" property="key"/>
            <bean:write name="parameter" property="desc"/>
         </TD>
         <TD WIDTH="50%">
                    <html:text name="parameter" property="value" indexed="true"
onchange="validate(this)"/>
         </TD>
      </TR>
      </logic:iterate>
     ....

In my SaveParametersAction.java I simply get the paramList from the form and
process them...

   public ActionForward perform(ActionMapping mapping,
                                ActionForm form,
                                HttpServletRequest request,
                                HttpServletResponse response)
   throws IOException, ServletException
   {
      ...
      ParametersForm paramForm = (ParametersForm) form;

      // Get the parameter list
      Parameter[] paramList = paramForm.getParameterList();

     ...do stuff with paramList
   }

So, Frank, not sure what you're doing differently!  Maybe you can check the code
 above and see if you spot anything?

Cheers, and sorry for the confusion - too little sleep, I think!

Dave


---------------------- Forwarded by David Hay/Lex/Lexmark on 07/12/2001 01:52 PM
---------------------------


David Hay
07/12/2001 01:11 PM

To:   [EMAIL PROTECTED]
cc:
Subject:  Re: Long Story short

Frank,

I have just tried mine with arrays, rather than collections, and does NOT work!

Can anyone explain why?  Presume it is something to do with getters/setters, but
would appreciate any insight...

Cheers,

Dave


---------------------- Forwarded by David Hay/Lex/Lexmark on 07/12/2001 01:11 PM
---------------------------


David Hay
07/12/2001 12:38 PM

To:   [EMAIL PROTECTED]
cc:

Subject:  Re: Long Story short  (Document link: David Hay)

Frank,

could you do me a favour?  Could you try using a collection eg Vector instead of
array in your form bean?  you should then have the equivalent of the following
in your form bean:

public final class ParametersForm extends ActionForm
{
   // --------------------------------------------------- Instance Variables

   /**
    * The parameter list
    */
   private Vector parameterList = new Vector();
   // ----------------------------------------------------------- Properties

   /**
    * Return the list of parameters
    */
   public Vector getParameterList()
   {
      return(this.parameterList);
   }

   /**
    * Set the list of parameters
    *
    * @param parameterList The new list
    */
   public void setParameterList(Vector parameterList)
   {
      this.parameterList = parameterList;
   }

   /**
    * Get a particular parameter from the parameterList, based on index
    *
    * @param   index The index of the parameter to retrieve
    */
   public Parameter getParameter(int index)
   {
      return (Parameter)parameterList.elementAt(index);

   }
}

Let me know if that changes anything

cheers,

Dave




"Frank Ling" <[EMAIL PROTECTED]> on 07/11/2001 07:04:03
PM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:    (bcc: David Hay/Lex/Lexmark)
Subject:  Re: Long Story short



Hi, Dave:

Thanks for the reply, I did have form-bean define at my struts-config.xml,
in the matter fact, I did get all other form-bean field setting back form
HTML form except this attributes array.

The reason I used the changed indexed tag of html:text for iterate tag, is
recently all the thread on this mailing list regarding for Iterate property
updating all recommend using your changed tag to have text name set like
array items (I.e. attributes[n].value), then sounds like will help to set
this value back to original array on my form bean. I just don't get it how
this will be happen.

I do have all my html:text name set like that way (i.e.
attributes[n].value), but still get nothing setting back to my array, I do
have all the setter method for element of the array.

Do you know how your indexed tag will help on this matters?

Thanks again.

Frank Ling


----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 11, 2001 2:22 PM
Subject: Re: Long Story short


>
>
> Frank,
>
> Do you have your struts-config set up correctly?  You might check that a
new
> form is not being created...
>
> Dave
>
> PS  Do you need the indexed naming?  If you don't, you don't need to use
the
> changed tags...
>
>
>
>
> "Frank Ling" <[EMAIL PROTECTED]> on 07/11/2001
> 01:19:29 PM
>
> Please respond to [EMAIL PROTECTED]
>
> To:   [EMAIL PROTECTED]
> cc:    (bcc: David Hay/Lex/Lexmark)
> Subject:  Long Story short
>
>
>
> Hi, There:
>
> I send a long version story regarding for the Iteration tag with indexed
tag
> for property update. Not too much people response. Here is the short
version
> for that story.
>
> I get Dave hay's indexed tag work good with the Iterate tag for showing
the
> text field of my array attributes. I get attributes[n].value shows
properly
> on my JSP page. but nothing setting back to attributes array of my form
> bean. the whole array is null after I received it on the next action
class.
>
> Can anybody explain to me, why I get all these attributes[n].value shows
as
> the name of HTML text name, then that will automatically populate back to
my
> array? It's not working that way for me right now. what I did wrong. Any
> suggestion will be highly appreciated.
>
> Thanks
>
> Best Regards
>
> Frank Ling
>
>
>
>
>
>
>
>











Reply via email to