You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

The following document illustrates how to get started writing a web application using common code that we have been using or developing over the last few years. We also describe how to deploy the application to a web server.

Web Application Skeleton

Download end extract the following zip file containing a skeleton for your new web application.

GLAST Commons

The GLAST Commons is a collections of common code that can and should be shared across different GLAST web application providing a uniform look and feel. The following items are provided by the GLAST Commons and are used in the skeleton provided above:

  • style sheet If included in your jsp page, it will give your page the style shared by all other applications. This style sheet is loaded when needed via the web, so any change to the GLAST Commons style sheet will propagate to all the applications using it. By default the style sheet is included in the Sitemesh templates described below, so you should not have to include it.
  • GLAST Logo This servlet creates the GLAST logo for a provided title. This is also included by default in the Sitemesh templates.
  • Date and Date/Time Picker These are javascript functions that make it easier to select either Dates and/or Times in your application. Examples are provided in the jsp file: src/webapp/pickers.jsp

Filters

The GLAST Commons provide three filters that are by default included in the above skeleton application:

  • Login A filter that monitor the login status of users with our central single-sign-on CAS server. This filter makes sure that once a user logged in, its logged-in status is preserved across applications.
  • Cookies Most of our applications require cookies. This filter checks that the user's browser allows cookies to be set and warns the user if they are disabled.
  • Multipart This filter allows form data, including uploaded files, to be submitted using enctype="multipart/form-data".

To disable any of these filters you'll have to remove their specification in src/webapp/WEB-INF/web.xml.

Sitemesh

Sitemesh is used to decorate the pages, making sure they all get a similar look and feel. Please refer to the sitemesh documentation for more information.

The main sitemesh related files are the following:

  • src/webapp/WEB-INF/sitemesh.xml Sitemes configuration file in which appropriate modules are loaded to handle frames.
  • src/webapp/WEB-INF/decorators.xml This is the mapping between your jsp pages and the templates to be used to decorate them. In this example we map all the pages to a common decorator, but for three pages belonging to a frame which need to have special decorators. The following are the decorators used:
    • src/webapp/decorators/basicDecorator.jsp common decorator for all pages. It adds a common style sheed from the GLAST commons, a style sheet specifit to this application (src/webapp/css/style.css), it adds the logo on the top right of the page, the login button and the footer with the last modified date.
    • src/webapp/decorators/justFooterDecorator.jsp decorator that just adds the footer, used for the main window of frames. It adds the last modified date at the bottom of the page.
    • src/webapp/decorators/justHeaderDecorator.jsp decorator that just decorates the header with the logo and the login button. This is used for the header of a frame.
    • src/webapp/decorators/justStyleDecorator.jsp decorator that just adds style sheets. Used for the menu/tree window of a frame.

The above decorators share common code stored in the form of tag files:

  • src/webapp/WEB-INF/tags/decorators/footerDecorator.tag Prints the last modified date in the footer.
  • src/webapp/WEB-INF/tags/decorators/headerDecorator.tag Adds the logo and the login button to the header.

Finally for sitemesh to work a filter needs to be added to the application. It's the filter that is responsible for mangling your jsp code with the decorating templates. This is done in src/webapp/WEB-INF/web.xml with the following code:

    <filter>
        <filter-name>sitemesh</filter-name>
        <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

If you are not interested in sitemesh you can remove the filter definition in web.xml and all the above files.

Display Tag For Tables

We use the Display tag library to create sortable tables. We provide a simple jsp example (src/webapp/table.jsp) that displays a sample list of items created using the java classes in src/main/java/org/glast/web/base/table.

To use the Display tag library all you have to do is to include the tag library definition at the top of your jsp page:

      <%@taglib prefix="display" uri="http://displaytag.sf.net" %>

and use the prefix display to access the table tags.

Additionally, if you specify the table's class to be datatable, as done in the example below, you will get the default styles provided by the GLAST Commons and used by most of the other GLAST web applications.

        <display:table  class="datatable" name="${table}"  defaultorder="ascending"  sort="list" id="tableId" >

AIDATLD For Plots

Logging

  • No labels