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

standard html submit and do_handle_event

Former Member
0 Likes
1,119

I have created a BSP application based on the MVC model.

my application ontains one view and one controller.

the view contains au sumbit button within a form :

all my view is written in the standard HTML (no HTMLB code).

My problème is that i can't get the event in the DO_HANDLE_EVENT methode.

could anyone help me.

Thank you in advance.

View Entire Topic
athavanraja
Active Contributor
0 Likes

give the 'name' property a value like

name="onInputProcessing(goto_next)" .

Now you can use oninputprocessing something like

if event_id = 'goto_next' .

      • do something

endif .

Former Member
0 Likes

Thanks.

Former Member
0 Likes

Sorry, I do not see the point.

I tried to apply and did not get the

exspected result!

How do you get the HTML form fields

by using MVC within DO_HANDLE_EVENT or

DO_HANDLE_DATA?

Kindly regards

Jörg Hoffmann (joerg.hoffmann@mummert.de)

laxminarayan_s
Associate
Associate
0 Likes

Answer is already there from durairaj. All you need to do is define a (hidden) field with the name onInputProcessing. Sample code

<form name="test" method="post">

<input type=hidden name="onInputProcessing(my_event)">

put in all your form fields here

<input type="submit" onclick="submit">

</form>

On your do_handle_data, you already have form_fields parameter from which you can get all the form fields.

On your do_handle_event, you have the event parameter where in you can capture the event performed. In the above case the event would be "my_event".

Hope this helps.

Former Member
0 Likes

Hello All,

I am new to BSP/MVC development but has fair experience in J2EE and some ABAP programming. My question is if we want client side validations on page submit how to code that. In traditional HTML-JSP following code works

<form name="frm1" action= "test.jsp" onSubmit = "return testsubmit()">. If JavaScript function returns false the form does'nt gets submitted. However over here if we call JavaScript function onClientClick it passes event to DO_EVENT_HANDLE method. Can anyone tell how to use JavaScript along with BSP/MVC or is there any other way.

Thanks in advance.

Thanks And Regards

Rajeev Patkie

Former Member
0 Likes

Hello Rajeev-

You can always implement a JavaScript based client-side validation before your BSP form takes 'any' event-driven action.

You can declare your <page language> as ABAP and your <script language> as JavaScript. Just envelope your JavaScript validation within the <script> tags and then after validation, pass your form to the DO_HANDLE_EVENT method in MVC or onInputProcessing method in non-MVC.

- Vik.

Former Member
0 Likes

Hey Durairaj,

Isn't onInputProcessing() a non-MVC event handler?

Isn't this particular question about an application that is conformant to the Object Oriented Design Pattern?

I am curious how you would invoke onInputProcessing() on an HTML view that is without flow-logic?

- Vik.

Former Member
0 Likes

Hello Vik,

Thanks for your help. But can't understand how to pass a form to DO_HANDLE_EVENT. I am having one Save Button defined as:

<htmlb:button id="Save" text="Save" tooltip="Save the above entries" design = "EMPHASIZED" onClick="Save" onClientClick="validateVal()" />

I am calling validateVal() javascript method to perform validations. If something is wrong the method returns false else true. What is happening is even if method returns false DO_HANDLE_EVENT gets called.Can it be done in such a way that if the javascript method returns false the DO_HANDLE_EVENT method is not getting called else it should get called.

Thanks in advance.

Thanks And Regards

Rajeev Patkie

Former Member
0 Likes

Rajeev-

The whole idea behind the model-view-controller object oriented design pattern is to decouple the application event handling and flow logic from presentational directives.

Meaning, the view (.html) page is merely a shell to display output and provide the form for taking-in input. In the MVC OODP, any and all real event/data handling has to take place in and by the controller.

So in your case, I would still handle the event in the controller, but I would pass different values (through the JavaScript validation) to the controller. In the controller you can set up conditional logic to do one thing or another.

Does this sound right to you?

-Vik.

Former Member
0 Likes

Hello Vik,

I do agree with you that MVC is meant to decouple the application event handling and flow logic from presentational directives.

But in my case there are about 40 user entry values in which many of them are numeric.So imagine everytime all the data would be passed to server(once the form is submitted all the values will be passed to the controller) and validated and again send back to the browser.

Again could'nt understand the concept of passing parameters from JavaScript to controller class. If as such we are passing the data to controller, we can validate that in controller itself and revert back the appropriate messages through JavaScript to the browser.

Anyways very much thanks for your help.

Thanks And Regards

Rajeev Patkie

Former Member
0 Likes

Hi Rajeev-

What I mean is quite simple, really. I have a BSP web application that is also built in conformance to the MVC object oriented design pattern.

In one of my views, I have a button that has some JavaScript actions performed on it before its processing is taken up by the controller.

When I was developing the code behind this button, I did not need to do any specific coding to have JavaScript be executed first and then the DO_HANDLE_EVENT method. All I did was associate the client-side JavaScript code to that button and then also wrote some BSP code in the method DO_HANDLE_EVENT.

In my application, the client-side JavaScript code ran first and then passed the processing handle to SAP Web Application Server. This native precedence of processing eliminated any need for me to write my client-side JavaScript any differently then I would have if my application was non-MVC.

Hope this helps.

Thanks,

- Vik.

Former Member
0 Likes

Hello Rajeev-

What you might want to do is to specify another attribute in your <HTMLB:Button> called onClientClick.

onClientClick defines the JavaScript fragment that is executed when the user clicks on the button.

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.

Hope this helps you out.

- Vik.

Former Member
0 Likes

Hello Vik,

Exactly same thing I want but did'nt know how to cancel onClick event through Javascript.Please do let me know how to cancel the same.

Anyways thanks for the reply.

Thanks And Regards

Rajeev Patkie

Former Member
0 Likes

sorry, I was too quick

Message was edited by: Marco Nickel

former_member181879
Active Contributor
0 Likes

FAQ updated on this.

<b>BSP Trouble Shooting: Frequently Asked (Short) Questions</b>

/people/brian.mckellar/blog/2003/10/23/bsp-trouble-shooting-frequently-asked-short-questions