• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Set a method when clicked on a hyperlink

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All

In my application user needs to delete a few messages from time to time.
So the user will have a check box to select the messages and then a hyperlink "Delete the selected messages".

I have 2 problems here.
1)When the checkbox is clicked the textarea with the message should be disabled.
2)The hyperlink "Delete the selected messages" when clicked on should set a method DeleteMessage in class Messages. I am using a function setMethod which would set the particular method when a related button or link is cliked on. The code for the funciton is give below.

How do I achieve these two tasks. Please advice.

<script>
function setMethod(method){
alert(""+method);
document.forms[0].method.value=method;

}
</script>

Thank you,
Dee Gee
 
Ranch Hand
Posts: 141
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The disabling can be accomplished using JavaScript OnClick() event.

regarding the hyperlink item:
It looks like you are on the right track. You've created a field to hold the value of the method call. At the end of your java script, submit the form - document.forms[0].submit()

Then modify your action class to handle the method field.
<code>
if(myForm.getMethod() == "deleteSelectedMessages"){
myBusinessObject.DeleteSelectedMessagesMethod(myForm);
// then forward me somewhere or back to that same screen...

}
else{
// do other stuff
}
</code>

or however you want to do it...
 
Dee Gee
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chris

Thank you.

I have another problem,
How do I call this method from an hyperlink?

Say "when I click on Delete selected messages I should be calling a method and not going to another page.
If the method executed successfully it would forward you to a new page.

Dee Gee.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic