Server tags

This section describes using WebCharts3D server tags to produce interactive images during page processing. (See Overview for more information). Before you start producing images, you will need to setup WebCharts3D on the server as it is described in Setup section.

To produce images using custom tags you need to:

  1. Refernce the tag library descriptor. You can do it in a number of ways, for example:
    <%@ taglib prefix="ct" uri="http://www.gpoint.com/tld/webcharts50.tld" %>

  2. Insert the chart using ct:webchart tag. This tag has the following optional attributes:
    Name Type Description
    style String  Styles in the XML Format or name of a file that contains styles in XML format.
    type String  Image type (PNG|JPG|GIF|WBMP|SVF|SVG|PDF|TIF)
    width int  The width of the chart
    height int  The height of the chart
    rsel int  The chart's row selection (-1 by the default)
    csel int  The chart's column selection (0 by the default)
    html boolean  Flag telling WebCharts3D to produce 508 compliant charts with HTML description. Default: false.
    connection java.sql.Connection  Opened SQL connection for data retrieval (Optional)
    location String  Filename of the file with data. (Optional)
    getImageURL String  The location and name of the file/servlet that will retrieve stored image from the server. See JSP section of this chapter for more information about getImage.jsp. Default: /getImage.jsp.

The data for the chart can be specified in a number of ways:

  1. In XML format embedded into the tag's body. For example:

    <ct:webchart type="PNG" width="256" height="256" style="..." >
    <?xml version="1.0" encoding="UTF-8"?>
    <XML type="default">
       <ROW Y2000="100" Y2001="200" Y2002="300"></ROW>
    </XML>
    </ct:webchart>

  2. In XML format stored in a file specified by the location attribute. The body of the tag should be empty.
  3. In a separated format stored in a file specified by the location attribute. The body of the tag should be in the following format:

    <csv
     location="location"- same location as specified in location attribute
     separator="," - Field separator (Optional)
     quote="" - Quote character or empty string (Optional)
     isCrosstab="true|false"- True or false (Optional)
     hasColLabels="true|false" - True or false (Optional)
     hasRowLabels="true|false"- True or false (Optional)
     encoding="encoding"/>- Encoding (Optional)


  4. As an SQL query to be executed on opened database connection specified by the connection attribute. The body of the tag should be in the following format:

    <sql isCrosstab="true|false" hasRowLabels="true|false">
    SQL Command
    </sql>

NOTE


WebCharts3D tag library uses taglib version 2.0 (J2EE 1.4). If your server does not support this version you might need to create a tag library descriptor for the supported version. You can also easily create your own tags, for example:
public class MyTaglibComponent extends BodyTagSupport {
   ...

public int doEndTag() throws JspException {

   MxServerComponent server;
   try {
      server = MxServerComponent.getDefaultInstance(pageContext.getServletContext());
      MxChartDescription dsc = server.newImageSpec();

      dsc.width = width ;
      dsc.height= height;
      dsc.type = type ;

      dsc.model = getBodyContent().getString(); // Use body as chart's model
      dsc.loadStyles(style); // load style from a file

      String tag = server.getImageTag(dsc,getImageURL+"?image=");
      getBodyContent().getEnclosingWriter().write(tag);
   }
   catch(java.io.IOException ex) { throw new JspException(ex.toString()); }
   return SKIP_BODY;
}