Shane

Sorry for all the confusion and please bear with me..

How do I get Struts to repopulate multiple elements with all with the
same property? this is my exact problem..

Let me give u my .jsp page example (Initiall the table will have one
row)

<TABLE id="mytable">
<TR>
  <TD>
    <html:select   property="sex">
      <html:option value="MALE">Male</html:option>
      <html:option value="FEMALE">Female</html:option>
    </html:select>
  </TD>
  <td><html:text property="firstName" /></td>
</tr>
</TABLE>

I have a Javascript which adds rows to the table on click of a button. 

So if user has enetered five rows of data then  How do I get Struts to
repopulate the table?

Hope i am clear.

Thanks


>>> [EMAIL PROTECTED] 06/06/03 10:08AM >>>

Then the original question from the start and asked 3 times in an hour
because it wasn't answered should have been a one liner:

How do I get Struts to repopulate multiple elements with all with the
same
property?  Or something like that.  

>From your question you say you have a (single) table with a (single)
html:text and a (single) html:select.  Now you show the code and it is a
more clear that you don't have what you mentioned.  You should have
posted a
code example in the first place. It would save time.

Now, what doesn't make sense is the same key for the bean:message.  This
is
because I have an interesting solution I am thinking about but if I knew
the
real way you intend to use the tags believe I could help better.
I can't picture the need for this on a form:

Name [     ]
Name [     ]
Name [     ]

Then if you say, it is really key="du.theName1" and the next one is
"du.theName2" then that wouldn't be truly dynamic.



-----Original Message-----
From: Sashi Ravipati [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 06, 2003 8:26 AM
To: [EMAIL PROTECTED]
Subject: RE: How to repopulate Form which has html elementswithsamename

Thanks for the sample and I have that working. But my issues is slightly
different where there are Multiple HTML elements with the same name

Eg: <bean:message key="du.theName" /><html:text property="name" />
<bean:message key="du.theName" /><html:text property="name" />
<bean:message key="du.theName" /><html:text property="name" />
<bean:message key="du.theName" /><html:text property="name" />

Then in this case how do u repopulate the page.

Thanks



>>> [EMAIL PROTECTED] 06/05/03 05:13PM >>>

Here, no more asking about it.  The code is very close but not tested.
So if
it isn't 100% right do some leg work for gosh sakes.

form.jsp:

<%@ taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<!-- I wonder if you are not putting the above line in your JSP??? -->
<html:form action="/test.do" >
<bean:message key="du.theName" /><html:text property="name" />
<bean:message key="du.whatever" /><html:text property="whatever" />
</html:form>

ActionForm class:

package my.package;
class MyForm extends org.apache.struts.action.ActionForm
{
    private String name;
    private String whatever;
    
    public void setName(String name){ this.name=name; }
    public String getName(){ return this.name; }
    public void setWhatever(String whatever){ this.whatever=whatever; }
    public String getWhatever(){ return this.whatever; }

    public String whatThe(){ return "Look at documentation closer!!!"; }

    //Define the validate method or use the struts validator.  Since you
    //a newbie which likes to repost and repost you should not use
    //validator at this point in time, please
}

Action class:

package my.package;
class MyAction extends org.apache.struts.action.Action
{
    //do stuff in the execute method
}

struts-config:

    <form-bean      name="aForm"
                    type="my.package.MyForm">
    </form-bean>

    <action    path="/showform"
        type="my.package.MyAction" 
        name="aForm" 
          input="form.jsp"
          validate="true"
        scope="request">
        <forward name="display"      path="form.jsp"/>
        <forward   name="blah"          path="crap.jsp"/>
    </action>





-----Original Message-----
From: Sashi Ravipati [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 05, 2003 4:29 PM
To: [EMAIL PROTECTED]
Subject: Re: How to repopulate Form which has html elements withsamename

Do u have any working sample so that I can build from there

>>> [EMAIL PROTECTED] 06/05/03 01:54PM >>>
Repopulating Fields.

I keep hearing that this is a freebie in struts but i have note seen it
work
on
my app yet.  i just stuff what i want to repopulate with in the session
(for
now).

It would be nice if someone could post what "setup write"  IS.  so we
can
check
if we have something set up "WRONG".

After all,  WSAD 5 came with struts preloaded so how can it be setup
wrong?



"Sashi Ravipati" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Let me rephrase my question.
>
> I have a table which looks like this.. example
> <table width="300" border="0" cellspacing="1" cellpadding="1">
> <tr>
>   <th>Name</th>
>   <th>Sex</th>
> </tr>
> <tr>
> <td><html:text  property="name" /></td>
>   <td><html:select  property="sex" >
>       <html:option value="">&nbsp;</html:option>
>        <html:option value="M" >Male</html:option>
>        <html:option value="F" >Female</html:option>
>     </html:select>
>   </td>
>   </tr>
> <tr>
>   <td><html:text property="name" /></td>
>   <td><html:select  property="sex" >
>       <html:option value="">&nbsp;</html:option>
>       <html:option value="">&nbsp;</html:option>
>        <html:option value="M" >Male</html:option>
>        <html:option value="F" >Female</html:option>
>     </html:select>
>   </td>
> </tr>
> </table>
>
> So when I add data like
> Sashi     Male
> Sushma FEMALE
>
> now I submit the form, and say there are some validation errors
>
> how can I build the table with the above values retrieving from the
Form
> Bean .My  form bean has the following methods
>
> public String[] getName(){
>     return name;
>   }
>
>   public void setName(String[] newName){
>     name = newName;
>   }
>
>   public String[] getSex(){
>     return sex;
>   }
>
>   public void setSex(String[] newSex){
>     sex = newSex;
>   }
>
> The values are getting stored in the array, but to get them back and
> build my table is what is not clear to me..
>
> <logic:iterate > may do the job but how to use it??
>
> Hope I am clear now
>
>
> >>> [EMAIL PROTECTED] 06/05/03 11:30AM >>>
>
> Sounds like you might be missing input="theform.jsp" in your action
> where
> theform.jsp is the name of your JSP you want to have come back with
the
> errors.  Also, have <html:errors/> in the JSP to report the errors
(just
> as
> important (more) than repopulating).
>
> If this doesn't help find a better (for you) online struts tutorial.
> What
> you are trying to do  is a freebie in struts (if everything is setup
> right).
>
>
> -----Original Message-----
> From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 05, 2003 10:59 AM
> To: [EMAIL PROTECTED]
> Subject: How to repopulate Form which has html elements with same name
>
> Hi
>
> I am a newbie to struts...
>
> I have a dynamic table which has a <html:text >  and a <html:select> .
> The
> user cliks on a add button and enter values in each row of the table
and
> submits the form.
>
> How can I repopulate the valuse if validation fails.
>
> Can some body give a working exapmle of the Action Form that is
required
> for
> this kind of requirement.
>
> I found this in Ted Husted site but had no clue as what he is trying
to
> do,
> What is RESULT etc
>
--------------------------------------------------------------------------
--
> ---------------
> <TABLE><html:form action="/item/StoreCategory">
> <logic:iterate name="RESULT" property="iterator" id="row">
> <TR>
> <TH>name</TH>
> <TH>category</TH>
> </TR>
> <TR>
> <TD><bean:write name="row" property="name"/></TD>
> <TD><%-- REMEMBER TO SPECIFY THE ITERATE ID AS THE NAME --%>
> <html:select name="row" property="category">
> <html:option value="ART">Art</html:option>
> <html:option value="AUT">Automotive</html:option>
> <%-- ... --%>
> </html:select>
> <%-- REMEMBER TO SPECIFY THE ITERATE ID AS THE NAME --%>
> <html:hidden name="row" property="key"/>
> </TD>
> </TR>
> </logic:iterate>
> <TR>
> <TD colspan="2" align="right">
> <html:submit/>
> </TD>
> </TR>
> </html:form>
> </TABLE>
>
--------------------------------------------------------------------------
--
> -------------
>
> ---------------------------------------------------------------------
> 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