• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

I want to submit the button but not refresh the page

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic