• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Data Population on PageLoad

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a requirement where i want my primary field[Prod Id] in the form (in JSP) to be populated at page loading time.. i.e the value of the field has to be fetched from the database (Max Value of Prod Id +1 ).. This form is used to create a new product , The Prod Id is pre-populated and is a read-only field.. the other values are to be entered by the user.

What is the best approach in getting the data.

Thanks
John.
 
Sheriff
Posts: 67590
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
Your servlet controller should cooperate with a "model" class to obtain the value from the database. Is this the part you are havng trouble with?

Once obtained, the value can be placed on the request as an attribute (aka scoped variable). The controller forwards to the JSP page which uses the scoped variable to fill in the value attribute of the form element.

It's not clear which part of this process is giving you problems.
 
John Vergis
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
The scenario was for creating a new product, when the user clicks on Create New Product, it was forwarded to the JSP page where the fields were supposed to be entered, and i had no idea how to populate the Product Id,

Now I feel it would be better if instead of forwarding to the JSP Page... on clicking on Create a new Product, call the servlet which will set the product id value in the request and forward to the JSP page where i can fetch the value and set it in the Prod Id field

Any suggestions
 
Bear Bibeault
Sheriff
Posts: 67590
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


I suggest that this is a good approach. What more are you looking for at this point? I assume you have the means to get the infor from the DB?
 
John Vergis
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help
 
Bear Bibeault
Sheriff
Posts: 67590
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
Cool. If you run into trouble coding it up, post back.
 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic