• 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

link another jsp page when button clicked- how- help urgent

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
I have a form with 3 buttons on my jsp. in struts config i have put the <forward name="validate" path"/validatefile"/>

validatefile path is to go to another action-jsp.
is something wrong?
the name is name of button on jsp. In actionclass i have just execute method. when user clicks on button1 how do we take him to another jsp?
 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the button part of a form?

you need an html:form tag with an attribute action="yourActionPath"
or alternately an html:link with an attribute action="yourActionPath"

the action path should take your program to an action class where processing is done then after that action class returns a value which determines what jsp or page definition you go to next (these are the forward tags nested inside the action tags in the struts-config file).

This pretty fundamental to the way struts works, form/link submission -> action class -> page/jsp(with forms/links) -> action. Just all the parts represented by -> are maintained inside the struts-config.

I'd recommend spending 2-3 hours just reading a book/website.
 
Liz Brown
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok. Do i need to put any code for each button in action class?
Or just forward tag in struts will take name of button and path to the action or jsp i mention.
I have got it until here, however i am not sure if i need to add code to hnadle each button in actionclass.
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depends on what each button is doing. Is each button assocciated to the same form? or same link? If each button is associated to its own form then each one will have its own action class. However if all three buttons are associated to the same form/action you need to do something that will let your action class differentiate between which one was pushed (assuming you want them all to do different things). For me the easiest thing to do was add a hidden field to the form who's value I changed with javascript to denote which button was pressed (and then submit the form).

-Tad
 
Liz Brown
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
page 1 has 3 buttons, each should go to different paths(action-form-jsp)

can you please tell me more about button names and forward action if i have to write in struts-config.

Example:
I have 3 buttons each are submit type and if I have different names for them. How do we generally wrtie this code to mention these buttons with struts tags and html:link ? can I do this way mentioning in struts-config.

Do we generally write any methods inside action class to foward the buttons to another path?
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps the LookupDispatchAction can help you. with this Action you can specify for each form-button a separate method to be called in an ActionClass (must be inherited from LookupDispatchAction).

http://www.jguru.com/faq/view.jsp?EID=900642

http://husted.com/struts/tips/003.html
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic