This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Struts and the fly likes struts2: how to create dynamic input field? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply locked New topic

struts2: how to create dynamic input field?

hans meiser

Joined: Dec 29, 2008
Posts: 22
Hi guys.

I would like to create a Form where a user can enter a text, and then enter multiple buzzwords which match to the text.

My first Idea was to make a input field and to write, that the user has to seperate each buzzword with a ; in the input field. so i could operate with string operations an fill each buzzword into the database.

now my question is, if there is a possibility to make a input form, which generates a new empty input field, if you fill in the first on? so the user can add as many buzzwords as he likes?

this would be easyier to handle for the user.

Thanks for your input!
Joe Ess

Joined: Oct 29, 2001
Posts: 8713

Are you asking how to add the text boxes? That's not a struts problem. You can do that with client-side javascript.

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
hans meiser

Joined: Dec 29, 2008
Posts: 22
Can you tell me how i have to implement this on one JSP site? how can i use the stored values after that in my action class?

It would be very helpful, if you could post a short example?

Thank you very much...
Joe Ess

Joined: Oct 29, 2001
Posts: 8713

You can use javascript in a JSP.
As for getting the information to an action, I assume one would use an indexed property. Our FAQ has an example for Struts 1. This example for Struts 2 is fairly similar.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 541

I have similar kind of problem

I tried the below:

Idea is to use same name in Action Class property.
The above works but below does not:

Now I would use the name EmailId1 as property but the above does not work.Please advice.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60077

Please do not post the same question more than once.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: struts2: how to create dynamic input field?
Similar Threads
help with this type of programa (manipulating text)
Form Problem
form navigation
Validate a form
jQuery-How to highlight invalid input field value after getting validation error