Project

General

Profile

1
<h2>Extending with new objects</h2>
2

    
3
<p>
4
The widgets and models provided in the Mapbuilder distribution are 
5
intended to meet most application requirements,
6
however they certainly can't meet all requirements.
7
Fortunately, the modular design makes it very easy to customize and extend 
8
the library to meet your requirements.
9
</p>
10

    
11
<p>
12
Both widgets and models can be specified in the config file using generic 
13
&lt;Widget&gt; and &lt;Model&gt; objects where no specialized 
14
JavaScript code is required.
15
The &lt;stylesheet&gt; property must be specified for generic Widget objects.
16
</p>
17

    
18
<p>
19
The widget &lt;stylesheet&gt; property can also be specified for any widget 
20
to replace the stylesheet supplied in the Mapbuilder distribution.
21
The typical way to use this is to copy the default stylesheet into your 
22
application's directory and customize it as required, 
23
and setting the path to this new file in the config file.
24
</p>
25

    
26
<p>
27
For widgets, all properties in the config file are automatically set as a
28
stylesheet parameter.
29
For example, if the widget has a &lt;lineColor&gt; property in config, 
30
the stylesheet for that widget can declare a "lineColor" parameter and use
31
that to get the value set in the config file:
32
</p>
33
<pre>
34
  &lt;xsl:param name="lineColor" select="'red'"/&gt;
35
  &lt;xsl:template match="/"&gt;
36
    line color:&lt;xsl:value-of select="$lineColor"/&gt;
37
  &lt;/xsl:template&gt;
38
</pre>
39

    
40
<p>
41
The file naming convention in Mapbuilder is that each JavaScript object in
42
config has a corresponding .js file in the mapbuilder/lib directory with 
43
the same name as the object name.
44
You can override this by specifying a &lt;scriptFile&gt; property 
45
in the config file which gives a path to a Javascript file to define the object. 
46
</p>
47

    
48
<p>
49
Using these techniques, developers and implementers can code, debug, and test 
50
their applications independent of the core Mapbuilder library.
51
However the models, widgets and tools that you develop could be useful 
52
for a wider audience and you are encouraged to contribute these back to 
53
the Mapbuilder project so that we can all benefit from each other's efforts.
54
</p>
55

    
56
<p align="right">
57
<a href="?page=config/listeners">previous</a>&nbsp;&nbsp;&nbsp; 
58
<a href="docs/register">next</a>
59
</p>
(2-2/7)