Forum Stats

  • 3,783,408 Users
  • 2,254,768 Discussions
  • 7,880,383 Comments

Discussions

Calling Java Clas method from OnClick event on InputText

machan
machan Member Posts: 174 Blue Ribbon
Hi,

I want to call a method in the java class from the OnClick event on an inputtext. Is this possible.

Actual task is - to clear the value in the textbox onClick. If I use the script ----- onclick="this.value=''; ----- the value at the client page gets cleared but server side value in the java class stays. I want to clear the value in the java class variable as well.

Please let me know if this can be done.

Thanks.

Answers

  • 829740
    829740 Member Posts: 10
    Not possible to do, with any set method.

    What you could do is:
    Write a javascript method that you call when the button is clicked.
    This javascript method, sends an ajax call to a server side component.
    The server side component then calls the method on the class.
  • 907941
    907941 Member Posts: 3
    When form is submitted to servlet, your input parameter is null. So in servlet you can check a simple condition and set its mataching class data member to null.
    Is that correct or i didnt understand your post correctly.
This discussion has been closed.