A module which provides a generic WSF component for creating edit frontends for any kind of data tuples. See "wsf_edit_sql" for an implementation.object WsfEdit WsfComponent
This is a base object for WSF components which assemble edit frontends for any kind of data tuples. Usually one would not use this object directly but an object which is derived from it, such as WsfEditSql. A 'data tuple' may be anything that can be represented as list of key-value pairs, such as a tuple from an SQL table. The basic idea is that the methods edit_load() and edit_save are overloaded so they can load and save the data tuple to be edited. The get_html() method should also be overloaded so it evaluates a template which is using the methods edit_input(), edit_textarea and edit_select() for creating the form elements. An example for using WsfEdit can be found in the documentation of WsfEditSql. This object is derived from WsfComponent.
var WsfEdit.edit_data;
A hash containing the data tuple. When edit_save() is called, this contains the data sent to the browser, not the new data returned by the user. This can be used to check if the data has actually been modified.
var WsfEdit.edit_fields;
The fields included in the edit form generated. This can be used to check which fields in the tuple have actually been shown to the user. The edit_save() method should only save the fields defined in this hash. This is especially important if the template includes some fields conditionally, e.g. because the user has not the accurate permissions to edit all fields.
var WsfEdit.edit_actions;
This hash can be used to define additional actions to be executed instead of simply calling edit_save(). If a query string parameter matches a key defined in that hash, the value of that hash entry will be executed (as function/method pointer) and edit_save(). Won't be called. Usually this is used to implement things such as "Back to List" buttons.
var WsfEdit.just_updated;
The edit_save() method should set this variable to '1' when is saved the new data. This can e.g. be used by the template to display a "Database updated" message.
method WsfEdit.edit_reset();
This method must be executed by get_html() before evaluating the template. It resets edit_fields and calls edit_load().
method WsfEdit.edit_input(field, %opt);
Returns the HTML code for a input box. The parameter 'field' is a key in the edit_data hash. The following named parameters are supported: style value for the css style attribute size value for the size attribute Simply include that function in your template using the ${ .. } substitution.
method WsfEdit.edit_textarea(field, %opt);
Returns the HTML code for a textarea. The following named parameters are supported: style value for the css style attribute cols value for the cols attribute rows value for the rows attribute (see also edit_input())
method WsfEdit.edit_select(field, list, %opt);
Returns the HTML code for a select box. The list parameter is a hash with the possible values as keys and the description texts as values. The following named parameters are supported: style value for the css style attribute emptydesc If this parameter is defined, an additional option with that description and an empty value is added as first option to the list of possible options. (see also edit_input())
method WsfEdit.edit_load();
This method must be overloaded. It must fill the edit_data hash with values.
method WsfEdit.edit_save();
This method must be overloaded. For all keys defined in edit_fields, it must update the values in the backend storage. The data must be obtained from 'cgi.param["edit_$keyname"]'. It is possible to compare the new values with the old values in edit_data to see if the values have actually changed. The variable just_updated must be set to '1' if anything has been updated.
method WsfEdit.main();
Overloaded WsfComponent.main().
method WsfEdit.get_html();
Overloaded WsfComponent.get_html(). This method must be overloaded again by object actually implementing an editor. The method edit_reset() must be called in the very beginning of that method.
method WsfEdit.init();
Constructor.
Generated by SPLDOC. | http://www.clifford.at/spl/ |