package WebGUI::Asset::Wobject::NewWobject;

$VERSION = "1.0.0";

#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com                     info@plainblack.com
#-------------------------------------------------------------------

use strict;
use Tie::IxHash;
use WebGUI::International;
use WebGUI::Utility;
use base 'WebGUI::Asset::Wobject';

# To get an installer for your wobject, add the Installable AssetAspect
# See WebGUI::AssetAspect::Installable and sbin/installClass.pl for more
# details

#-------------------------------------------------------------------

=head2 definition ( )

=cut

sub definition {
    my $class      = shift;
    my $session    = shift;
    my $definition = shift;
    my $i18n       = WebGUI::International->new( $session, 'Asset_NewWobject' );
    tie my %properties, 'Tie::IxHash', (
        templateIdView => {
            fieldType   => "template",
            tab         => "display",
            namespace   => '', # XXX Fill in namespace
            label       => $i18n->get('templateId label'),
            hoverHelp   => $i18n->get('templateIdView description'),
        },
        # XXX Add your properties
    );
    push @{$definition}, {
        assetName         => $i18n->get('assetName'),
        icon              => 'newWobject.gif',
        autoGenerateForms => 1,
        tableName         => 'NewWobject',
        className         => 'WebGUI::Asset::Wobject::NewWobject',
        properties        => \%properties
        };
    return $class->SUPER::definition( $session, $definition );
} ## end sub definition

#-------------------------------------------------------------------

=head2 prepareView ( )

See WebGUI::Asset::prepareView() for details.

=cut

sub prepareView {
    my $self = shift;
    $self->SUPER::prepareView();
    my $template = WebGUI::Asset::Template->new( $self->session, $self->get("templateIdView") );
    $template->prepare($self->getMetaDataAsTemplateVariables);
    $self->{_viewTemplate} = $template;
}

#-------------------------------------------------------------------

=head2 view ( )

method called by the www_view method.  Returns a processed template
to be displayed within the page style.  

=cut

sub view {
    my $self    = shift;
    my $session = $self->session;
    my $var = $self->get;
    return $self->processTemplate( $var, undef, $self->{_viewTemplate} );
}

1;

#vim:ft=perl
