File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes I want to submit the button but not refresh the page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "I want to submit the button but not refresh the page" Watch "I want to submit the button but not refresh the page" New topic
Author

I want to submit the button but not refresh the page

meera rao
Ranch Hand

Joined: Jun 30, 2005
Posts: 67
Hello,

I am stuck with a problem. I have 3 buttons,

<html:submit disabled="false" property="action" styleId="btn1"> Button 1 <html:submit>
<html:submit disabled="false" property="action" styleId="btn1"> Button 2 <html:submit>
<html:submit disabled="true" property="action" styleId="btn1"> Button 3 <html:submit>

When the user clicks the first button, it should disable the first button, enable the third button and also i need to pass to the java code which button is clicked.

I am using javascript to disable and enable buttons. but when i do this, it does disable the button, but also refreshes the page , so the button is enabled again.

and if it executes the javascript, it doesn't tell me which button was clicked, as when it refreshes the page, the button is unclicked.

Please help me solve this problem
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

I think I answered this in a different thread already.

Use html:button instead of html:submit on the buttons that you do not want to "refresh".


A good workman is known by his tools.
sudhakar Tadepalli
Ranch Hand

Joined: Dec 27, 2001
Posts: 130
Rao, You need to track enable or disbale value with scriplet. You can try decalring a property in the form bean as boolean or string and chek in in the jsp and pass the value to the html.

EX:

<% boolean tempValue = formBean.getClickedValue(); %> //Line 1

<html:submit disabled="<%tempValue%>" property="action" styleId="btn1"> Button 1 <html:submit>


When submitted you get the value and set it to the formBean in your action class, so when it comes to the same page your first line exceutes again and keeps the previous value. Hope it helps.

Sudhakar
meera rao
Ranch Hand

Joined: Jun 30, 2005
Posts: 67
Thanks a lot both of you. Marc you did tell me before, but I think i did somethign wrong then and it didn't work. I am sorry to bother you again, it works this time
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Originally posted by meera rao:
Thanks a lot both of you. Marc you did tell me before, but I think i did somethign wrong then and it didn't work. I am sorry to bother you again, it works this time


Ah, "it works": the words I love to hear!
meera rao
Ranch Hand

Joined: Jun 30, 2005
Posts: 67
I am sorry I posted the reply in hurry.

I used html:button, but i would also like to know which button was clicked, and this does not happen with html:button.

How would i know which button was clicked?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I want to submit the button but not refresh the page