Class ::Generic::List (public)

 ::xotcl::Class ::Generic::List[i] [ -actions actions ] \
    [ -bulk_action_method bulk_action_method ] [ -elements elements ] \
    [ -rows_per_page rows_per_page ] [ -row_code row_code ] \
    [ -class class ] [ -no_create_p no_create_p ] \
    [ -create_url create_url ] [ -no_edit_p no_edit_p ] \
    [ -edit_url edit_url ] [ -edit_template edit_template ] \
    [ -no_delete_p no_delete_p ] [ -delete_url delete_url ] \
    [ -delete_template delete_template ] [ -package_id package_id ] \
    [ -html_class html_class ] [ -html_main_class html_main_class ] \
    [ -html_sub_class html_sub_class ]

Defined in /var/www/openacs.org/packages/xotcl-core/tcl/generic-procs.tcl

Simple OO interface to template::list. This class has been built to allow quick creation of list UIs for generic acs_objects.

Many parameters are homonymous to those for template::list::create and work in the same way, unless stated differently in this documentation.

Despite the high number of object's members, most of them are there for backward compatibility with the procedural API and they seldom need to be specified.

An example of instantiation could just look as this:

    # Must be an existing acs_object class on the system.
    set class "::dev::Location"

    # As we are talking about acs_objects, our 'delete'
    # page could of course be the same for every object
    # in the system.
    ::Generic::List create list1  -class $class  -package_id $package_id  -rows_per_page $rows_per_page  -delete_url "../delete"  -elements {
          name {
            label "Name"
          }
          street {
            label "Street"
          }
          number {
            label "Number"
          }
          city {
            label "City"
          }
          region {
            label "Region"
          }
          country {
            label "Country"
          }
          coords {
            label "Coordinates"
          }
        } -orderby {
          default_value name
          name {
            label "Name"
            orderby_desc "name desc"
            orderby_asc "name asc"
          }
        } -row_code {
          set coords "$latitude $longitude"
        }

    list1 generate
    
...while the ADP template would include this:
    <listtemplate name="list1"></listtemplate>
    
Notice that in this case we didn't have to specify queries, nor populate any multirow by hand: they have come directly from class's data-model. A list built in this way will be paginated automatically.

Switches:
-actions (optional)
Behaves as in template::list::create. If missing, can be automatically generated acting on create_url and no_create_p parameters (see below).
-bulk_action_method (optional)
Behaves as in template::list::create, but will default to POST method, as it is safer with respect to possible high number of query parameters.
-elements (optional)
Behaves as in template::list::create. It must be possible to build every element either through class's instance members, or programmatically (see row_code below).
-rows_per_page (optional)
Behaves as template::list::create's page_size parameter. Pagination is automatically for this class. To turn it off, just set this parameter to "" .
-row_code (optional)
This snippet will be executed for every instance/row in the list, so is similar in spirit to code_block argument for db_multirow. This will allow the user to build programmatically other elements outside object's data model, override edit and delete url and so on. Code will have access to every variable in the caller scope and to each instance's variable.
-class (optional)
Is the class (descendant of acs_object) for which this list will be built.
-no_create_p (optional)
Tells to the list we don't want instance creation action button to be built automatically.
-create_url (optional)
When instance creation url is automatically built, tells the list to which url make it point.
-no_edit_p (optional)
Tells to the list we don't want instance edit action button to be built automatically.
-edit_url (optional)
When instance edit element is automatically built, tells the list to which url make it point. Page pointed must accept an item_id parameter, that will be the primary key of edited instance.
-edit_template (optional)
When instance edit element is automatically built, use this template to build the element.
-no_delete_p (optional)
Tells to the list we don't want instance delete action button to be built automatically.
-delete_url (optional)
When instance delete url is automatically built, tells the list to which url make it point. Page pointed must accept an item_id parameter, that will be the primary key of deleted instance.
-delete_template (optional)
When instance delete element is automatically built, use this template to build the element.
-package_id (optional)
Is the package for this instance. It has no use for now.
-html_class (optional)
Behaves as class parameter in template::list::create.
-html_main_class (optional)
Behaves as main_class parameter in template::list::create.
-html_sub_class (optional)
Behaves as sub_class parameter in template::list::create.
Author:
Antonio Pisano <antonio@elettrotecnica.it>

Testcases:
No testcase defined.
[ show source ]
Show another procedure: