The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::Widget::Compound - A non-visual compound of other (presumably) visual widgets

SYNOPSIS

 $conf = {
   SessionObject => {
     begin_datetime => {
       class  => "App::Widget::Compound",
       components => [ "begin_yr", "begin_mon", "begin_day", "begin_hr", "begin_min", "begin_sec", ],
       parse  => "^([0-9]{4})-([0-9][0-9])-([0-9][0-9]) ([0-9][0-9]):([0-9][0-9]):([0-9][0-9])$",
       format => "%04d-%02d-%02d %02d:%02d:%02d",
     }
     end_datetime => {
       class  => "App::Widget::Compound",
       components => [ "end_yr", "end_mon", "end_day", ],
       separator  => "-",
     }
   },
 };

DESCRIPTION

This class is a non-visual compound of other (presumably) visual widgets. However, it must be "displayed" so that event-html is created (an <input type="hidden"> tag).

The role of a Compound widget is to keep the joined compound value in sync with the split component values. Thus, when the form is submitted an event is fired to join() the component values into the compound value.

Processing then occurs, presumably affecting the value of the compound widget directly.

When the compound widget is "displayed" with an html() call, its value is split out into the component values. This should happen before the component widgets are displayed or the wrong values will be shown. This may be done by placing the compound widget higher on the page than its components or by making an explicit call to split() in the code.