NAME

Net::Jabber::X::Form::Field::Option - Jabber X Form Field Option Module

SYNOPSIS

Net::Jabber::X::Form::Field::Option is a companion to the 
Net::Jabber::X::Form::Field module.  It provides the user a simple 
interface to set and retrieve all parts of a Jabber Form Field
Option.

DESCRIPTION

  To initialize the Option with a Jabber <x/> and then access the </x>
  you must pass it the XML::Parser Tree array from the 
  Net::Jabber::Client module.  In the callback function for the object
  type foo:

    use Net::Jabber;

    sub foo {
      my $foo = new Net::Jabber::Foo(@_);

      my @xTags = $foo->GetX("jabber:x:form");

      my $xTag;
      foreach $xTag (@xTags) {
        my @fields = $xTag->GetFields();
	my $field;
	foreach $field (@fields) {
	  if ($field->GetType() eq "option") {
	    foreach my $option ($field->GetOptions()) {
	      $option->GetXXXX();
	    }
	  }
	  .
	  .
	  .
	}
      }
      .
      .
      .
    }

  You now have access to all of the retrieval functions available below.

  To create a new X Form Field Option to send to another user:

    use Net::Jabber;

    $Client = new Net::Jabber::Client();
    ...

    $foo = new Net::Jabber::Foo();
    $form = $foo->NewX("jabber:x:form");
    $field = $form->AddField(tpye=>"option");
    $option = $field->AddOption();
    ...

    $client->Send($foo);

  Using $field you can call the creation functions below to populate the 
  tag before sending it.

  For more information about the array format being passed to the CallBack
  please read the Net::Jabber::Client documentation.

Retrieval functions

$label  = $option->GetLabel();
$value  = $option->GetValue();

@option = $option->GetTree();
$str    = $option->GetXML();

Creation functions

    $option->SetOption(label=>"Male",
		       value=>"m");

    $option->SetLabel('Yes');
    $option->SetValue('1');

Test functions

$test = $option->DefinedLabel();
$test = $option->DefinedValue();

METHODS

Retrieval functions

GetLabel() - returns a string with the label that the option should have
             in the GUI.

GetValuel() - returns a string with the value that the option should have
              when selected.

GetXML() - returns the XML string that represents the <presence/>.
           This is used by the Send() function in Client.pm to send
           this object as a Jabber Presence.

GetTree() - returns an array that contains the <presence/> tag
            in XML::Parser Tree format.

Creation functions

SetOption(label=>string, - set multiple options in the <option/>
          value=>string)   at one time.  This is a cumulative
                           and overwriting action.  If you
                           set the "label" twice, the second
                           setting is what is used.  If you set
                           the label, and then set the
                           value then both will be in the
                           <option/> tag.  For valid settings
                           read the specific Set functions below.

SetLabel(string) - sets the label to show in the GUI for this option.

SetValue(string) - sets the value to set the field to when this option
                   is selected in the GUI.

Test functions

DefinedLabel() - returns 1 if the label attribute is set in the <field/>,
                 0 otherwise.

DefinedValue() - returns 1 if the value attribute is set in the <field/>,
                 0 otherwise.

AUTHOR

By Ryan Eatmon in February of 2001 for http://jabber.org..

COPYRIGHT

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