Sergey Rusakov > ePortal-4.5 > dialog.mc

Download:
ePortal-4.5.tar.gz

Annotate this POD

View/Report Bugs
Source  

NAME ^

dialog.mc - Dialog contruction module.

SYNOPSIS ^

This Mason component replaces obsoleted ePortal::HTML::Dialog package.

dialog.mc is used to draw a dialog like windows. Some methods are used for easy creation of dialogs to edit ThePersistent objects.

Usage

 <&| /dialog.mc, parameters ... &>
  content of the dialog
 </&>

 <%method onStartRequest><%perl>
  $obj = new ePortal::Catalog;
  $m->comp('/dialog.mc:handle_request', obj => $obj);
 </%perl></%method>

Parameters

METHODS ^

edit_dialog

This method used to construct "Edit an object" dialog with a submit form iside.

WARNING! This method generates

 <table cols="2">
  Your content here
 </table>

Parameters:

form

Generate HTML form. See field methods for details how to generate HTML fields.

 <& /dialog.mc:form, parameters, ... &>

DIALOG FORM FIELDS ^

Most of dialog field creation method accepts the following parameters:

cell

Draw a cell for edit_dialog. That is is <td colspan="2">. All -xxx like parameters are passed to CGI::td() function.

label_value_row

Draw a row with two cells: label and value

canvas

Display content inside a canvas.

 <&| /dialog.mc:canvas, label => ..., parameters, ... &>
  dialog value
 </&>

 <canvas>
  <% optional label %>
  <% $m->content %>
 </canvas>

field

Discover field type with a help of fieldtype attribute of the object and call appropriate method of dialog.mc. Default field type is textfield.

This is default method to produce a dialog field. This method created a row of table

 <tr>
   <td>label:</td> <td>field</td>
 </tr>

hidden

/dialog.mc:hidden - generate hidden field

popup_menu

Generates list box aka popup_menu.

radio_group

Generates radio button group.

textfield

Generate text field.

See DIALOG FORM FIELDS for other parameters.

password

Generate password input field.

See DIALOG FORM FIELDS for other parameters.

textarea

Generate text area field.

See DIALOG FORM FIELDS for other parameters.

xacl_field

Generate ACL property field.

See DIALOG FORM FIELDS for other parameters.

upload

Generate file upload field.

See DIALOG FORM FIELDS for other parameters.

yes_no

Generates list box or checkbox to input YES or NO.

checkbox

Generates checkbox tag.

date

Generates date input field.

read_only

Generate text read only field.

See DIALOG FORM FIELDS for other parameters.

buttons

Display dialog buttons.

 <& /dialog.mc:buttons, parameters, ... &>

Possible button names are: ok, cancel, more, delete, apply.

To diplay a button pass parameter xxx_button => 1

To change predefined label of a button pass parameter xxx_label => "..."

ok and cancel buttons are displayed by default.

_table3td

Internal method. Do not use it! Used to produce one row table with three cells. This is the correct way to align a table.

 td1     td2     td3

REQUEST HANDLING METHODS ^

handle_request

This the engine of dialog. Call it from onStartupRequest method for proper redirect handling.

This method does the following:

  1. restore_or_throw object to edit
  2. htmlSave parameters from request
  3. if ok button is pressed then save the object and redirect to back_url
  4. if cancel button is pressed then just redirect to back_url

htmlSave

Safely get attributes values from request and apply them to the object with object->htmlSave2(). This method does not updates the object in database. Do it yourself.

This method does extra processing for special multipart attributes like DateTime, xacl_field, etc...

This method does not updates ID attributes.

isButtonPressed

Check is a button was pressed on dialog.

Every standard dialog button named as dlgb_NAME. If no dlgb_NAME parameter exists in request then isButtonPressed('ok') returns true on dialog submit.

back_url

Calculates URL where to return (redirect) from Dialog when a button will pressed.

DATA FLOW ^

 handle_request()     dialog.mc     
  htmlSave()          dialog.mc      handler DateTime, xacl fields
  htmlSave2()         Support.pm     this called 
  value_from_req()    Support.pm     for each attribute to save
  value()
 update() or insert() Base.pm
  validate()

AUTHOR ^

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

syntax highlighting: