Skip navigation.

Extending the Administration Console

  Previous Next vertical dots separating previous/next from contents/index/pdf Contents View as PDF   Get Adobe Reader

Creating Portlets That Match the Administration Console

This section describes how to add a portlet that uses the Administration Console's JSP templates, styles, and user input controls. For example, you can add portlets that render your content as one of the following:

Figure 5-1 illustrates the process. The steps in the process, and the results of each are described in Table 5-1. Subsequent sections detail each step in the process.

Figure 5-1 Administration Console Extension Development Overview

Administration Console Extension Development Overview


 

Table 5-1 Model MBean Development Tasks and Results

Step

Description

Result

1. Create and Use a Message Bundle.

Create a text file that contains a name/value pair for each text string that you want to display in your extension.

One or more.properties files.

2. Create Struts ActionForms and Actions.

To render HTML forms and tables that function as forms, the Administration Console uses JSP tags that load data from Java beans. To submit user input, the JSP tags forward to Struts Actions. Some JSP tags require the use of Struts ActionForms to populate the Java beans and make them available to the JSP.

If you use Administration Console JSP tags, you must create your own Struts ActionForms and Actions.

A Struts configuration file, Java beans, and Java classes that implement org.apache.struts.action.ActionForm and org.apache.struts.action.Action.

3. Create JSPs that Use BEA Templates and JSP Tags.

WebLogic Server provides JSP templates that you can import into your JSPs. It also provides a JSP tag library to render the same UI controls that the Administration Console uses.

JSPs that match the Administration Console styles and structure.

4. Create a .portlet XML File.

Create a portlet that causes Struts to instantiate your ActionForm. The ActionForm populates Java beans and forwards to a JSP.

A .portlet XML file that defines a portlet and configures it to launch a Struts action.

5.Create Other Portal Framework Files and Deploy the Extension.

Create XML files that define a location for your extension.

Then archive your extension files as a JAR file and copy it to your domain's console-ext directory.

A .pinc XML file that defines a page or book control (optional), a netuix-extension.xml file that describes where to locate your extension, and a JAR file that automatically deploys.

 


Create and Use a Message Bundle

BEA recommends that you define all of the text strings that your JSP displays in a message bundle.

To create and use a message bundle:

  1. Create a text file that contains name/value pairs (properties) for each string you want to display. Use the equal sign (=) as the delimiter between the name and value, and place each property on its own line.
  2. For example:
    myextension.myTab.introduction=This page provides monitoring data for my application.
    myextension.myTab.TotalServletHits.label=Total hits for my servlet.

  3. Save the file as dev-dir/WEB-INF/classes/bundle.properties where
  4. Save each localized version of the properties file as dev-dir/WEB-INF/classes/bundle_locale.properties
  5. where locale is a locale code supported by java.util.Locale. See Locale in the J2SE API Specification.

    For example, mycompany_ja.properties.

    Make sure to provide one file named bundle.properties; this is the default file that is used if a user has not specified a locale.

  6. To use the bundle in your JSPs:
    1. Import the JSTL fmt.tld tag library:
      <%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>
    2. Declare the name of your bundle:
      <fmt:setBundle basename="bundle" var="current_bundle" scope="page"/>
      where bundle is the name you used in the previous step.
    3. When you want the JSP to output a string, use the following JSP tag:
      <fmt:message key="property-name" bundle="${current_bundle}"/>
    4. For example:
      <fmt:message key="myextension.myTab.introduction" bundle="${current_bundle}"/>

 


Create Struts ActionForms and Actions

All WebLogic Server JSP tags that display and submit forms (and tables that function as forms) assume that Apache Struts is the controller agent. The JSP tags use Java beans that are populated by Struts ActionForms (form beans) and submit user input to a Struts Action. For information on Apache Struts, see The Apache Struts Web Application Framework at http://struts.apache.org/.

Some tags, such as <wl-extension:table>, require the form bean to contain a property that is a collection of Java beans. Each bean in the collection describes a single object or component that is rendered as a row in the table. For information on each Administration Console JSP tag and the Java bean properties that it requires, see WebLogic Server JSP Tags Reference.

If your extension manages WebLogic Server resources, create Struts ActionForms that populate Java bean properties with attribute values from WebLogic Server Managed Beans (MBeans). Similarly, create Struts Actions that set MBean values or invoke MBean operations. For information on working with WebLogic Server MBeans, see Developing Custom Management Utilities with JMX and Developing Manageable Applications with JMX.

Create a Named Struts Module

A Struts module is a Struts configuration file, message bundle, and other related resources. All Struts applications must have one default module. As of Struts 1.1, applications can have multiple modules, each of which must be uniquely named. For more information, see the Struts Newbie FAQ at http://struts.apache.org/faqs/newbie.html#modules.

Because the WebLogic Server Administration Console already uses the default module, you must create your own module for your extension. If you follow WebLogic Server naming conventions, the Administration Console will automatically discover your module and register it with the Apache Struts controller servlet.

To create a named Struts module for your Administration Console extension:

  1. Save your Struts configuration file as follows:
    dev-dir/WEB-INF/struts-auto-config-MyModule.xml
    where:
  2. When you define portlets that forward to your Struts actions, include the module="/MyModule" attribute in the portlet's <netuix:portlet> element (see Example: The Form in the Domains: Configuration: General Portlet).

For information on using additional features of Struts modules, see Configuring Applications in the Apache Struts User Guide.

Example: The Form in the Domains: Configuration: General Portlet

The Domains: Configuration: General portlet renders a form that provides configuration data for the domain. When the Administration Console loads this portlet:

  1. The portlet forwards to the Struts DomainConfigGeneral action path, which refers to an ActionForm that is defined in a Struts configuration file. The configuration file and associated resources are in a Struts module named core.
  2. Below is an excerpt from the portlet's .portlet file:

    <netuix:portlet definitionLabel="CoreDomainDomainConfigGeneralPortlet"
       title="core.domain.domainconfiggeneral.portlet.title">
       <netuix:strutsContent module="/core"
                              action="DomainConfigGeneral"
                              refreshAction="DomainConfigGeneral"/>
    </netuix:portlet>

  3. When the Struts controller servlet receives the request from the portlet, it:
    1. Instantiates the form bean that is named by the <action path="DomainConfigGeneral"> element in the Struts configuration file. (See Listing 5-1.)
    2. This form bean, domainConfigGeneralForm, contains three properties:

      name, which identifies the bean

      handle, which is the name of an Action class. The <wl-extension:form> JSP tag invokes this Action when a user submits the form.

      domainConfigGeneral, which is a Java bean whose properties correspond to attributes in the WebLogic Server DomainMBean.

    3. Launches the ActionForm class that is specified by the <action path="DomainConfigGeneral"> element in the Struts configuration file.
    4. This class, com.bea.console.actions.core.domain.DomainConfigGeneralAction, connects to an MBean server, gets the value of the DomainMBean attributes, and populates the domainConfigGeneral Java bean with the MBean attribute values.

  4. After the ActionForm instantiates and populates a form bean, it loads the DomainConfigGeneralForm.jsp and makes the form bean available to the JSP.

Listing 5-1 ActionForm for the Domains: Configuration: General Portlet

...
<form-bean name="domainConfigGeneralForm"
   type="org.apache.struts.validator.DynaValidatorForm">
   <form-property name="name"
      type="java.lang.String"/>
   <form-property name="handle"
      type="com.bea.console.handles.Handle"/>
   <form-property name="domainConfigGeneral"
      type="com.bea.console.cvo.core.domain.DomainConfigGeneralBean"/>
</form-bean>
...
<action path="/DomainConfigGeneral"
   type="com.bea.console.actions.core.domain.DomainConfigGeneralAction"
   name="domainConfigGeneralForm"
   parameter="tab"
   scope="request"
   validate="false">
   <forward name="success"
      contextRelative="true"
      path="/jsp/core/domain/DomainConfigGeneralForm.jsp"/>
</action>

 


Create JSPs that Use BEA Templates and JSP Tags

Most portlets in the Administration Console JSPs that are based on the tableBaseLayout_netui and configBaseLayout_netui templates. For information about these templates, see WebLogic Server JSP Templates.

The following sections describe how to create JSPs that use these templates:

Set Up Your Development Environment

The Administration Console JSP templates require the use of JSP tags from the JSP Standard Tag Library (JSTL), the BEA Administration Console Extension Tag Library, and the Apache Beehive Page Flows Tag Library.

The WebLogic Server runtime environment already provides these tag libraries. For development support, add the following tag libraries to your development environment:
WL_HOME/server/lib/consoleapp/webapp/WEB-INF/beehive-netui-tags-html.jar
WL_HOME/server/lib/consoleapp/webapp/WEB-INF/fmt.tld
WL_HOME/server/lib/consoleapp/webapp/WEB-INF/console-html.tld

Create a Table JSP

A table JSP uses a table to summarize a set of resources and provides navigation to those resources (see Figure 2-4). If your extension manages multiple resources or multiple instances of a single resource, create a table JSP.

Note: Tables can contain buttons and checkboxes, which enable you to select one or more rows and invoke an action for the selected items. For information about this feature, see <wl-extension:table> in WebLogic Server JSP Tags Reference.

Before you create a table JSP, create a Struts ActionForm that populates a form bean and forwards to your JSP. (See Create Struts ActionForms and Actions.) The form bean must contain the following minimal properties:

To create a table JSP (see Listing 5-2):

  1. Create a JSP and save it in your development directory. Consider creating a subdirectory to contain all of the JSPs in your extension. For example, dev-dir/jsp
    where dev-dir is your development directory. For more information, see Archive and Deploy the Extension.
  2. Import JSP tag libraries by including the following tags:
    <%@ taglib uri="/WEB-INF/console-html.tld" prefix="wl-extension" %>
    <%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>
    <%@ taglib uri="/WEB-INF/beehive-netui-tags-template.tld" prefix="beehive-template" %>
  3. For information about these tag libraries, see JSP Tag Libraries.

  4. (Optional) If you plan to use <fmt:message> tags to display localized text, use <fmt:setBundle/> to specify the name of the message bundle.
  5. This <fmt:setBundle/> tag enables you to specify the bundle name once, and then refer to this value from <fmt:message> tags by variable.

  6. Declare the JSP template for tables by creating the following opening tag:
  7. <beehive-template:template
       templatePage="/layouts/tableBaseLayout_netui.jsp">

    Do not close the tag yet. All other JSP tags in a table JSP are nested in this template tag.

  8. Create a <beehive-template:section name="configAreaIntroduction"> tag. Inside this tag, provide an introductory sentence or paragraph that describes the table. This description is rendered above the table.
  9. Create the following opening tag:
    <beehive-template:section name="table">
  10. Do not close the tag yet.

  11. Create an opening <wl-extensions:table> tag and specify values for the following minimal attributes:
  12. If you specified "true" for the captionEnabled attribute, create a <wl-extension:caption> tag. Inside this tag, provide a caption for the table.
  13. For each property in the row bean that you want to display in the table, create a <wl-extension:column> tag and specify values for the following attributes:
  14. If you want the text in a column to be a hyperlink, nest a <wl-extension:column-link> tag in the <wl-extension:column> tag. For the <wl-extension:column-link> tag's portlet attribute, specify the definitionLabel of the portlet to which you want to link.
  15. Instead of using <wl-extension:column-link> and the definitionLabel of a portlet, you can use <wl-extension:column-dispatch>, the value of metadata that you have defined for a portlet, and the value of an additional property that you must include in this table's form bean. Using metadata specify a linking target enables you to forward to all portlets that contain the specified metadata. See column-dispatch in the WebLogic Server JSP Tag Reference.

  16. Close the <wl-extension:table>, <beehive-template:section>, and <beehive-template:template> tags.

Listing 5-2 Example: Simple Table JSP

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/console-html.tld" prefix="wl" %>
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/beehive-netui-tags-template.tld" prefix="beehive-template" %>
<fmt:setBundle basename="core" var="current_bundle" scope="page"/>
<beehive-template:template templatePage="/layouts/tableBaseLayout_netui.jsp">
   <beehive-template:section name="configAreaIntroduction">
      <fmt:message key="core.server.servertable.introduction"
            bundle="${current_bundle}"/>
   </beehive-template:section>
   <beehive-template:section name="table">
      <wl-extension:table name="extensionForm"
             property="contents"
             captionEnabled="true"
            bundle="core">
         <wl-extension:caption>
            <fmt:message key="server.table.caption"
                 bundle="${current_bundle}"/>
         </wl-extension:caption>
         <wl-extension:column property="name" label="server.table.label.name">
            <wl-extension:column-link portlet="MyPortletID"/>
         </wl-extension:column>
         <wl-extension:column property="clusterName"
            label="server.table.label.cluster"/>
         <wl-extension:column property="machineName"
            label="server.table.label.machine"/>
      </wl-extension:table>
   </beehive-template:section>
</beehive-template:template>

Create a Configuration JSP

A configuration JSP uses a form to display the configuration of a resource and to enable users to modify the configuration (see Figure 2-3). You can create a read-only configuration JSP that enables users to monitor a resource.

The Administration Console JSP tags can render standard HTML input controls, such as text, text-areas, and radio buttons.

Before you create a configuration JSP, create a Struts ActionForm that populates a form bean and forwards to your JSP. (See Create Struts ActionForms and Actions.) The form bean must contain the following minimal properties:

To create a configuration JSP (see Listing 5-3):

  1. Create a JSP and save it in your development directory. Consider creating a subdirectory to contain all of the JSPs in your extension. For example, dev-dir/jsp
    where dev-dir is your development directory. For more information, see Archive and Deploy the Extension.
  2. Import JSP tag libraries by including the following tags:
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/console-html.tld" prefix="wl-extension" %>
    <%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>
    <%@ taglib uri="/WEB-INF/beehive-netui-tags-template.tld" prefix="beehive-template" %>
  3. For information about these tag libraries, see JSP Tag Libraries.

  4. (Optional) If you plan to use <fmt:message> tags to display localized text, use <fmt:setBundle/> to specify the name of the message bundle.
  5. This <fmt:setBundle/> tag enables you to specify the bundle name once, and then refer to this value from <fmt:message> tags by variable.

  6. Declare the JSP template for configuration pages by creating the following opening tag:
  7. <beehive-template:template templatePage="/layouts/configBaseLayout_netui.jsp">

    Do not close the tag yet. All other JSP tags in a configuration JSP are nested in this template tag.

  8. Create a <beehive-template:section name="configAreaIntroduction"> tag. Inside this tag, provide an introductory sentence or paragraph that describes the form. This description is rendered above the form.
  9. Create the following opening tag:
    <beehive-template:section name="form">
  10. Do not close the tag yet.

  11. Indicate that the next set of JSP tags output XHTML by creating the following tag:
  12. <html:xhtml/>

  13. Create an opening <wl-extension:template
    name="/WEB-INF/templates/form.xml">
    tag.
  14. The JSP tags that render forms can be used to render different types of forms. All form-related JSP tags output XML and the <wl-extension:template> tag specifies an XSLT template to transform the XML to XHTML. WebLogic Server provides the following templates:

  15. Create an opening <wl-extension:form> and specify values for the following attributes:
  16. For each property in the form bean that you want to display in the form, create a <wl-extension> tag corresponding to the type of control that you want to render (see WebLogic Server JSP Tags Reference):
  17. Alternatively, you can use <wl-extension:reflecting-fields>, which generates an HTML input tag for each property in a form bean. For example, for a bean property that contains a java.lang.String, the tag generates a text control; for a boolean, it generates a checkbox. This tag uses the default form bean, which is passed to the JSP in the request.

  18. To generate text on the page that describes to users the purpose of each control, include the inlineHelpId attribute in each <wl-extension> tag in the previous step.
  19. Close the <wl-extension:form>, <beehive-template:section>, and <beehive-template:template> tags.

Listing 5-3 Example: Simple Configuration JSP

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/console-html.tld" prefix="wl" %>
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/beehive-netui-tags-template.tld"
   prefix="beehive-template" %>
<fmt:setBundle basename="core" var="current_bundle" scope="page"/>
<beehive-template:template templatePage="/layouts/configBaseLayout_netui.jsp">
   <beehive-template:section name="configAreaIntroduction">
      <fmt:message key="core.server.serverconfiggeneral.introduction"
           bundle="${current_bundle}"/>
   </beehive-template:section>
   <beehive-template:section name="form">
      <html:xhtml/>
      <wl-extension:template name="/WEB-INF/templates/form.xml">
         <wl-extension:form action="/CoreServerServerConfigGeneralUpdated" bundle="core">
            <wl-extension:text property="serverConfigGeneral.Name"
               labelId="core.server.serverconfiggeneral.name.label"
                inlineHelpId="core.server.serverconfiggeneral.name.
                    label.inlinehelp" />
             <wl-extension:select property="serverConfigGeneral.selectedMachine"
                 labelId="core.server.serverconfiggeneral.machine.label"
                 inlineHelpId="core.server.serverconfiggeneral.machine.
                    label.inlinehelp">
                  <wl-extension:optionsCollection
                     property="serverConfigGeneral.availableMachines"
                     label="label" value="value"/>
              </wl-extension:select>
         </wl-extension:form>
      </wl-extension:template>
   </beehive-template:section>
</beehive-template:template>

 


Create a .portlet XML File

A .portlet XML file defines a WebLogic Portal portlet, which is a container for content such as JSPs and Struts actions. All JSPs in the Administration Console must be contained in portlets. For more information about portlet XML files, see the Portal Support Schema Reference.

To create a portlet that contains a JSP based on WebLogic Server template and its required Struts actions:

  1. Copy the code from Listing 5-4 and paste it into new text file.
  2. Consider creating a subdirectory to contain all of the portlet XML files in your extension. For example, dev-dir/PortalConfig
    where dev-dir is your development directory. For more information, see Archive and Deploy the Extension.

    Also consider adopting the following naming convention:
    JSP-file-name-no-extension.portlet

    where JSP-file-name-no-extension is the name of the JSP file that the portlet contains. For example, if the portlet contains a JSP file named monitorEJB.jsp, then name the portlet XML file monitorEJB.portlet.

  3. Replace the values in Listing 5-4 as follows:

Note that this .portlet does not specify the name of your table or configuration JSP. Instead, the name of this JSP is specified in the Struts configuration file.

Listing 5-4 Template for a Simple .portlet XML File

<?xml version="1.0" encoding="UTF-8"?>
<portal:root xmlns:html="http://www.w3.org/1999/xhtml-netuix-modified/1.0.0"
   xmlns:portal="http://www.bea.com/servers/netuix/xsd/portal/support/1.0.0"
   xmlns:netuix="http://www.bea.com/servers/netuix/xsd/controls/netuix/1.0.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.bea.com/servers/netuix/xsd/portal/
      support/1.0.0 portal-support-1_0_0.xsd">
   <netuix:portlet definitionLabel="Label" title="Title" >
     <netuix:strutsContent module="Struts-module"
          action="
action-path"
          refreshAction="
refresh-action-path"/>
   </netuix:portlet>
</portal:root>

 


Create Other Portal Framework Files and Deploy the Extension

You can add your portlet directly to the desktop, but if you want your portlet to display as a tab or subtab in the ContentBook, you must define books or pages to contain it. In addition, you must create a netuix-extension.xml file which specifies where to locate your portlet, books, and pages and which functions as the deployment descriptor for your extension.

See Adding Portlets and Navigation Controls.

 

Back to Top Previous Next