[Bio] / WebApplication / WebComponent.pm Repository:
ViewVC logotype

View of /WebApplication/WebComponent.pm

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.4 - (download) (as text) (annotate)
Thu Sep 4 18:59:15 2008 UTC (11 years, 10 months ago) by parrello
Branch: MAIN
CVS Tags: rast_rel_2008_12_18, rast_2008_0924, rast_rel_2008_09_30, mgrast_rel_2008_0924, mgrast_rel_2008_1110_v2, rast_rel_2009_02_05, mgrast_rel_2008_0625, rast_rel_2008_10_09, rast_release_2008_09_29, mgrast_rel_2008_0923, mgrast_rel_2008_0919, mgrast_rel_2008_1110, rast_rel_2008_09_29, mgrast_rel_2008_0917, rast_rel_2008_10_29, rast_rel_2008_11_24
Changes since 1.3: +6 -3 lines
Fixed to allow SEED-mode testing on NMPDR machines.

package WebComponent;

# WebComponent - abstract web component class 

# $Id: WebComponent.pm,v 1.4 2008/09/04 18:59:15 parrello Exp $

use strict;
use warnings;
use FIG_Config;


=head1 NAME

WebComponent - abstract web component class


This module is the abstract WebComponent class used by the web application
framework. A web component is a reusable page element inherited from this
class. Each component is assigned an unique id (to support javascript 
operations on the components). 

Using a web component is done by requesting the component from the application,
then setting parameters as supported by the specific component and finally
returning the html output of the component.

=head1 METHODS

=over 4

=item * B<new> (I<application>, I<id>)

Creates a new instance of the WebComponent object. The constructor requires
a reference to the web application object and an (unique) id. Unique ids 
are used to manipulate html elements by javascript.


sub new {
    my ($class, $application, $id) = @_;

    # check application
    unless (ref $application and $application->isa("WebApplication")) {
      die "Invalid application in __PACKAGE__ new.";
    $id = '' unless (defined $id);
    my $sv_url = "$FIG_Config::cgi_url/seedviewer.cgi";
    if (FIGRules::nmpdr_mode($application->cgi) && $FIG_Config::linkinSV) {
	$sv_url = $FIG_Config::linkinSV;
    my $self = { 'application' => $application, 
		 'id'          => $id,
		 'css'         => undef,
                 'svURL'       => $sv_url,
    bless $self, $class;

    return $self;


=item * B<application> ()

Returns the reference to the application object


sub application {
  return $_[0]->{'application'};


=item * B<svURL> ()

Returns the Seed Viewer URL


sub svURL {
    return $_[0]->{svURL};


=item * B<id> ()

Returns the numerical id of the web component


sub id {
  return $_[0]->{'id'};


=item * B<get_trigger> (I<action_name>)

Returns a unique cgi action param based on the I<action_name>.


sub get_trigger {
  return 'wac_'.$_[0]->id.'_'.$_[1];


=item * B<require_javascript> ()

Returns a reference to an array of javascript files to include into the 
output page. By default the method returns the reference to an empty 
array. Overload in inherited web components as needed.


sub require_javascript {
  return [ ];


=item * B<require_css> (I<css_file>)

Returns the name of the css file to include into the the html of the web component.
If the optional parameter I<css_file> is given, the component will require that
css file instead of the default one.


sub require_css {
  if ($_[1]) {
    $_[0]->{'css'} = $_[1];
  return $_[0]->{'css'};


=item * B<output> ()

Returns the html of the web component


sub output {
  die "Abstract method 'output' must be implemented in __PACKAGE__.\n";


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3