Publishing and Editing Wizards  Locate

This section describes how publishing and editing wizards work in the Business Service Console. After you read this section you will understand how to modify existing wizards and create new wizards.

The Business Service Console's wizards are composed of steps. In each step users usually can go back to the previous step (if there is one), proceed to the next step, finish the wizard if the last step has concluded, or cancel the wizard at any step before the conclusion.

We will show you how wizards work on the wizard that comes with Business Service Console. The wizard purpose is editing an already published interface (service interface). The wizard allows users to modify interface's name, description and categorization. The wizard has two steps; the first step will enable users to edit the name and description of the interface, while in the second step users can modify the interface's categorization.

To create a publishing/editing wizards, follow these steps:

  1. Create entries in the configuration file that list the wizard's components and endpoint URLs

  2. Create Java parts of wizard's components

  3. Create JSP parts of wizard's components

These steps are described in the subsequent sections.

You can find the complete JSP code for the editInterfaceWizard component in the jsp\publish\iface subdirectory of the REGISTRY_HOME\app\uddi\bsc.jar file. The source of its Java part is in the src directory of the same JAR file.

The wizardIterator framework component is thoroughly described in the Business Service Console framework section of this documentation.

Wizard Configuration  Locate

The configuration file web_component.xml for the Business Service Console is located in the conf subdirectory of the REGISTRY_HOME\app\uddi\bsc.jar file. The wizard for editing interfaces has the following entries in the configuration file:

<config name="web" savingPeriod="5000">
    <webFramework>
    ...
        <component name="editInterfaceWizard"
            className="com.systinet.uddi.bui.standard.component.publish.iface.EditInterfaceWizard"
            page="publish/iface/editInterfaceWizard.jsp">
            <parameter paramName="wizardComponents" paramValue="editInterfaceStep1,editInterfaceStep2"/>
            <parameter paramName="wizardNames" paramValue="Name and description, Interface properties"/>
        </component>
        <component name="editInterfaceStep1" page="publish/iface/editInterfaceStep1.jsp"/>
        <component name="editInterfaceStep2" page="publish/iface/editInterfaceStep2.jsp"/>
        ...
    </webFramework>
...
</config>

Each wizard must have a task with a URL declared in the configuration file. The task URL defines an endpoint where the wizard task is accessible. This task references the editInterfaceWizard component. The task will be accessible at the relative URL /publish/interfaces/editInterface to the context of Business Service Console.

The wizard for editing the interface has the following task declaration:

<config name="web" savingPeriod="5000">
    <webFramework>
        ...
        <task uri="/publish/interfaces/editInterface" 
              caption="Edit interface" 
              component="editInterfaceWizard"/>
        ...
    </webFramework>
    ...
</config> 
The Java Part of the Wizard Component  Locate

The Java portion of this component acts as follows:

  1. A Java class representing the Java part of the component must extend com.systinet.webfw.ComponentImpl. In its process method it parses the input parameter params and retrieves the tModelKey parameter.

  2. If the JSP session does not yet contain an instance of the TModel object (the edited interface), it sends a request to BEA AquaLogic Service Registry to get that instance by key.

  3. It then stores the returned instance to the session object.

  4. It also takes care of handling the WizardIterator.CANCEL and WizardIterator.FINISH actions.

    For the WizardIterator.CANCEL action, it stores an attribute in the request that can be displayed in the appropriate message through the JSP part of the component.

    For the WizardIterator.FINISH action it should republish the instance of TModel into BEA AquaLogic Service Registry and store an attribute to request as a flag that the wizard was finished.

The following static variables are used in the JSP part of the component:

// request attribute signaling that the wizard has been canceled
public static final String CANCELED = "canceled";

// request attribute signaling that the wizard has been finished
public static final String RESULT_TMODEL_KEY = "resultTModelKey";
            
// param with the tModelKey String of the interface that is to be edited
public static final String TMODEL_KEY = "tModelKey"; 

The body of the process method follows.

  1. First, define a few variables:

    // retrieve the request from the call context
    WebRequest request = getRequest();
    // session
    Map session = getCurrentSession();

  2. Next handle the WizardIterator.CANCEL action:

    if (WizardIterator.CANCEL.equals(action)) {
        request.setAttribute(CANCELED, "true");
        return;
    } 

  3. Then, check whether the instance of TModel is already in the session. If it is not, parse the input parameter params for the TMODEL_KEY parameter, send a request to BEA AquaLogic Service Registry and store the response into the session.

  4. The object the wizard should iterate over (the object that will be passed to the steps of the wizard for modification) must be stored into the session under the following string: WizardIterator.FORM.

    TModel tModel = (TModel) session.get(getPrefix(params) + WizardIterator.FORM);
                        
    if (tModel == null) {
         String tModelKey = (String) params.get(TMODEL_KEY);
         Get_tModelDetail get_tModelDetail = new Get_tModelDetail();
         String authInfo = UDDIUserRoles.getAuthInfo();
         get_tModelDetail.setAuthInfo(authInfo);
                        
        try {
            get_tModelDetail.addTModelKey(tModelKey);
            UDDI_Inquiry_PortType inquiry = UDDIApiHelper.getInquiry();
            TModelDetail tModelDetail = inquiry.get_tModelDetail(get_tModelDetail);
            tModel = tModelDetail.getTModelArrayList().get(0);
                        
            if (tModel.getCategoryBag() == null) {
                tModel.setCategoryBag(new CategoryBag());
            }
                        
            if (tModel.getDescriptionArrayList() == null) {
                tModel.addDescription(new Description());
            }
                        
            if (tModel.getOverviewDocArrayList() == null) {
                tModel.addOverviewDoc(new OverviewDoc());
            }
                        
            if (tModel.getOverviewDocArrayList().get(0).getOverviewURL() == null) {
                tModel.getOverviewDocArrayList().get(0).setOverviewURL(new OverviewURL());
            }
                        
        } catch (InvalidParameterException e) {
            throw new BUIDefaultException(BUIDefaultErrorCodes.UDDI_ERROR, e);
        } catch (UDDIException e) {
                throw new BUIDefaultException(BUIDefaultErrorCodes.UDDI_ERROR, e);
        }
                        
        session.put(getPrefix(params) + WizardIterator.FORM, tModel);
    }

  5. Finally we should handle the WizardIterator.FINISH action and republish the modified instance of the interface (TModel):

     if (WizardIterator.FINISH.equals(action)) {
        Save_tModel save_tModel = new Save_tModel();
        String authInfo = UDDIUserRoles.getAuthInfo();
        save_tModel.setAuthInfo(authInfo);
        UDDI_Publication_PortType publish = UDDIApiHelper.getPublishing();
        TModelDetail result = null;
        try {
            TModel cloned = (TModel) tModel.clone();
            cloned.normalize();
            save_tModel.addTModel(cloned);
            result = publish.save_tModel(save_tModel);
            request.setAttribute(RESULT_TMODEL_KEY,
            result.getTModelArrayList().get(0).getTModelKey());
        } catch (CloneNotSupportedException e) {
            throw new BUIDefaultException(BUIDefaultErrorCodes.INTERNAL_ERROR, e);
        } catch (UDDIException e) {
            throw new BUIDefaultException(BUIDefaultErrorCodes.UDDI_ERROR, e);
        }
    } 

For the complete source of the default implementation see the src subdirectory of the JAR file mentioned above.

JSP Part of the Wizard Component  Locate

For the full default source of the JSP part of the editInterfaceWizard component please see the editInterfaceWizard.jsp file in the jsp\publish\iface subdirectory of the REGISTRY_HOME\app\uddi\bsc.jar file.

As we are concerned only with the implementation of the wizard, we can omit the unimportant header and footer sections of the page as well as the section where the navigation tree is declared.

The framework component wizardIterator accepts several parameters including names of the components representing the steps (the componentNames parameter), human readable names of the steps (the stepNames parameter), and finally the object that will be passed to each of the step components for modification (the form parameter).

[Note]Note

The Java part of the editInterfaceWizard component stored the instance of the interface (TModel) under the string WizardIterator.FORM into the session, hence here the parameter form is evaluated as the ${form}.

[Note]Note

The values of wizardComponents and wizardNames variables are specified in the web_component.xml configuration file.

  1. Bare display. The following is all the code you need to implement a wizard -- you need only pass the names of the step components and the object that should be passed to these steps (that is, the object that will be shared among them, the interface to be edited):

    <syswf:component name="wizardIterator" prefix="wizard">
        <syswf:param name="componentNames" value="${wizardComponents}"/>
        <syswf:param name="stepNames" value="${wizardNames}"/>
        <syswf:param name="form" value="${form}"/>
    </syswf:component>
  2. Processing actions. Now add some processing logic. For cases in which the wizard is cancelled, the request will contain the attribute EditInterfaceWizard.CANCEL. We should check for the presence of this attribute and display an appropriate message if that check is positive. We should also check whether the wizard finishes. In such cases the request will contain the attribute EditInterfaceWizard.RESULT_TMODEL_KEY. If this attribute is present, we should display the message that the interface was successfully republished and provide the user a link to its details.

    <c:choose>
        <c:when test="${empty canceled}">
            <c:choose>
                <c:when test="${empty resultTModelKey}">
                    <syswf:component name="wizardIterator" prefix="wizard">
                        <syswf:param name="componentNames" 
                            value="${wizardComponents}"/>
                        <syswf:param name="stepNames" 
                            value="${wizardNames}"/>
                        <syswf:param name="form" value="${form}"/>
                     </syswf:component>
                </c:when>
                <c:otherwise>
                    <p>Interface
                        <a target="_blank" 
                          href="<c:out value="${unsecureUrl}"/>
                            /browse/interfaceDetail?tModelKey=
                          <c:out value="${resultTModelKey}"/>"
                            title="View detail">
                          <c:out value="${form.name.value}"/>
                        </a>
                        has been republished.
                    </p>
                </c:otherwise>
            </c:choose>
        </c:when>
        <c:otherwise>
            <p>
                Republishing of interface has been canceled.
            </p>
        </c:otherwise>
    </c:choose>   

And now we will turn to the step components of the wizard as the last thing to be written.

JSP Part of the Wizard Steps  Locate

For the full default source of the JSP parts of the wizard steps please see files editInterfaceStep1.jsp and editInterfaceStep2.jsp in the jsp\publish\iface subdirectory of the REGISTRY_HOME\app\uddi\bsc.jar file.

Step One - Editing the Name and Description of the Interface  Locate

In the first step the user can modify the interface name and description. The framework component wizardIterator passes the instance of TModel representing the edited interface to each step under the WizardIterator.FORM string (which is equal to "form"). Note that here the custom tag library of the BEA AquaLogic Service Registry web framework comes into play and significantly simplifies the implementation of needed functionality.

In the first step we declare a table with two rows. The first row will contain the input field for the name of the interface prefilled by the value taken from the TModel instance. The second row will contain the text area for the interface description prefilled by its value, again taken from the edited instance. Using a custom library, the values entered by the user are directly retrieved from and stored into the instance without any further need of parsing and explicit coding. Here is the code for the table:

<table border="0" cellapdding="0" cellspacing="0" width="70%">
    <tr>
        <td width="25%" class="horizCtlName">
            Name:<sup class="required">*</sup>
        </td>
        <td width="75%" class="horizCtlSet">
            <syswf:input name="form.name" 
                         value="${form.name}" 
                         property="value" 
                         hint="Enter the name of interface">
                <syswf:attribute name="size" value="50"/>
                <syswf:checker name="required" action="checkFields"/>
            </syswf:input>
        </td>
    </tr>
    <tr>
        <td width="25%" class="horizCtlName">
            Description:
        </td>
        <td width="75%" class="horizCtlSet">
            <syswf:textArea name="form.descriptionArrayList[0]" 
                            value="${form.descriptionArrayList[0]}" 
                            property="value" 
                            hint="Enter the description of interface" >
                <syswf:attribute name="cols" value="37"/>
                <syswf:attribute name="rows" value="3"/>
            </syswf:textArea>
        </td>
    </tr>
</table> 
Step Two - Editing Categorization of Interface  Locate

In the second step the user can modify the interface categorization.

In the second and final step we declare a table with two rows. The first row will contain the input field for the value of the interface categorization in the systinet-com:taxonomy:usage taxonomy. The second row will contain a drop down list in which the user can select the value of the interface categorization in uddi:systinet.com:taxonomy:interface:status taxonomy.

For rendering taxonomies, the Business Service Console framework components are used.

<table border="0" cellapdding="0" cellspacing="0" width="100%">
    <tr>
        <td width="15%" class="horizCtlName">
            Usage:
        </td>
        <td width="85%" class="horizCtlSet">
            <syswf:component prefix="step4#filterUsage" name="taxonomyFilterPure">
                <syswf:param name="taxonomyTModelKey" 
                    value="uddi:systinet.com:taxonomy:usage"/>
                <syswf:param name="categoryBag" value="${form.categoryBag}"/>
                <syswf:param name="restricted" value="yes"/>
                <syswf:param name="reuse" value="yes"/>
            </syswf:component>
        </td>
    </tr>
    <tr>
        <td width="15%" class="horizCtlName">
            Status:
        </td>
        <td width="85%" class="horizCtlSet">
            <syswf:component prefix="step4#filterState" name="taxonomyFilter">
                <syswf:param name="taxonomyTModelKey" 
                    value="uddi:systinet.com:taxonomy:interface:status"/>
                <syswf:param name="categoryBag" value="${form.categoryBag}"/>
                <syswf:param name="selectMode" value="one"/>
                <syswf:param name="viewMode" value="radio"/>
                <syswf:param name="fakeNil" value="n/a"/>
            </syswf:component>
        </td>
    </tr>
</table>