This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Struts and the fly likes html:button Struts jsp code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:button Struts jsp code" Watch "html:button Struts jsp code" New topic
Author

html:button Struts jsp code

Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Hi All,
I have been looking online for jsp code examples using the struts tag <html:button> but can find very few mentions of it. Is this because it is not used much? Is there a better tag to use if I have a page with 4 buttons, each which will redirect the user to one of 4 differant pages?
Thanks for any ideas,
Kim
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30405
    
150

Kim,
A google search turns up quite a few examples. The first one is excellent.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Thank you for your reply. I am actually interested in buttons which when clicked will redirect the user to another jsp, not radio buttons. I have googled html:button but didn't find much about non-radio buttons. Any other tips very appreciated.
Kinjal Sonpal
Ranch Hand

Joined: Jun 06, 2003
Posts: 96
Originally posted by Kim Kantola:
Thank you for your reply. I am actually interested in buttons which
when clicked will redirect the user to another jsp, not radio buttons. I
have googled html:button but didn't find much about non-radio buttons. Any
other tips very appreciated.

If you are not really allergic to a mix of JavaScript and struts-tag, then
it's possible like this.

This will allow you to fire form submission based on some dynamic
condition. If you need a simple link kind of effect (no form submission),
then, document.location="<html:rewrite ... />" can do the trick.
And then the place, wherever you require a button,

I use this to provide more than one Actions for a single form. Please note that Click, here, is intentionally misspelt to pass through the forum posting. It does not allow html codes.

HTH.

Thanks and regards,
Kinjal Sonpal
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

A method without javascript:

If the buttons all have different text, you can give them all the same name and have your action match up the text of button with your forward.

If any of the buttons contain the same text (ie all say "Edit"), then you must give each one its own name with getters and setters for each. There are a multitude of tricky things you can do behind the scenes in your form and action to determine which button was clicked and which forward to use. Google should help find some.


A good workman is known by his tools.
Kinjal Sonpal
Ranch Hand

Joined: Jun 06, 2003
Posts: 96
Originally posted by Marc Peabody:
A method without javascript:
If the buttons all have different text, you can give them all the same name and have your action match up the text of button with your forward.

If any of the buttons contain the same text (ie all say "Edit"), then you must give each one its own name with getters and setters for each. There are a multitude of tricky things you can do behind the scenes in your form and action to determine which button was clicked and which forward to use. Google should help find some.

Hmmm... Very interesting way. I never realised this. One more thing Mark. I'm using DispatchAction for this. As you can guess, I'm using JavaScript code to determine, which method of DispatchAction should be called and accordingly I attach the value for the query parameter. I'm not getting a clearer idea as to how the above metioned way can be implemented. Please throw some more light on this.

Thanks and regards,
Kinjal Sonpal
[ June 03, 2004: Message edited by: Kinjal Sonpal ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: html:button Struts jsp code