MMBase Editwizard Front end


The editwizard extension assumes a directory structure where files can be found. Two root locations are used to find the files. The most important one is the editwizard home directory. The editwizard home is the directory that contains the editwizard data library, css-stylesheets, javascript files and jsp pages. In the standard distribution, this location is /mmapps/editwizard/. The other root location is the referrer page directory. You call the editwizard scripts (list.jsp and wizard.jsp) from a page located in another directory than the editwizard home directory. If you do, the wizards keep a reference to the calling page, the 'referrer'. When a xml or xsl file is requested, the wizard first checks whether the file can be found in the directory of the referrer page. You can also use this location to have you own javascript files or css-stylesheets.

The assumed sub locations of the editwizard home directory are:

Adding a logo is not so hard to do, but what if you have your own fieldtype (wizard definition schema attribute ftype)? Maybe, you want your fieldtype represented as a checkbox, radio button or dropdown box. This involves graphical representation, client-side initialisation and validation.

The first thing we have to do for this is overriding the ftype-unknown template of the wizard.xsl (See the first example). This template calls templates for unknown ftypes to generate the graphical representation.

		
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet 
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:node="org.mmbase.bridge.util.xml.NodeFunction"
  xmlns:date="org.mmbase.bridge.util.xml.DateFormat"
  extension-element-prefixes="node date">

   <!-- Import original stylesheet -->
   <xsl:import href="ew:xsl/wizard.xsl"/>

  <xsl:template name="ftype-unknown">
    <xsl:choose>
      <xsl:when test="@ftype=&apos;my_ftype&apos;">
      	<xsl:call-template name="ftype-my-ftype"/>
      </xsl:when>
      <xsl:otherwise>
      	<xsl:call-template name="ftype-other"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  
  <xsl:template name="ftype-my-ftype">
    <input type="checkbox" name="{@fieldname}" value="{value}" id="{@fieldname}">
      <xsl:apply-templates select="@*" />
    </input>
  </xsl:template>

  <xsl:template name="extrajavascript">
    <script language="javascript" src="{$referrerdir}override.js"></script>
  </xsl:template>

</xsl:stylesheet>
		
		

Now the editwizard will generate a checkbox for all fields with ftyp=”my_ftype”. We will use an <referrer page directory>/override.js to initialise and validate the checkbox. The validator will attach itself to the input fields when it is required to validate it. The validation is now only at the client-side. The editwizard will do a server-side validation for the existing fieldtypes too.

		
function initializeElement(elem, dttype, ftype) {
    if (ftype == "my_ftype") {
        elem.checked = true;
    }
}

//validator methods
function requiresUnknown(el, form) {
    return (el.getAttribute("ftype") == "my_ftype");
}

function validateUnknown(el, form, v) {
    if (el.getAttribute("ftype") == "my_ftype" && el.checked) {
        return "Checkbox is still checked";
    }
    return "";
}
		
		

This is part of the MMBase documentation.

For questions and remarks about this documentation mail to: documentation@mmbase.org