• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

dynamic textareas with Struts 2

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am learning Struts 2 and trying to add textareas dynamically with <s:textarea> tag in a jsp page (by clicking a button 'add more'). Can anyone please provide an example?

thanks in advance,

Haitao
 
Bartender
Posts: 9565
12
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to add text fields on the browser, you have to use client-side JavaScript like this.
Name the fields using indexed properties and Struts will handle putting the collection in your JavaBean.
 
Haitao Lok
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your response. sorry I didn't make myself clear here.

In my jsp file, I have the following (with struts tags)

<s:textfield key="subject" name="subject1"/>
<s:textfield key="level" name="level1"/>

I need to add a button on the page so that when I hit it, the browser will display another pair of the textfields

<s:textfield key="subject" name="subject2"/>
<s:textfield key="level" name="level2"/>


I understand javascript can generate pure html dynamically but not struts stuff, which is what baffles me.

Haitao
 
Joe Ess
Bartender
Posts: 9565
12
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Haitao Lok:
I understand javascript can generate pure html dynamically but not struts stuff, which is what baffles me.



On the browser side, there is no "struts stuff". Do a "view source" on a browser-rendered Struts JSP page and you'll see plain old HTML.
 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!