• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

struts 1.3 Interactive form

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
vinod chemmi
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i did it.

thanks.
 
vinod chemmi
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic