Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Step - 4 : Show labels in screens above the form like "New Person --- Simple Event"  and  "New Person --- Java Event" so that it will be easy to identify the purpose of that form.

...

Code Block
public static String createPracticePersonJavaEvent(HttpServletRequest request, HttpServletResponse response){              LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");                              GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
}

...

Step - 2 : Now you have to process the fields comming from the form like :
            

Code Block
              String salutation = (String) request.getParameter("salutation");
              String firstName = (String) request.getParameter("firstName");
            

Step - 3 : Now prepare a map for the values which you have to pass to the service which you will call "createPracticePerson" . Like :
            

Code Block

              Map createPersonCtx = UtilMisc.toMap("salutation", salutation, "firstName", firstName);
             

 

Step - 4 : Then at the end just call the service "createPracticePerson" like :
             

String firstName = (String) request.getParameter("firstName");

Step - 3 : Now prepare a map for the values which you have to pass to the service which you will call "createPracticePerson" . Like :            

Code Block

Map createPersonCtx = UtilMisc.toMap("salutation", salutation, "firstName", firstName);

Step - 4 : Then at the end just call the service "createPracticePerson" like :             

Code Block

try{
    Map person = dispatcher.runSync("createPracticePerson", createPersonCtx);
 }catch (GenericServiceException e){
    
Code Block

             try{
                 Map person = dispatcher.runSync("createPracticePerson", createPersonCtx);
              }catch (GenericServiceException e){
                  Debug.logError(e.toString(), module);         return "error";
              }
               return "error";
 }
return "success";
             


After writting event in Java don't forget to compile it by running "ant" command. At this moment you will need to add build.xml file to your component directory i.e. at hot-deploy/practice/ For the content of build.xml file you can refer "example" component.
Here in build.xml file ensure one thing you are having follwing entry:

...

Step - 2 :  Now you have to create a file by name "eecas.xml" in "entitydef" directory, which will be in your component directory "practice". Eeca definition will come here. (Take reference from eecas.xml of "accounting" component). This will be :

    <!-- To create party role whenever a party is created -->
    <eca entity="Party" operation="create" event="return">
        <condition field-name="partyId" operator="is-not-empty"/>
        <action service="createPartyRoleCustomer" mode="sync"/>
    </eca>

...

 Create a group service by name "partyGroup" like :

<!- - Group service -->
    <service name="partyGroup" engine="group" auth="true">
        <description>Creates a party, person and party role Client</description>
        <group>
            <invoke name="createPracticePerson" result-to-context="true"/>
            <invoke name="createPartyRoleClient"/>
        </group>
    </service>

...

Step - 2 : Create new screen, form and service for creating a person. Here service will implement the interface. (For creating interface take reference from services_fixedasset.xml of accounting component) it will be like :

<!- - Peson Interface - ->
    <service name="createPersonInterface" engine="interface" location="" invoke="">
        <attribute name="firstName" mode="IN" type="String" optional="false"/>
        <attribute name="middleName" mode="IN" type="String" optional="true"/>
        <attribute name="lastName" mode="IN" type="String" optional="false"/>
        <attribute name="suffix" mode="IN" type="String" optional="true"/>
    </service>
   
    <service name="createPracticePersonInterfaceService" engine="simple" location="org/hotwax/practice/PracticeServices.xml" invoke="createPracticePersonInterfaceService" auth="false">
        <description>Creates a new Person</description>
        <implements service="createPersonInterface"/>
        <attribute name="partyId" mode="OUT" type="String" optional="false"/>  
        <override name="suffix" optional="false"/>
    </service>

...