• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Liz Brown
Ranch Hand
Posts: 112
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Tad Dicks
Ranch Hand
Posts: 264
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Florian Kammermann
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic