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.
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>
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>
Include the following code where you want to invoke the Template Chooser in page:
<input type="button" value="Change Template" onclick=" changeTemplate('currentTemplate')"/>
| Options | Since | Description | Default |
| currentTemplate | V1.0 | The current Template of the application | - |
| Options | Since | Description | Default |
| className | V1.0 | The style class | Dekoh |
| title | V1.0 | Set the title here | ‘Template Chooser’ |
| topMessage | V1.0 | The top message on the dialog | 'Pick a template that suits your collection' |
| width | V1.0 | Width of the dialog | 600 |
| height | V1.0 | Height of the dialog | 450 |
| xPos | V1.0 | Specify the x position of the dialog in the document | 0 |
| yPos | V1.0 | Specify the y position of the dialog in the document | 0 |
| minimizable | V1.0 | Works 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 |
| maximizable | V1.0 | Works with resizable value set to ‘true’. The value defined for this is ‘true’ or ‘false’ depends on whether you want to make dialog maximized | False |
| isModal | V1.0 | Specify whether the dialog is modal or not | true |
| portalImageDir | V1.0 | The portal Image directory path | '/dekohportal' |
| changeTemplateParam | V1.0 | The jsp parameter to change the template | 'changeTemplateTo' |
| Function | Parameters | Description |
| renderTemplates | allTemplateData, currentTemplate | - |
| handleTemplateOnClick | templateName | - |
| handleTemplateMouseOver | templateName | - |
| handleTemplateMouseOut | templateName | - |
| removeChangeTemplateParamIfAvailable | url | - |
| resizeThumbnail | - | - |
| getAllTemplates | - | - |
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.
<!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>
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.
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 Name | Functionality |
| getTemplateDetails | Gets the list all templates available |
| getTemplateDetailsForTemplate | Gets the template details for the given template name |
| setCollectionTemplateProperties | Sets the given template properties to the given collection |
| setTemplateProperty | Sets the template property to the given digitalObject |
| setUserViewPreference | Sets the user viewing preference (list or thumb nail view) |
| SetDefaultTemplate | User can set the default template to be set to the imported collections |
| GetDefaultCollectionTemplate | Gets the user-preference default template if not set will give "pebbles" |
Dekoh Portal Ver 0.4.2 or later.