This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes struts 1.3 Interactive form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 1.3 Interactive form" Watch "struts 1.3 Interactive form" New topic
Author

struts 1.3 Interactive form

vinod chemmi
Ranch Hand

Joined: Jun 15, 2009
Posts: 35
Hi Experts

How can i create an interactive form in struts?
Suppose i want to create a form to enter name of students of class. The students number may change for different class.
I want a form to read number of students and text entries for names.??

Thanks.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8935
    
    9

You are looking at using indexed properties, like an array or hashmap, to represent the data in your form. Search the forum and you should find some examples.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
vinod chemmi
Ranch Hand

Joined: Jun 15, 2009
Posts: 35
No. Indexed properties are not suited for my requirements. I want to create an interactive form which decide the number of entries from an input field itself.Usually we are doing it by using java script.But how can i use HTML tag library inside javascript? Indexed properties such as array,arraylist, or Mapp are not suited .

Thanks.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8935
    
    9

You use JavaScript to add the form elements on the client side. You need to use indexed properties to name the form elements so Struts knows how to handle them.
The Struts tag library is for the developer's convenience. What gets sent to the web browser is plain old HTML ("view source" is your friend).
vinod chemmi
Ranch Hand

Joined: Jun 15, 2009
Posts: 35
Yes i did it.

thanks.
vinod chemmi
Ranch Hand

Joined: Jun 15, 2009
Posts: 35
Hi Experts

I fedup with struts in case of creating interactive forms. I think it has lot problems to work with it. It is not possible to add dynamically one more element and taking the value from java script.

i tried like this from java script..

document.forms['registerForm'].elements['boardname[1]'].value;

here boardname is an indexed property of registerForm(ActionForm).

But i am getting boarname[1] not defined.

I understood struts 1.3 is not suited for working javascript.
Its interactive form always should initialize in Action, then what is meaning of dynamic form..?



Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8935
    
    9

vinod chemmi wrote:It is not possible to add dynamically one more element and taking the value from java script.


There are thousands of examples of such functionality on the internet. Give this one a read and see if it makes sense.

vinod chemmi wrote:
I understood struts 1.3 is not suited for working javascript.


Technically, Struts is an implementation of a Front Controller pattern. It has little to do with client-side tasks like building a dynamic form.
In the example you give above, you have a field named "boardname", but the error you get indicates a field named "boarname". Is this a red herring or is problem that you've misspelled something?
If you still have problems, you will have to Tell Us The Details. There are many things that can go wrong when implementing this functionality. Without knowing exactly what you are doing, we're just guessing.
vinod chemmi
Ranch Hand

Joined: Jun 15, 2009
Posts: 35
Thanks Ess

I resolved it using LazyDynaBean.i think LazyDynaBean is the only solution for crating ineractive formm in struts 1.3. Also i used pure input elements from javascript,because sturuts based is not possible.Any way with javascripts struts elements are not flexible.

Thanks.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8935
    
    9

vinod chemmi wrote:
I resolved it using LazyDynaBean.i think LazyDynaBean is the only solution for crating ineractive formm in struts 1.3. .


I'm happy to hear you got your code to work, but I have pointed out that there are many working examples of dynamic forms with Struts that do not use LazyDynaBean. I don't want people reading this topic to get the wrong idea about what works and what doesn't.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: struts 1.3 Interactive form