Creating a new delegate object
Creating a delegate object and associating it to an entity is a relatively straightforward process. It does involve multiple steps, as do many changes to the data model. To create a new delegate, you need to do the following:
Task |
Description |
More information |
|---|---|---|
Step 1: Create the Delegate Object |
Define the delegate
entity using the |
|
Step 2: Define the Delegate Functionality |
Create a Gosu enhancement to provide any functionality that you want to expose on your delegate. |
|
Step 3: Add the Delegate to the Parent Entity |
Use the |
|
Step 4: Deploy your Data Model Changes |
Deploy your data model changes. You may need to regenerate any Java API file or web service WSDL files after data model changes. |
Applicability of base configuration delegates to custom entities
In some cases, Guidewire recommends that custom entities not implement base configuration delegates. To ascertain these cases, identify whether the delegate implements an interface designed for internal useage only. If the base configuration delegate implements an internal interface that is for only internal entities, Guidewire recommends against reusing the delegate.
Instead, create a delegate similar to the base configuration delegate. In addition, create interfaces similar to the interfaces that the base configuration delegate implements. Implement these new interfaces as needed.
An example of a delegate that Guidewire recommends against reusing for custom entities is the Approvable delegate. The Approvable delegate implements the ApprovableInternalMethods interface and indirectly implements the ApprovalHandler interface. Guidewire intends these interfaces for internal usage. The interface implementations are intended for base configuration objects.
Instead of reusing the Approvable delegate, Guidewire recommends creating another delegate similar to the Approvable delegate. In addition, create and implement the interfaces that the new delegate requires.
Step 1: Create the delegate object
About this task
The first step in defining a new delegate is to create the delegate file and populate it with the necessary code.
Procedure
- In Guidewire Studio, in the Project tool window, navigate to .
- Right-click Entity, and then click .
- In the Entity text box, type the name of the delegate.
- In the Entity Type drop-down list, click delegate.
- Click OK.
-
Add fields to your new delegate.
In the Field drop-down list, select
the field type to add, and then click Add
.
For information on the possible XML elements that you can add to your new entity definition, see Data entity subelements.
What to do next
After completing this task, complete Step 2: Define the delegate functionality.
Step 2: Define the delegate functionality
Before you begin
About this task
Next, you need to provide functionality for the delegate. While there are several ways to do this, you must use a Gosu enhancement implementation.
Java class implementation |
In the base configuration,
Guidewire provides a Java class implementation for each delegate to provide
the necessary functionality. The Delegate
object designates the Java class through the |
Gosu enhancement implementation |
You must implement the delegate functionality through a Gosu enhancement that defines any functionality associated with the fields on the delegate. By providing the name of the delegate entity to the enhancement as you create it, you inform Studio that you are adding functionality for that particular delegate. Studio automatically recognizes that you are enhancing the delegate. |
Procedure
-
In Guidewire Studio, in the Project
tool window, navigate to .
This is an example package. In actual practice, you can place the enhancement in a location that makes business sense.
- Right-click gw, and then click .
-
In the Name
text box, type the name of the enhancement.
As a best practice, Guidewire recommends that you use the name of the delegate followed by
Enhancement.For example, if the delegate is namedMyDelegate, then name the enhancementMyDelegateEnhancement. - In the Enhanced type list, click the name of the delegate entity that you created.
- Click OK.
- In the enhancement code window, enter code to provide the necessary functionality. The delegate automatically has access to all fields and members that you define in the Gosu enhancement.
What to do next
After completing this task, complete Step 3: Add the delegate to the parent entity.
Step 3: Add the delegate to the parent entity
Before you begin
About this task
The next step is to associate
a delegate with an entity using the <implementsEntity>
element in the entity definition.
- If you are creating a new entity,
then you need to add the
<implementsEntity>element to the entity definition. - If you are working with an existing
entity, then you need to add the
<implementsEntity>element to the entity extension.
Procedure
- In Guidewire Studio, in the Project tool window, navigate to the entity to modify, or create a new entity.
-
In the Field
drop-down list, click implementsEntity, and then
click Add
.
- Next to the name attribute, click the Value drop-down list, and click the name of the delegate.
What to do next
After completing this task, complete Step 4: Deploy your data model changes.
Step 4: Deploy your data model changes
Before you begin
About this task
After completing the previous steps, you need to deploy your data model changes. If necessary, see Deploying data model changes to the application server for details. Depending on whether you are working in a development or production environment, you need to perform different tasks. You may need to regenerate any Java API file or web service WSDL files after data model changes.
