struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom Klaasen (TeleRelay)" <tom.klaa...@telerelay.com>
Subject RE: how to dynamically add to form
Date Tue, 13 Nov 2001 13:23:26 GMT
You should have a look at the nested: taglib from Arron Bates, that
makes both these things really easy.

Quoting his contribution mail:
-----
For a built version and the updated example (I didn't want to send more 
than was necessary to provide the source)...
http://www.keyboardmonkey.com/StrutMonkey/downloads/index.html

Updated Running example...
http://www.keyboardmonkey.com/StrutMonkey/
-----


hth,
tomK


> -----Original Message-----
> From: Rob Breeds [mailto:Rob_Breeds@uk.ibm.com] 
> Sent: dinsdag 13 november 2001 13:57
> To: Struts Users Mailing List
> Subject: how to dynamically add to form
> Importance: High
> 
> 
> 
> Hi
> 
> I have an input JSP with a single form on it. The action for 
> the submit
> will invoke the backend business logic and return a results page. Easy
> enough.
> 
> There are several distinct sections in the input page, one 
> for entering 1
> or more names, another for 1 or more descriptions, and other similar
> sections requiring multiple inputs.
> 
> Considering just the Names section, what I want to do is 
> allow the user to
> enter a new name into a text input box and when they click an 
> 'Add' link
> next to the name, it adds the name to the current list of names in the
> ActionForm (stored in a Vector) and redisplays the input form 
> JSP showing
> the current list of names plus a new input text box. The user 
> should be
> able to add one name at a time ad infinitum until they finally hit the
> submit button for the overall form.
> 
> name1                              <----------------------- 
> first 3 names
> already entered
> name2                              <-----------------------
> name3                              <-----------------------
> [ text box ] add name   <----------------------   link to add 
> another name
> and update display
> 
> 1. How do I get the 'Add' link to pass the value of the input 
> text box into
> the ActionForm? I have a field in the ActionForm called 
> newName, and when
> the setNewName method is called it will add the new name to the Vector
> called names. I can't see how to get to the form from a <html:link
> forward>... and I shouldn't have to submit the form to update 
> each section
> of the form should I?
> 
> 2. For testing, I am submitting the form, and in the Action 
> adding dummy
> data into the Vector of names (in NameBean objects with a 
> property of name)
> and forwarding back to the input page. I use the <bean:iterate> tag to
> display the contents of the Vector names, but it gives weird results:!
> 
> Following works and displays the object references to the items in the
> Vector so I know that there are the correct number of items:
> <bean:write name="saveEntityForm" property="names"/>
> 
> This fails, with JSP error 'Cannot find bean el in scope null '
> <logic:iterate id="el" name="saveEntityForm" property="names">
>      <bean:write name="el" property="name"/>
> </logic:iterate>
> 
> It's almost as if the ActionForm isn't being saved in the 
> request but then
> why does the display work when I don't use iterate?
> 
> I'm going round in circles with this so any help to get me 
> moving again is
> appreciated.
> 
> Thanks
> 
> Rob Breeds
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:struts-user-> unsubscribe@jakarta.apache.org>
> For 
> additional commands, 
> e-mail: <mailto:struts-user-help@jakarta.apache.org>
> 
> 

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message