Solstice::Controller::FormInput::TextArea - Collects form input from a <textarea>


Solstice documentation Contained in the Solstice distribution.

Index


Code Index:

NAME

Top

Solstice::Controller::FormInput::TextArea - Collects form input from a <textarea>

SYNOPSIS

Top

DESCRIPTION

Top

Export

None by default.

Methods

new()
new($model)

Constructor.

getView()

Creates the view object for the home page.

update()
validate()
isModelTainted()

AUTHOR

Top

Educational Technology Development Group, <catalyst@u.washington.edu>

VERSION

Top

$Revision: 25 $

SEE ALSO

Top

COPYRIGHT

Top


Solstice documentation Contained in the Solstice distribution.
package Solstice::Controller::FormInput::TextArea;

# $Id: TextArea.pm 25 2006-01-14 00:50:12Z jlaney $

use strict;
use warnings;
use 5.006_000;

use base qw(Solstice::Controller::FormInput);

use Solstice::View::FormInput::TextArea;

use Solstice::CGI;
use Solstice::StringLibrary qw(trimstr);

use constant TRUE  => 1;
use constant FALSE => 0;

use constant PARAM => 'htmltextarea';

sub new {
    my $class = shift;
    my $self = $class->SUPER::new(@_);

    $self->_setControl($self->getModel());
    
    return $self;
}

sub getView {
    my $self = shift;

    my $view = Solstice::View::FormInput::TextArea->new($self->getModel());
    $view->setName($self->getName() || PARAM);
    
    return $view;
}

sub update { 
    my $self = shift;

    $self->setModel(trimstr(param($self->getName() || PARAM)));
    
    return TRUE;
}

sub validate { 
    my $self = shift;

    my $name = $self->getName() || PARAM;

    my $param = $self->getIsRequired()
        ? $self->createRequiredParam($name)
        : $self->createOptionalParam($name);

    return $self->processConstraints();
}

sub isModelTainted {
    my $self = shift;

    my $old_content = $self->_getControl() || '';
    my $new_content = $self->getModel()    || '';
    #warn "\nOld: ".$old_content."\n";
    #warn "\nNew: ".$new_content."\n\n";
    return ($old_content ne $new_content) ? TRUE : FALSE;
}

sub _setControl {
    my $self = shift;
    $self->{'_control'} = shift;
}

sub _getControl {
    my $self = shift;
    return $self->{'_control'};
}

sub setFocusEditor {
    my $self = shift;
    $self->{'_focus_editor'} = shift;
}

sub getFocusEditor {
    my $self = shift;
    return $self->{'_focus_editor'};
}

1;
__END__