In this Lesson
You will learn how to create a single-row agent that uses a datasource to maintain information in a database table.
Single row agents can be used to insert, update, delete, or view rows in a table. If you provide a datasource to the agent wizard it will create all the code needed to perform those operations.
You also have the option of generating an agent without a datasource and then coding the necessary behaviors yourself. This applies if you want to obtain information from something other than a relational database or if the agent is performing a process that does not require any information to be stored.
TipConsider generating single-row and multi-row agents as soon as you have your database tables defined. The agents could be used to improve the skin. You can then come back and add the advanced functionality in the agents as the design evolves.
Create a single-row agent
You will now create a single-row agent that provides full access to the Party table.
- Select the com.example.party.agent package and then open the agent wizard.
- Create a single-row agent named Party as shown here
- Create nodes for all the values in the datasource.
- Select a query for all 3 modes and the delete action.
Query SelectionThe query selection fields only display datasource queries that are appropriate for the mode or action. View displays only selectBy queries. Delete displays only deleteBy queries, and so on. The name that is displayed is the base query name of Party – as defined by the datasource.
TipYou can see the datasource used by this agent by selecting the Open Datasource button in the upper right corner of the agent editor.
- Assign the com.example.party.codelist.PartyTimes code list to the party start time.
- Assign the com.example.party.codelist.PartyTimes code list to the party end time.
- Build the agent
- The Agent view should indicate the build was successful
- Notice the Java classes that were created
Well done engineering team! You have given the design team something they can use to make their skin come to life.