cvsuser     02/03/22 15:08:13

  Modified:    P5EEx/Blue/P5EEx/Blue/Widget HTML.pm
  Log:
  moved methods around and began documenting them
  
  Revision  Changes    Path
  1.6       +123 -64   p5ee/P5EEx/Blue/P5EEx/Blue/Widget/HTML.pm
  
  Index: HTML.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/P5EEx/Blue/P5EEx/Blue/Widget/HTML.pm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- HTML.pm   12 Mar 2002 16:57:34 -0000      1.5
  +++ HTML.pm   22 Mar 2002 23:08:13 -0000      1.6
  @@ -1,10 +1,10 @@
   
   ######################################################################
  -## $Id: HTML.pm,v 1.5 2002/03/12 16:57:34 spadkins Exp $
  +## $Id: HTML.pm,v 1.6 2002/03/22 23:08:13 spadkins Exp $
   ######################################################################
   
   package P5EEx::Blue::Widget::HTML;
  -$VERSION = do { my @r=(q$Revision: 1.5 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r};
  +$VERSION = do { my @r=(q$Revision: 1.6 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r};
   
   use P5EEx::Blue::Widget;
   @ISA = ( "P5EEx::Blue::Widget" );
  @@ -21,16 +21,114 @@
   
   =cut
   
  -######################################################################
  -# METHODS
  -######################################################################
  +#############################################################################
  +# PUBLIC METHODS
  +#############################################################################
  +
  +=head1 Public Methods:
  +
  +=cut
  +
  +#############################################################################
  +# display()
  +#############################################################################
  +
  +# I'm not sure whether an HTML widget should have a display() method.
  +# HTML widgets do not have the power to display themselves.
  +# They can only render themselves as HTML.
  +# If the Context decides this should be sent to the browser, that is
  +# its choice and not an action of the widget itself.
  +# However, this is a convenient place to put protections agains exceptions.
  +# Perhaps it should be called something else, but it definitely has a role.
  +
  +=head2 display()
  +
  +    * Signature: $text = $widget->display();
  +    * Param:     void
  +    * Return:    $text              text
  +    * Throws:    P5EEx::Blue::Exception::Widget
  +    * Since:     0.01
  +
  +    Sample Usage:
  +
  +    $text = $widget->display();
  +
  +=cut
  +
  +sub display {
  +    my $self = shift;
  +
  +    my ($html);
  +    $self->{context}->dbgprint("P5EEx::Blue::Widget::HTML(", $self->{name}, 
")->display()")
  +        if ($P5EEx::Blue::DEBUG && $self->{context}->dbg(1));
  +
  +    eval {
  +        $html = $self->html();
  +    };
  +    if ($@) {
  +        my ($name, $msg);
  +        if (ref($@) eq "") {  # i.e. a string thrown with "die"
  +            $msg = $@;
  +        }
  +        elsif ($@->isa("P5EEx::Blue::Exception")) {
  +            $msg = $@->error . "\n" . $@->trace->as_string . "\n";
  +        }
  +        else {
  +            $@->rethrow();
  +        }
  +        $msg =~ s{&}{&}gso;
  +        $msg =~ s{<}{&lt;}gso;
  +        $msg =~ s{>}{&gt;}gso;
  +        $msg =~ s{\"}{&quot;}gso;
  +        $msg =~ s{\n}{<br>\n}gso;
  +        $name = $self->{name};
  +        $html = <<EOF;
  +<table border="1" cellspacing="0">
  +<tr><td bgcolor="#aaaaaa">
  +<b>Widget Display Error: $name</b><br>
  +</td></tr>
  +<tr><td bgcolor="#ffaaaa">
  +<font size="-1" face="sans-serif">
  +$msg
  +</font>
  +</td></tr>
  +</table>
  +EOF
  +    }
  +    return $html;
  +}
  +
  +#############################################################################
  +# PROTECTED METHODS
  +#############################################################################
  +
  +=head1 Protected Methods:
  +
  +=cut
  +
  +#############################################################################
  +# user_event_name()
  +#############################################################################
  +
  +=head2 user_event_name()
  +
  +    * Signature: $text = $widget->user_event_name($event,@args);
  +    * Param:     void
  +    * Return:    $text              text
  +    * Throws:    P5EEx::Blue::Exception::Widget
  +    * Since:     0.01
  +
  +    Sample Usage:
  +
  +    $name = $self->user_event_name("open","folder","1.1");
  +    $html .= "<input type='submit' name='$name' value='Push Me'>\n";
  +
  +=cut
   
   # Creates a name suitable for use in <input type=submit> and
   # <input type=image> tags that will cause an event to be
   # handled when the form is posted back to the web server.
   # i.e.
  -#    $name = $self->user_event_name("open","folder","1.1");
  -#    $html .= "<input type='submit' name='$name' value='Push Me'>\n";
   
   sub user_event_name {
       my ($self, $event, @args) = @_;
  @@ -41,10 +139,26 @@
       "p5ee.event.{${name}}.${event}${args}";
   }
   
  +#############################################################################
  +# callback_event_tag()
  +#############################################################################
  +
  +=head2 callback_event_tag()
  +
  +    * Signature: $text = $widget->callback_event_tag($event,@args);
  +    * Param:     void
  +    * Return:    $text              text
  +    * Throws:    P5EEx::Blue::Exception::Widget
  +    * Since:     0.01
  +
  +    Sample Usage:
  +
  +    $html .= $self->callback_event_tag("open","folder","1.1");
  +
  +=cut
  +
   # Creates an <input type=hidden> tag that will cause an event to be
   # automatically handled when the form is posted back to the web server.
  -# i.e.
  -#    $html .= $self->callback_event_tag("open","folder","1.1");
   
   sub callback_event_tag {
       my ($self, $event, @args) = @_;
  @@ -112,61 +226,6 @@
   
      $url = "${protocol}://${server}${port_str}";
      $url;
  -}
  -
  -######################################################################
  -# OUTPUT METHODS
  -######################################################################
  -
  -# I don't think an HTML widget should have a display() method.
  -# HTML widgets do not have the power to display themselves.
  -# They can only render themselves as HTML.
  -# If the Context decides this should be sent to the browser, that is
  -# its choice and not an action of the widget itself.
  -# However, this is a convenient place to put protections agains exceptions.
  -# Perhaps it should be called something else, but it definitely has a role.
  -
  -sub display {
  -    my $self = shift;
  -
  -    my ($html);
  -    $self->{context}->dbgprint("P5EEx::Blue::Widget::HTML(", $self->{name}, 
")->display()")
  -        if ($P5EEx::Blue::DEBUG && $self->{context}->dbg(1));
  -
  -    eval {
  -        $html = $self->html();
  -    };
  -    if ($@) {
  -        my ($name, $msg);
  -        if (ref($@) eq "") {  # i.e. a string thrown with "die"
  -            $msg = $@;
  -        }
  -        elsif ($@->isa("P5EEx::Blue::Exception")) {
  -            $msg = $@->error . "\n" . $@->trace->as_string . "\n";
  -        }
  -        else {
  -            $@->rethrow();
  -        }
  -        $msg =~ s{&}{&amp;}gso;
  -        $msg =~ s{<}{&lt;}gso;
  -        $msg =~ s{>}{&gt;}gso;
  -        $msg =~ s{\"}{&quot;}gso;
  -        $msg =~ s{\n}{<br>\n}gso;
  -        $name = $self->{name};
  -        $html = <<EOF;
  -<table border="1" cellspacing="0">
  -<tr><td bgcolor="#aaaaaa">
  -<b>Widget Display Error: $name</b><br>
  -</td></tr>
  -<tr><td bgcolor="#ffaaaa">
  -<font size="-1" face="sans-serif">
  -$msg
  -</font>
  -</td></tr>
  -</table>
  -EOF
  -    }
  -    return $html;
   }
   
   1;
  
  
  


Reply via email to