LEGAL

#===========================================================================

Copyright (C) 2008 by Nik Ogura. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Bug reports and comments to nik.ogura@gmail.com.

#===========================================================================

NAME

CGI::Lazy::Widget

SYNOPSIS

use CGI::Lazy;

my $q = CGI::Lazy->new('/path/to/config');

my $widget = $q->widget->dataset({...});

DESCRIPTION

CGI::Lazy::Widget is an abstract class for widgets such as Dataset, Composite, and Domloader.

Its methods are called internally by its child classes. There are, at present, no real uses for the class by itself.

METHODS

ajaxReturn ( widgets, data )

Wraps data (presumably from widget) in json format with validator from widgets for returning to browser in response to an ajax reqeust

ajaxSelect (args )

Returns result of select method in a json format suitable for returning to the browser

args

see select( args) for details

widgets

List of widgets to be parsed for validators

data

Widget html output

jsonescape ( var )

traverses variable and strips out single quotes to prevent JSON parser blowing up.

Strips them out rather than escaping them, as at present I can't figure out how to just add a single fracking backslash to them. s/'/\\'/g gives 2 backslashes, and s/'/\'/g gives none. grr. problem seems to be in either JSON or JSONPARSER

var

whatever variable you're going to convert to json and then parse

preloadLookup

Runs queries for lookup tables and parses then into JSON wrapped in javascript suitable for loading into the DOM of a page.

Useful only for tables that are intended to be preloaded into a page at load.

ajaxBlank ()

Convenience method. Returns blank widget output

select (args)

Runs select based on args and returns output.

args

Hash of select parameters. Expects to see a key called 'incoming' that contains the incoming parameters in widgetID-fieldname => value format.

Widgets such as Dataset will also have a parameter called CGILazyID which will contain the name of the widget (for doing different things at the cgi level based on which widget is talking to the app). This key/value will be stripped automatically.

The rest of the hash supports the following options:

div 		=> 1  #By default will be sans enclosing div tags, but div can be included if you pass div => 1.  This is useful for members of composite widgets.

searchLike		=> '%?%' # search will be like %value%, in other words anything containing 'value'. Like is applied only to searches coming in from web, not vars added to the search in the cgi

searchLike	 	=> '?%'  # search will be on value%

searchLike		=> '%?'  # search on %v

vars 		=> {fieldname => {optionname => optionvalue}}

vars 		=> {fieldname => {value => 'bar'}} #extra search parameter.

vars		=> {foo => {handle => $ref}}} # when retrieved $$ref will have the value of field foo. ('handle' is a 'handle' on that value for use in tying things together.)

searchLikeVars	=> '%?%' # search will be like %value%, in other words anything containing 'value'.  like is applied to vars specified from the cgi. Basically this means you can do a like on variables hardcoded in the cgi independantly from things coming in from the web.

searchLikeVars 	=> '?%'  # search will be on value%

searchikeVars	=> '%?'  # search on %v