cancel
Showing results for 
Search instead for 
Did you mean: 

Restrict the user to click on submit before clicking on another button

Former Member
0 Kudos

Dear All,

I have a requirement in my WDA Application.I am using two buttons here 1.Submit 2.Calculate.

Every time when user clicks on Submit button I have to force the user to click on Calculate button atleast once.

How can I achieve this?Pls suggest.

Thanks,

Reddy.

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

Create an attribute check in the context and in onActionCalculate method set the value to check to 'X' using set_attribute method.,

In OnActionSubmit method read the value of check using get_attribute method .

if lv_check = 'X'.

do the processing.

else.

display message to click calculate button first.

endif.

OR.

you can also play with enable/disable the button.

hope this helps u.,

Thanks & Regards,

Kiran

Former Member
0 Kudos

Thanks for all the responses.

I sholud not go for enable/disable because once the user clicked on calculate If I enable submit that dosn't satisfy my requirement.

Because my calculate button performing some calculation based on the user entered input.Suppose user is trying to click on submit I should provide a message or alert asking the user to click on calculate.

If it is one time operation I mean I can go for enaable/disable.

Let us say user changed the input field value and trying to submit the form then also I shud force the user to click on calculate.

Kris your suggestion is fine.But every time when I am clicking on submit It is displaying the message to the user to click on calculate even the the user clicked on the calculate once.This shud happen only once ,when user changes the input and try to click on submit again you shud display the alert to click on calculate.

After he is clicking on the calculate once I shud allow the user to click on submit with out any alert.

Thanks,

Reddy.

Former Member
0 Kudos

Dear All,

I am posting my code in order to provide clarity on my question.

I have declared a global attribute (flag) of type WDY_BOOLEAN in the component controller.

Here are My two actions.

ONACTIONCALCULATE:

data l_button_name type string.

l_button_name = wdevent->get_string( name = 'ID' ).

IF l_button_name eq 'CALCULATE'.

IF wd_comp_controller->flag NE 'X'.

wd_comp_controller->flag = 'X'.

ENDIF.

ONACTIONSUBMIT:

If wd_comp_controller->flag NE 'X'.

CALL METHOD l_message_manager->report_error_message

EXPORTING

message_text = 'Please click on the calculate button to check the Interest before proceeding'.

EndIF.

This code is working for the first attempt,That means If I click on submit without clicking on calculate

it will show a alert message.

But in the second attempt,let's say user has changed the input values(which are used for calculation)

trying to click on submit at that time it is not not showing any message.In this case also I am looking

for the message to be displayed.

Since there is no onchange event in WDA,I am not able to capture the changed value in the input fields.

Each time user changes the values in input fields I want the user to click on the Calculate button atleast once.

After that only I shud allow the user to click on submit button.

Please suggest how can I achieve this?

Thanks,

Reddy

Former Member
0 Kudos

Hi sudhir,

In ON_SUBMIT after displying message just clear FLAG value. I Think it will work for you.

ONACTIONSUBMIT:
If wd_comp_controller->flag NE 'X'.
CALL METHOD l_message_manager->report_error_message
EXPORTING
message_text = 'Please click on the calculate button to check the Interest before proceeding'.
EndIF.
clear wd_comp_controller->flag.

Cheers,

Kris.

Former Member
0 Kudos

Cool.It's working.Thanks for the solution.........

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Reddy ,

You can disable the submit button on the wdoinit and enable it in action for calculate button.

Initially Submit button is disable, when user click on Calculate then submit button will be enabled.

Regards

Kuldeep

former_member199125
Active Contributor
0 Kudos

hi sudhir,

I didn't understand your requirement, wht is the meaning of forcing to click on calculation button.

If you really want to perform calculation button action atleast once, then write calculation action in submit button action.

Pls rply with proper query if kissnas solution doesn't meet your criteria.

Regards

Srinivas

Former Member
0 Kudos

Hi sudhir,

You can identify which button is clicked by using this..

Use WDEVENT which is used to capture the UI element events that you have created on the View.

data l_button_name type string.
l_button_name = wdevent->get_string( name = 'ID' ).

case l_button_name.
when u2018button1u2019.
<Code>
when ' button2'.
<Code>
endcase.
using above , u will able to fetch the Button ID.

Create one attribute say FLAG in Component controller.

In second button action set this flag to X.

In any action or in WDDOMODIFYVIEW method write some code to raise error message.

If FLAG NE X.

Message.

Endif.

Hope it helps..

Cheers,

Kris.