HTML::GUI::select - Create and control a select input for webapp


NAME

HTML::GUI::select - Create and control a select input for webapp


VERSION

Version 0.01


SELECT

The select widget is made for choose an item in limited list.


PUBLIC ATTRIBUTES


PUBLIC METHODS

new

isNewValue Description : return 1 if the value already exist in the widget's options else return 0

  parameter :
          the newValue (scalar) to test
=cut

sub isNewValue($$) { my ($this,$newValue) = @_;

                foreach my $option (@{$this->{options}}){
                                if ($newValue eq $option->{value}){
                                                return 0;
                                }
                }
                return 1;
                }

setOptions

   Description : 
      Define the options of the select box.
                parameters :
                                $options is a ref to an array of hash ref
                                [{      value           =>      "myvalue",
                                                label           =>      "my label},
                                 {      value           =>      "myvalue2",
                                                label           =>      "my second label}]
                =cut
                

sub setOptions { my ($this,$options) = @_; if (!$options || ref $options ne 'ARRAY'){ $this->error("priv",{ type=>'incorrect use of API', 'explanation' => '$option should be an ARRAY ref', option => $options});


                }
                foreach my $oneOption (@$options){
                                if (ref $oneOption ne "HASH"
                                                                || !exists $oneOption->{value}
                                                                || !exists $oneOption->{label}){
                                                #wrong data structure !!
                                                $this->error("priv",{
                                                        type=>'incorrect use of API',
                                                        'explanation' => '$oneOption should be a hash ref '
                                                                                                                                        .'with ˝value" and "label" keys',
                                                        option => $oneOption});
                                                next;
                                }
                                $oneOption->{value} ||= '';
                                $oneOption->{label} ||= '';
                                if (!$this->isNewValue($oneOption->{value}) ){
                                                #value already used !!!
                                                $this->error("priv",{
                                                                        type=>'incorrect use of API',
                                                                        'explanation' => 'the value of $oneOption is already '
                                                                                                                                                        .'present in the widget',
                                                                        option => $oneOption});
                                                next;
                                }
                                push @{$this->{options}} , $oneOption; 
                                                }

}

getDefinitionData


  This method is the specialisation of the widget.pm method, refer to the widget.pm manual for more information.

getNudeHtml

   Description : 
      Return the html of the widget to be inserted in a <p> tag or a a table.


AUTHOR

Jean-Christian Hassler, <jhassler at free.fr>


BUGS

Please report any bugs or feature requests to bug-gui-libhtml-select at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc HTML::GUI::widget

You can also look for information at:


ACKNOWLEDGEMENTS


COPYRIGHT & LICENSE

Copyright 2007 Jean-Christian Hassler, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

 HTML::GUI::select - Create and control a select input for webapp