Re: [Perl-widget-developer] Dynamically configured Widgets
Status: Alpha
Brought to you by:
spadkins
|
From: Stephen A. <ste...@of...> - 2001-06-05 15:51:37
|
Cees,
At 08:07 PM 6/5/2001 +1000, Cees Hek wrote:
...
>I guess what I am looking for is some hooks that allow developers to
>generate widgets without requiring a configuration file. There are 2
>situation where I think this is necesary.
I agree.
This needs to be well-supported.
I did not originally think so.
I originally thought that every attribute should be required to be
configured from the config file.
Now I think that every configurable attribute should be *able* to be
configured from the config file, but that it should also be *able* to
be overridden by the constructor parameters.
In fact, I think I can envision the internal plumbing of the objects
getting a whole lot simpler...
>First situation: If we build a complex widget by combining several simple
>widgets (a good example is the DateDropDowns widget), then the simple
>widgets should not be required to be configured by the config file.
>Using the DateDropDowns as an example, there are never going to be more
>than 31 days in a month, so why waste config file space to hold them?
>The config file should contain options and values that the user may want
>to change, if it doesn't make sense to change it, then it shouldn't be in
>the config file.
Right.
>So the DateDropDowns.pm code should be able to do somethin like this:
>$date.day = $wc->widget(-name => 'date.day',
> -class => 'Widget::HTML::Select',
> -values => ['01'..'31']);
>
>The same can be done for months and years, although we could add a config
>option that asks if they want to use full months (ie 'January',
>'February') or short months (ie 'Jan', 'Feb'), and perhaps the range of
>years to include in the widget.
Right.
>This way the user doesn't need to know anything about the 'sub-widgets'
>that DateDropDowns uses internally. It will make the configuration files
>much cleaner and user friendly...
>
>
>The second situation is where you need a dynamic widget. For example a
>select box where the options depend on a database query.
>
>$sth = $dbh->prepare(q{
> SELECT category_id, category_name
> FROM categories
> ORDER BY category_name
>});
>$sth->execute();
>$data = $sth->fetchall_arrayref();
>$categories = $wc->widget(-name => 'categories', -values => $data);
>
>Where -values will contain a 2 dimensional array of values and labels (or
>some similar mechanism)
I actually would like to create data-bound controls as well,
where the SQL to populate the controls can be configured into the
config file and the values are populated at run time.
>Comments ??
See above.
>Cees Hek
Stephen
|