cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Difference between manual and JavaScript button click

CarstenKasper
Active Contributor
0 Likes
1,408

Hello folks,

I hope this threads fits this forum. It strongly related to the WCUIF but also JavaScript.

The setting:

I got a view that is displayed in a DIV container. This view got a standard <thtmlb:button> which is triggering a round trip when pressed.

When I press the button manually by mouse a correct server roundtrip is done. Delta Handling takes care that only this one view is refreshed. Everything is wonderful.

Now the issue:

I need to "press" this button using JavaScript. It is no problem to get a handle to the correct button and JavaScript provides two methods focus() and click() to call both JavaScript functions that are triggered when the button is pressed manually.

The coding looks like this


var button = getElementById('Id of my button');
button.focus();
button.click();

Now a server roundtrip i done, but it seems to be a roundtrip for the whole WebClient. Even worse: The UI freezes with the spinning "Please Wait..." showing.

Does anybody know how to do a correct, delta handled round trip that is invoked not by the user but JavaScript?

I already tried putting and calling the bsp:htmlbEvent. It behalves like the button described above.

Thankful for any pointers!

cheers Carsten

View Entire Topic
CarstenKasper
Active Contributor
0 Likes

Another day of debugging solved the problem.

When using the thtmlbAjaxRequest do not start another request while you are still in the result handler of the first. Put the button.click() in another function and everything works as expected.

cheers Carsten!

Edited by: Carsten Kasper on Sep 29, 2010 5:19 PM

Former Member
0 Likes

Hi Carsten,

I am also trying the same thing but not been able to trigger the event programatically. below is my code:

<bsp:htmlbEvent name = "fireEvent"
                 id   = "fireEvent"
                 p1   = "p1"
                 p2   = "p2" />

<thtmlb:button id            = "mybutton"
     text          = "Submit"
     onClientClick = "sessionexit( );" />

<script language="javascript" type="text/javascript">
        function sessionexit( )
      {

          var button = document.getElementById("<%= controller->component_id %>_mybutton");
          button.focus();
          button.click();
          return fireEvent('Submit');
      }
</script>

Could you please give me some heads up on this? Thanks for your help.

Regards,

Ashish

CarstenKasper
Active Contributor
0 Likes

Hi Ashish,

if I remember correctly, it is almost 2 years by now, for me the problem was that I tried to trigger the server roundtrip in a handler method automatically called by the THTMLB Ajax library. This does not work. Do not know why exacatly, it just doesn't.

Solution in my case:

Set a helper variable in the ajax handler and call an additional method with window.setTimeout() to trigger the roundtrip.

As I switched customers a while ago, I do not have access to the system where this issue was solved to recheck.

cheers Carsten