• 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

session.getattribute question

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm kind of new to the jsp world and have a question related to restoring html form fields dynamically using session.getattribute and javascript looping through the document.form.elements. Is there a way to do this. I am using WebSphere Development Studio Client as my development bench accessing an IBM Iseries DB2 data base through WAS 5.0. I am able to do it for each form element by name but there are many pages and many elements.

Thanks,
Randall
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Randal,

If what you mean to do is to have a client submit a form, and then if you need to display it again, populate it with the data sent by the client, then you can do it with a combination of JSP-JavaBeans.

Create a JavaBean with instance member names matching the input element names in the form. When the user submits the form, use <jsp:setProperty> tag to store all the data submitted in the JavaBean. If you need to display the form again, use that bean to populate it with the values sent by client earlier.

HTH
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sonny's point is that you do not need to use client-side Javascript to accomplish this. In fact, that's a mechanism I would not recommend.

Use server-side JSP mechanims to set the value attribute of the form controls to the desired values.
 
Randall Stewart
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.

So this would reload all of the html form fields defined in the bean class from the session?

<jsp:setProperty name="xyz" property="*" />

and this would do just one of the elements?

<jsp:setProperty name="xyz" property="field" value="value"/>

How would I clear out the old data the next visit to the page from a prompt page?

Also where in the HTML form would I place the code? I have an onLoad function and onUnload already built.

I don't mean to be stupid with this but IBM has been NO help on this.

Thanks again for you patience.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic