Create an answer container for the entity

About this task

The first step in defining a question set in another entity is to create a new answer container entity of the corresponding type.

Procedure

  1. Create a new entity that has a foreign key to the target entity and implements PCAnswerDelegate.

    For example, to configure an answer container for an account-level question set, create an entity named AccountAnswer_Ext.eti with a foreign key to Account that implements PCAnswerDelegate.

    For guidance, examine one of the three base product answer containers, such as LocationAnswer.eti.

  2. Add an answer array to the base entity in which you are creating an answer container.
    For example, to add an answer array for account-level answers, add an array named AccountAnswers to Account.etx. In the array, set owner to true.
      Account.etx
        <array
          arrayentity="AccountAnswer_Ext"
          cascadeDelete="true"
          desc="Set of answers for this account."
          name="AccountAnswers"
          owner="true"/>

    For guidance, examine one of the three base product entities that implements answer containers, such as PolicyLocation.eti.

  3. Define an answer container adapter in the gw.question package that implements the AnswerContainerAdapter interface.
    For example, to define an answer container adapter for an account-level question set, create a new class file: gw.question.AccountAnswerContainerAdapter.gs that implements gw.api.domain.AnswerContainerAdapter and overrides appropriate methods and properties. For more guidance, examine one of the base product entities that implements answer containers, such as PolicyLocationAnswerContainerAdapter.gs.
  4. Update the definition of your entity to implement the answer container using the answer container adapter class you just defined.
    For example, if you are defining an account-level question set and your answer container class is named AccountAnswerContainerAdapter:
      <implementsEntity name="AnswerContainer" adapter="gw.question.AccountAnswerContainerAdapter"/> 
      name="AnswerContainer" />