[Chameleon] newbie question...

Paul Spencer pspencer at dmsolutions.ca
Fri Nov 12 09:29:28 EST 2004


Max,

a caution: developing a new widget is fairly advanced and there is no 
documentation on how to do it yet (I'm still trying to start writing 
it).  New widgets require a reasonable working knowledge of programming 
concepts (PHP is an asset but easy to learn for a C programmer :)) and a 
willingness to search out information (on php/mapscript for instance).

There are several knowledgeable people on the list who have developed 
new widgets, but it is a bit of a black art :)

Here's a quick overview that may help you understand the flow of an 
application.

The general concept of chameleon is that it uses an application template 
and a MapServer MAP file to generate an application.  The application 
template is an HTML file with special tags that are interpreted by 
Chameleon as being widgets.  The tags cause widgets to be created, 
processed and ultimately turned into a series of javascript, HTML form 
variables and HTML to dispay for the user.

The chameleon engine passes through 2 stages:

1. initialization: happens on every page load, with an extra step when 
the user's session is first initialized.  This includes reading 
configuration files and creating all the core objects that handle most 
of the work.

2. execution: happens on every page load.  This has three phases:

* widget initialization

The template is parsed for the <cwc2 ... /> tags and widgets are created 
for each tag.  Widgets are initialized with the attributes found in the 
tags.  This phase includes calling the widget constructor, InitDefaults 
and several internal functions that are not normally overridden in the 
widget itself (like SetMap)

* widget execution

Every widget gets an opportunity to execute itself (ParseURL) based on 
values submitted with the page.  This normally means modifying the 
mapscript map object in some way

* widget publishing

Every widget gets an opportunity to render itself in the page.  Because 
of the complexity of HTML applications, this phase is separated into a 
couple of parts:

GetJavascriptXXXX - there are several functions to retrieve various 
kinds of javascript from the widgets.

GetHTMLHiddenVariables - retrieve an array of <input type='hidden' ...> 
key/values from every widget.  Used by widgets to propogate information 
from the user to the widget when the page is submitted.  Most widgets 
will set a form variable when they are activated, then submit the page 
... then check in ParseURL to see if the form variable is set before 
taking some action

DrawPublish - return an HTML representation of the widget.  There are 
helper objects like CWCButton and CWCPopup that handle commonly used 
cases like buttons, but you are free to output anything to the user here.

Javascript and HTML are combined and output in special places in the 
HTML template.  The results of DrawPublish are used to replace the 
original <cwc2 ...> tag in the template.

When all replacements are done, the resulting page is returned to the user.


Massimiliano Cannata wrote:
> Hello list, i'm new to this group and in approaching chameleon....
> 
> I already build a simple application looking at the great samples !!!!
> 
> As the next step I need to develoop new functions as drow graphics based 
> on a query end so on.....
> So I looked at the widget folder to see how to develoop a new widget.
> I can see a php files with the definition of class and functions, but 
> (consider that I woorked a lot with grass and usually I program in C) 
> where is defined the HTML that define using the argument the sequence of 
> action to do? (the main?) (Probably a stupid question?!?! but please 
> help me entering in this new world!
> 
> Thanks, Max
> 
> _____________________________________________________
> 
> Ing. Massimiliano Cannata
> 
> SUPSI - Istituto Scienze della Terra
> C.P. 72 - CH-6952 Canobbio (Ticino, Switzerland)
> Tel +41 (0)91 935 12 25 - Fax +41 (0)91 935 12 09
> mailto:massimiliano.cannata at supsi.ch
> http://www.ist.supsi.ch
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon

-- 
Cheers,

Paul

+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+


More information about the Chameleon mailing list