Skip to content

Lesson 3 companion — Controls, validation and feedback ​

Guided lesson · Assignment

Use this page to understand the employee form and adapt it to the assignment's second required field. Your form checks control values; it does not create an employee record yet.

1. Read a control's public API ​

ConceptExampleMeaning
PropertyInput.valueA setting or value held by the control.
AggregationPage.contentChild controls owned by a parent.
AssociationLabel.labelForA reference to another control.
EventButton.pressA notification that an interaction happened.
MethodInput.getValue()An operation callable on the control.

Open the API for the actual control you are using. Input provides getValue(); Select provides getSelectedKey(). Methods inherited from a base class are still available.

2. Find a field through its View ​

javascript
const oInput = this.byId("employeeNameInput");
const sName = oInput.getValue().trim();

this.byId uses the local XML ID. UI5 handles the View prefix. Avoid browser DOM lookups for ordinary control behavior.

trim() cleans the value you use for validation and feedback. It does not itself rewrite the visible Input. To change a control value in this lesson, call its setter; in Lesson 4, the model and binding take over that role.

3. Trace validation and recovery ​

The guided lesson handler follows this sequence: read → trim → check → report an error or success. On failure it sets a field error message and returns focus to the field. On success it clears the old error state and reports Details valid.

StateField behaviorResult feedback
InitialEmpty Name; Department IT.Not checked.
Invalid checkError state, useful message, focus on Name.Name required.
Valid checkError state cleared.Details valid and a toast.
ClearInitial values restored.Not checked.

The assignment extends this to Name and Job title. Check both fields before deciding to return, otherwise a first-field error can prevent the second field from being checked. Move focus to the first invalid field in form order.

The status reports the last check. Editing a value afterward does not automatically validate it; select Check Employee again. Clear should work after both success and failure.

4. Make the form understandable ​

xml
<Label id="employeeNameLabel"
    labelFor="employeeNameInput" text="Name" required="true" />
<Input id="employeeNameInput" placeholder="Enter employee name" />

A label names the field; a placeholder provides a hint. labelFor associates them for interaction and assistive technology. The required marker communicates a rule; the Controller enforces it.

SimpleForm handles responsive placement. The action HBox wraps its buttons. Verify the narrow layout and keyboard actions yourself; using responsive controls is a starting point rather than proof that a finished screen is usable.

5. Avoid these common mistakes ​

MistakeCorrection
Treating spaces as a valid nameTrim before checking emptiness.
Leaving a corrected field redSet its value state back to None on the next valid check.
Using a placeholder instead of a labelKeep an associated visible Label.
Calling the action SaveUse Check Employee because nothing is persisted.
Resetting only visible textReset values, value states, result status and focus consistently.

6. Check yourself ​

Why can an Input have a required label and still accept an empty value?

Compare your explanation

The required marker communicates the requirement. Your validation logic must reject the missing value, explain the problem and prevent the success path. For two required fields, each needs its own check and feedback.

7. Recover and continue ​

Use the completed Lesson 3 checkpoint to compare the one-field guided lesson form. The assignment adds Job title in a separate working copy. Lesson 4 starts from the guided lesson form and introduces model-based data entry.

8. Official documentation and examples ​

SAPUI5 references use 1.148.12. References checked on 15 November 2026.

ReferenceWhat to look up
Input APIValues, events and inherited value-state methods.
InputBase APIError states and explanatory value-state text.
Label APIlabelFor and the required marker.
Select APISelected keys and item choices.
SimpleForm APILayout properties and the control's Samples tab.
SAPUI5 ARIA labeling guidanceOfficial label and field association examples.
SAP Fiori design guidelinesInterface design and control usage guidance.

Independent learning materials for SAP frontend development.