Skip to Content
avatar image
Former Member

How to invoke a onClick call to JSP method from Javascript

Currently developing in the JSP Dynpage model in EP 5, but will also be developing in EP 6, once we get our hands on the installer.

My Question is, with the above environment, how do you force a call to the JSP method from a javascript call, in the case where you are using Client Side eventing, and want to mimic a Button Click, etc...

In the JSP page I have a HTMLB button defined as

<hbj:button id='Load' text="Load WorkBench" onClick="clickLoad" onClientClick="Validate()"/>

and the method clickLoad is in my Dynpage to handle when the user clicks on it.

I also know how to cancel the submit process of the button click in a call from the Validate() function with:

htmlbevent.cancelSubmit=true;

But, if I was in a seperate javascript function that is subscribed to some client event, how would I make the iView call that method clickLoad, as if the user clicked on that button. Also, would like to know how to do this genericly and not just for a button. It was the easiest way to explain it using a button.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jan 21, 2004 at 12:44 PM

    If I understand your question, you would need the listener iView to invoke submit() on the form of the iView that has the "clickLoad" Dynpage event handler.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Jorge,

      I'm curious to know if you were able to get this working based on Will's suggestion to invoke the submit() object.  I've been encountering the same issue you are describing and am looking for a solution. I tried Will's solution, but I couldn't get it working. If you got this working, I would be interested in seeing a code example if possible.

      Thanks,

      Kevin

  • avatar image
    Former Member
    Mar 03, 2004 at 08:18 PM

    One method that did work was to add an htmlb element into the page, that has an onClick event, such a button. Set it to be invisible via stylesheets, then trigger the client button click via javascript.

    You will then be able to have the server side event handler kick in, and do whatever is needed.

    Hope that helps.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Jorge,

      How can we trigger the client button click via javascript.

      Can you please share the code, if you were successfull in doing it.

      Thanks,

  • avatar image
    Former Member
    Mar 05, 2004 at 10:23 PM

    Vivek,

    If you don't want to button to show, you can hide it in a span with the style-sheet with similar code below:

    <SPAN STYLE="visibility: hidden">

    <hbj:button id='buttonEvent' text="" onClick="clickEvent"><% strbuttonEventId = yourContext.getParamIdForComponent(buttonEvent); %> </hbj:button>

    </SPAN>

    You can then trigger the button's onClick event via Javascript call such as:

    document.all.<%=strbuttonEventId%>.click();

    This should work fine, and i've used the above solution for the trigger of the event.

    Add comment
    10|10000 characters needed characters exceeded