In the Company Admin section, the business units page has a Create new business unit link to business_unit_new.jsp. Clicking this link brings the administrator to the Create New Business Unit page.

Here, the administrator can enter the name of the new business unit and select an existing business unit as its parent organization. For example, Mary Granger could create a business unit called Halfsale with the US Motor Works – US Division as a parent.

We used the CreateOrganizationFormHandler on <ATG9dir>/MotorpriseJSP/j2ee-apps/motorprise/web-app/en/admin/business_unit_new.jsp to create the new business unit and to specify its name and parent organization.

We set the following properties on the profile of the new business unit:

UserId

The id of the current user. This user is assigned an admin role to the newly created organization.

organizationName

The name of the business unit that is going to be created.

parentOrganizationId

The id of the parent organization for the newly created business unit.

This is the form we used on business_unit_new.jsp. We created a hidden form field that sets the CreateOrganizationFormHandler.userId to the admin who accesses the page. Then we set the name of the organization, CreateOrganizationFormHandler.organizationName.

<dsp:form action="business_units.jsp" method="post">
<dsp:input bean="CreateOrganizationFormHandler.userId"
   beanvalue="Profile.id" type="hidden"/>
<table border=0 cellpadding=4 cellspacing=0>
   <tr valign=top>
      <td align=right><span class=smallb>Name</span></td>
      <td><dsp:input bean="CreateOrganizationFormHandler.organizationName"
         size="30" type="text"/></td>
   </tr>

Then we used TargetPrincipals to show the user a list of the organizations from which she or he can select a parent of the new business unit to set parentOrganizationId

   <tr valign=top>
      <td align=right><span class=smallb>Parent organization</td>
      <td>
      <dsp:select bean=
         "CreateOrganizationFormHandler.parentOrganizationId">
      <!--By default set the parent organization to current user's
          organization--!>
      <dsp:getvalueof id="parentId" idtype="java.lang.String"
         bean="Profile.parentOrganization.repositoryId">
      <dsp:option selected="<%=true%>" value="<%=parentId%>"/>Select
         Parent Organization
      </dsp:getvalueof>
      <!--Display all organizations available to this user--!>
      <dsp:droplet name="TargetPrincipals">
         <dsp:param bean="Profile.id" name="userId"/>
         <dsp:param name="roleName" value="admin"/>
         <dsp:oparam name="output">
         <dsp:droplet name="ForEach">
            <dsp:param name="array" param="principals"/>
            <dsp:param name="sortProperties" value="+name"/>
            <dsp:oparam name="output">
            <dsp:getvalueof id="parentId" idtype="java.lang.String"
               param="element.repositoryItem.repositoryId">
            <dsp:option value="<%=parentId%>"/>
            <dsp:valueof param="element.repositoryItem.name"/>
            </dsp:getvalueof>
            </dsp:oparam>
         </dsp:droplet>
         </dsp:oparam>
      </dsp:droplet>
      </dsp:select>
      </td>
   </tr>

Then we added Save and Cancel buttons.

   <tr valign=top>
      <td></td>
      <td><br>
      <dsp:input bean=
         "CreateOrganizationFormHandler.createOrganizationSuccessURL"
         type="hidden" value="business_units.jsp"/>

      <dsp:input bean=
         "CreateOrganizationFormHandler.createOrganizationErrorURL"
            type="hidden" value="business_unit_new.jsp"/>
      <dsp:input bean="CreateOrganizationFormHandler.createOrganization"
         type="submit" value=" Save "/> &nbsp;
      <input type="submit" value=" Cancel "></td>

   </tr>

   </table>
</dsp:form>
 
loading table of contents...