cancel
Showing results for 
Search instead for 
Did you mean: 

Form Data Validations

Former Member
0 Kudos

Imagine there is a field called "Username" ,"Password" and "Submit button".

I want to implement following validations on click of "Submit" button.

1 . Please enter Username.

2. Username should have a length of 10 characters.

3. Please enter Password.

I want the validation procedure in 2 ways.

1. The process of validation by indvidual criteria

Example:

displaying each validation message by validating all bussiness criteria one by one.

That is in the above "Username" will be validated first.

If user enters value it will check for number of characters less then 10.

If this is passed then need to check for password entry.

2. Validating complete form at once

Validating complete form for all bussiness conditions and displaying them at once.

Please provide any links for data validations.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hey Raghu,

you can implement a method like checkFields() in the "@@begin others" part of your view which returns a boolean value. When you press the "SUBMIT"-button it is checked whether every mandatory field is filled with the correct data. There you can implement the logic of your query.

Here is an example for the method <b>checkFields()</b>:

/** Checks whether the mandatory input fields are filled with regular data. */

private boolean checkFields()

{

if ( wdContext.currentFreightrequestElement().getTitleInputField() == null ||

wdContext.currentFreightrequestElement().getTitleInputField().trim().length() == 0 )

{

wdComponentAPI.getMessageManager().

reportContextAttributeMessage(wdContext.currentFreightrequestElement(),

wdContext.nodeFreightrequest().getNodeInfo().getAttribute(ATTRIBUTE_TITLE_INPUT_FIELD),

IMessageFreightRequestComponent.ERROR__01,

null,

false);

return false;

}

........

}

The important thing is the <b>reportContextAttributeMessage()</b> which highlightens a field you want to check.

-


In the action-part you can use parts of the following code:

boolean success = false;

if ( checkFields()) {

success = wdThis.wdGetRequestComponentController().executeSave();

}

if (success == true)

{

IWDControllerInfo controllerInfo = wdControllerAPI.getViewInfo().getViewController();

String dialogText = wdComponentAPI.getTextAccessor().getText("TEXT_03");

IWDConfirmationDialog dialog =

wdComponentAPI.getWindowManager().createConfirmationWindow(dialogText, controllerInfo.findInEventHandlers("createNewRequest"),wdComponentAPI.getTextAccessor().getText("TEXT_04"));

dialog.addChoice(controllerInfo.findInEventHandlers("returnToWelcomeView"), wdComponentAPI.getTextAccessor().getText("TEXT_05"));

dialog.setTitle(wdComponentAPI.getTextAccessor().getText("TEXT_02"));

dialog.show();

}

So far,

Domingo