cancel
Showing results for 
Search instead for 
Did you mean: 

I need to throw an error message if the terms&conditions checkbox is not checked on click of Submit Button. Can anyone suggest.

Former Member
0 Kudos

I need to throw an error message if the terms&conditions checkbox is not checked on click of Submit Button in webdynpro java. Can anyone suggest.

Accepted Solutions (1)

Accepted Solutions (1)

amolgupta
Active Contributor
0 Kudos

The simplest way- write the following code in the action of the Submit button-


if (<radio button not checked>)

{

wdComponentAPI.getMessageManager().reportException("Please accept Terms and Conditions to continue",false);

}

else

{

     continueExecution();

}


The exception message will be shown on top of the view.


You may like to use Message Area UI element and place it at the bottom of the WD4J view to show our exception message at the bottom of the view.


I hope this helps !


Cheers,

-Amol Gupta

Former Member
0 Kudos

I need to check for checkbox not radiobutton. Eventhough for checkbox, how can I write the condition for checking whether it is checked or not.

amolgupta
Active Contributor
0 Kudos

My Apologies. The simplest way- write the following code in the action of the Submit button-


if (<check box not checked>)

{

wdComponentAPI.getMessageManager().reportException("Please accept Terms and Conditions to continue",false);

}

else

{

     continueExecution();

}


The exception message will be shown on top of the view.


You may like to use Message Area UI element and place it at the bottom of the WD4J view to show our exception message at the bottom of the view.


I hope this helps !


Cheers,

-Amol Gupta

Former Member
0 Kudos

if(<check box not checked>) -->  I just want to know in brackets what do I need to write.

amolgupta
Active Contributor
0 Kudos

In WebDynpro Java, the UI is linked to the context. We manipulate(read from / write into) the WDJ ui by manipulating the context.

your check box must be linked to a context attribute of type "boolean". Simply read it in your code. Sample code(needs to be modified according your custom context structure) -

if (wdContext.getCurrentContextElement().getCheckBoxState() == false)

{

     wdComponentAPI.getMessageManager().reportException("Please accept Terms and Conditions to      continue",false);

}

else

{

     continueExecution();

}

//I am assuming that you have a context attribute named CheckBoxState of type boolean bound to your Check box UI element.

Also "wdContext.getCurrentContextElement().getCheckBoxState() == false" - check the correctness of braces by using auto completion as I have written this code manually and not checked it on the NWDS.

Former Member
0 Kudos

Thank You Amol

amolgupta
Active Contributor
0 Kudos

Hi M Sahithi,

My pleasure to help you out. Do update the the discussion as resolved, if it solves your problem !

Thanks and Regards,

-Amol Gupta

amolgupta
Active Contributor
0 Kudos

You may want to reflect the part of discussion that actually solved your problem as the correct answer. This will lead to points being awarded to the person who solved your problem and also reflect the correct answer to be displayed on top with the problem.

Answers (0)