Template Chooser Widget

The Template Chooser widget is used to pick a template from an available list of templates. This widget uses Prototype JavaScript library. Note: This widget works only with applications that implement templates.

How to use

Add this code to the head section of the page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<style type="text/css" title="currentStyle" media="screen">
 @import '<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request, "theme","app","css.jsp?externalApp=true")%>';
</style>
<script src='/dekohportal/dwr/engine.js'></script>
<script src='/dekohportal/dwr/util.js'></script>
<script type='text/javascript' src='<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request, "common",null,"JSlibrary.jsp")%>'>
</script>
<script type='text/javascript' src='<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request, "widget","templateChooser","templateChooser.js")%>'>
</script>
<script type="text/javascript" src="<%=dekoh.portal.util.StaticFilesURLGenerator.generateStaticFileURL(request, "widget","dialog","dialog.js")%>">
</script>

JavaScript code

The basic syntax to initialize the widget is
<script>
 // the function to call the template chooser in the page
 function changeTemplate(currentTemplate)
    {
      new TemplateChooser(currentTemplate);
    }   
</script>

HTML code

Include the following code where you want to invoke the Template Chooser in page:

<input type="button" value="Change Template" onclick=" changeTemplate('currentTemplate')"/>

Parameters for initializing the widget

Required parameters

OptionsSinceDescriptionDefault
currentTemplateV1.0The current Template of the application-

Optional parameters

OptionsSinceDescriptionDefault
classNameV1.0The style classDekoh
titleV1.0Set the title here‘Template Chooser’
topMessageV1.0The top message on the dialog'Pick a template that suits your collection'
widthV1.0Width of the dialog600
heightV1.0Height of the dialog450
xPosV1.0Specify the x position of the dialog in the document 0
yPosV1.0Specify the y position of the dialog in the document0
minimizableV1.0Works with resizable value set to ‘true’. The value defined for this is ‘true’ or ‘false’ depends on whether you want to make dialog minimized False
maximizableV1.0Works with resizable value set to ‘true’. The value defined for this is ‘true’ or ‘false’ depends on whether you want to make dialog maximizedFalse
isModalV1.0Specify whether the dialog is modal or nottrue
portalImageDirV1.0The portal Image directory path'/dekohportal'
changeTemplateParamV1.0The jsp parameter to change the template'changeTemplateTo'

Functions

FunctionParametersDescription
renderTemplatesallTemplateData, currentTemplate-
handleTemplateOnClicktemplateName-
handleTemplateMouseOvertemplateName-
handleTemplateMouseOuttemplateName-
removeChangeTemplateParamIfAvailableurl-
resizeThumbnail--
getAllTemplates--

DWR Implementation

The DWR method mapping XML is inside the web.xml file
<init-param>
            <param-name>config-templateChooser</param-name>         <param-value>widgets/templateChooser/dwr-templateChooser.xml</param-value>
        </init-param>
Currently, the template chooser widget is used only in the Photos application. You can find the mapping described above in the web.xml inside Photos application.

DWR XML

<!DOCTYPE dwr PUBLIC
    "-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
    "http://www.getahead.ltd.uk/dwr/dwr10.dtd">
<dwr>
    <allow>
        <create creator="new" javascript="templatechooser">
            <param name="class" value="dekoh.photo.widget.templatechooser.TemplateUtil"/>
            <include method="getTemplateDetails"/>           
            <include method="setCollectionTemplateProperties"/>           
            <include method="getTemplateDetailsForTemplate"/>           
            <include method="setDefaultTemplate"/>           
            <include method="getDefaultCollectionTemplate"/>
            <include method="setTemplateProperty"/>
            <include method="setUserViewPreference"/>
        </create>
        <convert converter="bean" match="dekoh.photo.widget.templatechooser.TemplateDO"/>
    </allow>
</dwr>

Converters

We need to ensure that all the parameters can be converted. Many of the types provided by the JDK are enabled for you, but you need to give DWR permission to convert your own bean. Generally this means that JavaBean parameters will need a <convert ...> entry.
  • Convert-class: dekoh.photo.widget.templatechooser.TemplateDO
  • Description: JavaBean to hold information about the template.

Creators

Each class on which we execute methods, needs a <create ...> entry. There are several types of creator. The most common ones use either the 'new' keyword or the Spring framework. For more information, see the Creator documentation. ClassName : dekoh.photo.widget.templatechooser.TemplateUtil Description : Class will provide the functionality to get the available templates in picApp.

Method NameFunctionality
getTemplateDetailsGets the list all templates available
getTemplateDetailsForTemplateGets the template details for the given template name
setCollectionTemplatePropertiesSets the given template properties to the given collection
setTemplatePropertySets the template property to the given digitalObject
setUserViewPreferenceSets the user viewing preference (list or thumb nail view)
SetDefaultTemplateUser can set the default template to be set to the imported collections
GetDefaultCollectionTemplateGets the user-preference default template if not set will give "pebbles"

Availability

Dekoh Portal Ver 0.4.2 or later.

Attachments

templatechooser.jpg Info on templatechooser.jpg 103993 bytes