• 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

mentioning actions twice in struts-config

 
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

My specs suggest two actions for one JSP, may i know why should i write like that?

ex:

sample diagram is like this:

|----- showCustomerPaymentDataChangeStart.do
| |
fail |
| JSP Name here
| |
| |{logged_in}
| |
-------- CustomerPaymentDataChange.do


may i know what is the use of writing the actions twice in struts-config.xml file.

regards,
rahul
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most JSPs require some sort of preparation before they can be displayed such as populating lists for dropdown boxes, getting user information from a database, etc. If the JSP contains an HTML form as most do, there is also an action that must be taken when the form is submitted. Hence, there is often a need for two actions for every JSP: One to prepare for the display of the JSP, and one to process the information entered by the user in an HTML form.
 
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
2 different actions - 2 different entries.
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Merrill Higginson:
Most JSPs require some sort of preparation before they can be displayed such as populating lists for dropdown boxes, getting user information from a database, etc. If the JSP contains an HTML form as most do, there is also an action that must be taken when the form is submitted. Hence, there is often a need for two actions for every JSP: One to prepare for the display of the JSP, and one to process the information entered by the user in an HTML form.



can i get a simple example for this please?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Form bean:

Action classes:

struts-config.xml

ColorSelect.jsp

ColorResult.jsp

[ June 20, 2007: Message edited by: Merrill Higginson ]
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks alot Mr. Merrill Higginson
this example is a very good example

regards,
rahul
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
found a problem in Mr. Merrill Higginson code.

after running this code implementing the back and next buttons.

when i use back button from the last jsp to privious jsp, the value I select from the list is not appearing.

May i know what should i do to solve this problem.

and the big question is if I have more than one list box which should always show the selected iteams whn i come back from the other pages i think this code has to be modified.

please suggest me
regards,

rahul
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear in mind that this code was written as a simple demo, not a complete application. It has no database persistence, which is something you'd naturally want to put in an actual application.

In order to have the value selected retained, you would have to actually save the value to a database and then retrieve it when the page is redisplayed. In the example, you would add the following lines to the PrepareColorAction class:

You'd then add the following code to the ProcessColorAction class:
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you very much Mr. Merrill Higginson for your indetailed reply.

And it seems we are supposed to create an onther class which gets and sets color. I think, even though UserDao is not a form bean it resembels like it.


Thnks and regards,
rahul
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic