Sergey Rusakov > ePortal-4.5 > list.mc

Download:
ePortal-4.5.tar.gz

Annotate this POD

View/Report Bugs
Source  

NAME ^

list.mc - List of something as HTML table

SYNOPSIS ^

This Mason component replaces absoleted ePortal::HTML::List package.

It is used to create HTML tables for iterable objects and arrays.

 <&| /list.mc, id=>'list1', obj => $object OR  list => [@array] &>

  <&| /list.mc:row, parameters &>   # this method is optional
    <& /list.mc:column, parameters &>
    <& /list.mc:column_image, src => ... &>
  </&> # end of row
  <&| /list.mc:extra_row &>
     ...
  </&>

  # These method going after all "column" methods
  <&| /list.mc:before_title &> ...  </&>
  <&| /list.mc:after_title &> ...  </&>
  <&| /list.mc:before_footer &> ...  </&>
  <&| /list.mc:after_footer &> ...  </&>

  <&  /list.mc:row_span &>
 </&> # end of list

The typical list consists of the following:

 <table>
  <form>

   <before_title row>
   <title row>
   <after_title row>

     <one or more rows>
      <extra_row for each row>

   <before_footer row>
   <footer row>
   <action_bar row>
   <after_footer row>

  </form>
 </table>

The content of <&| list.mc &> is responsible for HTML generation of each row.

The very first call to content is when row_number==0. This call is used to count all columns, create soring groups and discover column titles. ThePersistent object is not restored at this moment and $_ is undefined for array lists.

Use local variable $_ as iterator for array. $_ is the object for ThePersistent lists.

PARAMETERS ^

All -xxx like parameters are passed directly to CGI::start_table. Others are

METHODS ^

row

Generic method to make a row. Call once per list content. Use extra_row method if you need more than one row per iteration.

This is optionsl method. list.mc call it implicitly at least once if you don't.

 <&| /list.mc:row &>
  <& /list.mc:column &>
  ...
 </&>

 <&| /list.mc:extra_row &>
  this is additional row
 </&>

extra_row

Produce "extra" row in the same style as main row. Used for description and memos

row_span

Make a space between rows.

 <&| list.mc:row &>
  ...
 </&>
 <& list.mc:row_span &>

action_bar

Action bar below footer consists of two cells. Left is your content and right is popup_menu with submit button. The name of popup_menu is list_action. You may get it with list_action method or as $ARGS{list_action}.

Array of ID of selected checkboxes available with checkboxes method.

checkboxes

Returns array ID of checked checkboxes or empty array.

list_action

Returns a value of list_action popup_menu or undef if form was not submitted. The fact of submit is request method eq 'POST'.

column

Generic method to make a column. Call it as many times as many columns you have. Place the calls inside row method.

column_image

A column with image.

column_delete

Produce delete button.

column_edit

Produce "edit object" button.

column_checkbox

Produce checkbox column

column_number

Row number counter

state

Returns HASH of arguments that represent current state of the list. Put these parameters to other forms on the page to save list apperance untouched.

self_url

Return self referencing URL without checkboxes selected.

state_as_hidden

Put list state as hidden fields into your form

before_title,after_title,before_footer,after_footer

This method used to insert a text before|after title|footer row. Place it AFTER all column methods. The content of method method is placed into one wide TD cell. Arguments are:

 <&| /list.mc:before_title &>
  this text goes before title row
 </&>

nodata

What to show when no data available in recordset?

REQUEST ARGUMENTS ^

These arguments are significant for list.mc when exists in request. See state method for convenient way to get hash of all of them.

AUTHOR ^

Sergey Rusakov, <rusakov_sa@users.sourceforge.net>

syntax highlighting: