• Post Reply Bookmark Topic Watch Topic
  • New Topic

Data Population on PageLoad

 
John Vergis
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65520
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65520
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks for your help
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65520
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool. If you run into trouble coding it up, post back.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!