GeoPrisma logo

Basic knowledge

This topics covers the basic knowledge of widgets, like what files are used by a widget, what functions are commonly used, etc.

Be sure to have read and understood the following topic before moving on : Widget

Global view

  • All widgets are in the [your_geoprisma_root_directory]/src/client/widgets directory.
  • There is a Sample widget from which you can copy the files to start from. It’s in the sample directory of the widgets directory.
  • Widgets can also be placed in a more complex structure of Sub-directories .
  • Widget names are case sensitive. Lowercases values must stay in lowercase in all files.
  • Only the widgets linked to the Resources the user has access to are included. For the purpose of simplification, these widgets will be called included widgets in this topic.
  • All widgets have the 3 following xsl templates (functions) :
  • The Globals.xslt file have some very useful functions you can use in your widget.

Sample widget

Here’s the file structure of the sample widget.

[your_geoprisma_root_directory]/src/client/widgets/sample :


Widgets are not limited to a single directory structure. You can create an infinite architecture of sub-directories in which to put your widgets. This comes in handy when similar widgets have to share common files of classes or simply to group them. For examples, here’s the structure of the editfeature directory from the widgets directory :


In the config, widgets using a sub-directories structure are defined a bit differently. They must have their whole path as type, with slashes ‘/’ replaces by ‘_’, like this :



  • Called only once per included widget type.
  • Called by the printAllWidgetSources function in the template file.
  • Main purposes :
    • Include once the files required by the widget, like javascript and stylesheet (css) files.
    • Create javascript variables common to all widgets of this type. For example, an javascript array variable could be defined in this function as a container for all the widgets of this type.


  • Called once per included widget.
  • Called by the printAllWidgetExecutions function in the template file.
  • Main purposes :
    • Create the objects used by each widget of this type. In more details, if you want to have multiple widget (of the same type) in your application, the code in this section is parsed X times ( where X is the number of included widgets in the application).

drawWidget / drawWidgets

Here, you have a choice of using either one or even both, it’s completely up to you. The drawWidgets method is much more user-friendly though. Nevertheless, we’ll see both methods and what they do and imply.

  • Theses functions are called in the template file.
  • Main purposes : determine where to put the actual widgets in the ui.


Designed to draw one widget only, by giving the widget’s name from the config as the argument. This requires to manually loop through the widgets in the template file. Here’s an example :

drawWidget function from the Widget.xslt file :

<xsl:template name="sample:drawWidget">
  <xsl:param name="pWidgetName" />
    objGPWidget<xsl:value-of select="$pWidgetName" />

drawWidget call from the Template.xslt file :

<xsl:for-each select="/geoprisma/widgets/widget[./type = 'sample']">
  <xsl:call-template name="sample:drawWidget">
    <xsl:with-param name="pWidgetName" select="./name" />


Designed to draw all widgets of a given type. To be able to do so, each widget must be added (done in the printWidgetExecution) to some kind of container (defined in the printWidgetSource). This method is easier to use in the template file. Here’s an example :

drawWidgets function from the Widget.xslt file :

<xsl:template name="sample:drawWidgets">
  <xsl:param name="pContainer" />

  <xsl:variable name="WidgetType">

  if (typeof(objGPWidget<xsl:value-of select="$WidgetType" />Container) != 'undefined' &amp;&amp; typeof(<xsl:value-of select="$pContainer" />) != 'undefined')
      if(<xsl:value-of select="$pContainer" />['ctype']){
          <xsl:value-of select="$pContainer" />.add(
              objGPWidget<xsl:value-of select="$WidgetType" />Container
      } else {
          <xsl:value-of select="$pContainer" />.items.push(
              objGPWidget<xsl:value-of select="$WidgetType" />Container

drawWidgets call from the Template.xslt file :

<xsl:call-template name="shortcut:drawWidgets">
  <xsl:with-param name="pContainer">

See the existing widgets to know more about theses methods.

Table Of Contents

Previous topic


Next topic

How to create a new widget

This Page