cancel
Showing results for 
Search instead for 
Did you mean: 

Enabling of button only once the mandatory field are filled

Former Member
0 Kudos

Hi,

I am having a requirement where i have a form with 4 fields which are mandatory and one non-mandatory and a SAVE button.I want the save button to be enabled only once all the mandatory fields are filled.So that it get saved in a table.

I have created a context attribute buttonEnabled of the type boolean also added the method to the view.

Now i can see the below method in the view java editor.

public boolean buttonEnabled( ) {

//@@begin buttonEnabled()

return false;

//@@end

}

How should i go about with checking whether the mandatory fields are empty or not.

Request Help..

Regards,

Suvarna

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Suvama,

Instead of enabling button after giving data for all 4 mandatory fields it is better to validate the 4 mandatory fields data after clicking the Save button.

Thanks

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Suvarna,

If you want to check that all the Mandatory fields are filled then an event should occur when you fill the last mandatory field or the last field on the view. There is a onEnter event for InputField UI element so that when you fill any data in the input area and press enter an event occurs.

So just declare Boolean attribute in the context and and bind the attribute to the enabled property of the button.

So when the user enters the data in the last mandatory input field and presses enter, the onEnter event will occur and in the that event handler check if all the mandatory fields have been filled and if the validation is true set the context attribute value as true. The button will get enabled.

Hope this solves your problem.In case any problem please revert back.

Regards,

Ardhendu.

Former Member
0 Kudos

Hi All,

Thanks for the suggestions!!!

I did validations for my fields and kept the button enabled itself.

Regards,

Suvarna

Former Member
0 Kudos

Hi,

As per my knowledge client side validations are not possible in WebDynpro for Java.

Validation can be done at server side. So for server roundtrip we have to trigger an action.

So without any action you can't control your button enable/disable property through context attribute.

So my suggestion is:

Enable that button all the time.

When user clicks on that button then do the validation for mandatory fields one by one.

If he did not enter value for any mandatory field then you can stop processing your save functionality and you can display the validation message like "Please enter all the mandatory fields".

Regards,

Charan