The validation of required fields in web applications is important, and you have to do the same for mobile applications.
In this post I will show how you can validate required fields in Oracle MAF 2.0. To do this, I will use the application of this post: REST/JSON in MAF.
Download the sample application: MAFValidationApp.zip.
Open empEdit page.
Add the Validation Group component to validate required fields.
Go to Components panel > Operations, drag the Validation Group component and drop before the panelFormLayout component.
Set the property: id=”vg1″.
Go to Structure panel, drag the Panel Form Layout component and drop inside the Validation Group component.
Go to Components panel > Operations, drag the Validation Behavior component and drop inside the commandButton components.
Set the property: group=”vg1″.
For some inputText components (employeeId, lastName, email, hireDate and jobId), set the properties: required=”true” and showRequired=”true”.
To add a Validation Rule for firstName attribute, open DataControls.dcx file.
Expand EmployeesPojoDC, choose employee and click the pencil icon to edit.
In the Employee.xml file, click Attributes tab.
In the Attributes page, select the firstName attribute, click Validation Rules tab, and then click the green plus icon to add a new rule.
Deploy the application and enjoy!