cancel
Showing results for 
Search instead for 
Did you mean: 

Server-side eventing

Former Member
0 Kudos

Hi

I know it is possible to do server-side eventing through htmlb, and client-side eventing with EPCF. But how can you manually call server side methods from for example a simple html link onClick event?

thx

Hans

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Hans,

you are right using HTMLB you have got two possibilities to realize eventing.

- client side eventing

- server side eventing

To trigger client-side eventing you use the method onClientClick. All interactive HTMLB GUI elements like buttons or links have this method. Basically, you specify the name of a javascript function that shall be execute when the user clicks on the GUI element. Client-Side eventing works without a request to the server.

To trigger server-side eventing you use the method onClick. Again all interactive HTMLB GUI elements have this method. Basically, you specify the name of a Java method (part of your portal component) that shall be execute when the user clicks on the GUI element. Of course, this time you initiate another server request.

Example using the classlib:


Form form = (Form)this.getForm();Button button = new Button("button", "button");button.setText("Confirm");
button.setWidth("125px");
button.setTooltip("Click here to confirm order");
button.setOnClick("ProcessConfirm");
button.setDisabled(false);
button.setDesign(ButtonDesign.STANDARD);
form.addComponent(button); 

In the example you are using server-side eventing. If the user clicks the button a server request is for your portal component is executed. Of course you have to define a method "ProcessConfirm" or "onProcessConfirm" in your portal component. If there is no such method the request will fail.

If both events ('onClick' and 'onClientClick') are specified, the 'onClientClick' event handling method is activated first. By default the 'onClick' event handling method is activated afterwards. In the JavaScript fragment you can cancel the activation of the 'onClick' event handling method with the command

htmlbevent.cancelSubmit=true;

The 'onClientClick' event is useful to preprocess the form and only send the form to client if the preprocessing was successful (e.g. date validation, valid number format etc.) to save client/server interaction.

You will find lots of information about HTMLB on the website of <a href="http://www.sapdesignguild.org/resources/htmlb_guidance/index.html">SAP Design Guild</a>

Best regards,

Martin

PS: Please reward points if you found that answer helpful