aspose file tools*
The moose likes Struts and the fly likes How to make an Image click just like a Submit button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to make an Image click just like a Submit button" Watch "How to make an Image click just like a Submit button" New topic
Author

How to make an Image click just like a Submit button

Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
Hello,

I have a button which is a DHTML simulated button. I want to make that one like submit button (which will call the action-mapping).

But i dont want to use any href links.

Please give me an idea.

Thanks

Mahendran
sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
I have used in this manner

<html:image src="your.gif" property="submit" />

this will work for you..
Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
Thanks for replying Mr.Sreenivas,

I need to do a custom calendar for my project. It has all the months as a button aligning vertically. If i click one month for Example MAR then 1 table with 5 rows and 7 columns <td> and <tr> I have to generate.

The Question for me is I have multiple buttons should call the same action with a parameter to diffentiate it.

Would you suggest me any idea for this.

Mahendran.
sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
Hi Mahendran,

your idea is good,have a single action for all the buttons,call with different parameters.

Sreenivas
Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
Hi Sreenivas,

It is basically a table in which all <td> behave like a button.

But the problem i am facing right now is - How to link an onClick() method <td> to behave like a submit button in Struts.

I am not using any <html:link ...> inside.


Mahendran.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In HTML, the <td> element itself supports an onclick event.


Merrill
Consultant, Sima Solutions
Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
Hi Merrill Higginson

Thanks for the reply,

Could you sent me any examples or links where onClick() behaves like a submit button (should call the actions in struts).

Mahendran A
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864

[ March 06, 2007: Message edited by: Merrill Higginson ]
Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
Hi Merrill Higginson,

Thanks for your code snippet,

I have another doubt.

In my project I have Security constraints in Web.xml (such as roles and usernames etc). So my question is whether this will block the javascript code.

Mahendran A
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The server will treat a form submitted with JavaScript no differently than a form submitted with a standard submit button. All the server-side code knows is that a form was submitted. It will therefore use the same rules to determine whether a user has access to a given action or not.
Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
Thanks Merrill

It was a wonderful comment.

Mahendran A
 
Consider Paul's rocket mass heater.
 
subject: How to make an Image click just like a Submit button