In this Lesson
You will
- Create a single-row agent for the PartyTheme table
- Install a data validation in the agent
Concepts
Up to this point you have performed all data validations in the datasource’s validation pack. There are times when it is not appropriate to install validations in the datasource because the datasource does not have all the information needed to perform the validation.
Data validation can also be performed in an agent. This lesson will ask you to install a validation in an agent so that you can see how it is done.
Create a Single-row Agent
- Select the com.example.party.agent package and then open the Agent wizard
- Create an agent named PartyTheme as shown here
- Select all datasource values
- Provide a query name for view, change, and add modes.
- Build the agent
- Install a validation requiring the party theme to be provided
- Open the PartyTheme.java file
- Open the Override/Implement Methods dialog
- Select the validate_PartyTheme method
- Add the following syntax to the end of the validate_PartyTheme method.
//a theme must be provided if (!hasContent(scheme.getPartyTheme())){ node.setMessage(error("A theme is required")); }
- The validate_PartyTheme method should now look like this
- Open the PartyTheme.java file
- Save the PartyTheme.java file.
End of lesson.