• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Struts Question from beginer

Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am learning struts and need help is doing the
I have one jsp display.jsp which shows name and
descritpion with a check box to select one name,
When the user selects one name and presses change i
want to display a change.jsp with all the info about
that name (name is key) and allow the user to modify
data (excpet name) and then when the user presses okay
validate amd update the database, if there is problem
display error.
I have done soome thing to add a new name, but for
change i need to get the data from database and
populate the fields to display, and then get the
updated fields
I need to know how to write a bean and map it to text
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For every form in your webapplication, you have to write a corresponding formbean of the ActionForm type. In your actionmapping you define a formbean and an action and link them together, etc. When the jsp page is loaded, that contains the <html:form... tag with the specified action, the form has a reference through the action to the corresponding formbean. The values of the properties of the formbean are then already loaded and set at the corresponding formcomponent (textfield, etc.). When the page is requested directly, the properties have default Java values (Strings are null and will result in empty textboxes, etc.).
What you need to do is the following: before you request the jsp page, you should write an Action that loads the data from the database. You create an instance of the specific formbean and set the relevant properties (the values that have to be displayed in the textfields). Then you have to add the instance of the formbean to the requestscope of the forwarded page, the actual jsp page, using the keyname that matches the name of the formbean in you actionmapping.
Jeroen Oosterlaar
[ January 11, 2003: Message edited by: J.H.B. Oosterlaar ]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic