Upgrading a Viewpoint 13.0 Portlet to 13.0.1

Extensibility
Extensibility covers the mechanisms by which you, as the user or developer, can extend the functionality of the Teradata Database, for example with the use of User Defined Functions, or UDFs.
Teradata Employee

Upgrading a Viewpoint 13.0 Portlet to 13.0.1

 If you have a portlet developed for Viewpoint 13.0, here are the steps you'll need to take in order to get it working correctly under Viewpoint 13.0.1.

Modify ivy.xml to use 13.0.1 jars

If you are developing inside of the Teradata network you will need to modify the ivy.xml file for your portlet. If you are not then go to the next step.

Edit ivy.xml. Change the rev to "13.0.1.0-SNAPSHOT" for all "tdcommons-X" projects, "3.0-SNAPSHOT" for "anterage", and "13.0.0.0" for "TeraJDBC". Here's an example of what the end result should look like:

ivy.xml

<dependency org="teradata" name="tdcommons-portlets" rev="13.0.1.0-SNAPSHOT" conf="runtime->runtime" changing="true" />
<dependency org="teradata" name="tdcommons-model" rev="13.0.1.0-SNAPSHOT" conf="runtime->runtime" changing="true" />
<dependency org="teradata" name="tdcommons-security" rev="13.0.1.0-SNAPSHOT" conf="runtime->runtime" changing="true" />
<dependency org="teradata" name="tdcommons-testutil" rev="13.0.1.0-SNAPSHOT" conf="build->build" changing="true" />
<dependency org="teradata" name="tdcommons-taglib" rev="13.0.1.0-SNAPSHOT" conf="runtime->runtime" changing="true" />
<dependency org="teradata" name="anterage" rev="3.0-SNAPSHOT" conf="runtime->runtime" changing="true" />
<dependency org="teradata" name="TeraJDBC" rev="13.0.0.0" conf="runtime->default" />

Manually move new jar files to your portlet

If you are developing external to the Teradata network you will need to manually update your portlet with new jar files. First delete all of the old jar files from your WEB-INF folder. There are located here:

C:\tdpdk-13.00.01.00\src\YourPortletName\web\WEB-INF\lib

Now grab the new jar files from one of the demo portlets that were generated with the 13.00.01.00 PDK, and put them in the folders that you just removed the old ones from. If you were to grab them from the DynamicQuery portlet, you would find them here:

C:\tdpdk-13.00.01.00\viewpoint-portal\webapps\DynamicQuery\web\WEB-INF\lib

Support internationalization

This guide should help you to update an existing Viewpoint portlet to be internationalizable, in several straightforward steps.

Edit your web.xml.

Add the following filter. This sets the character encoding to UTF-8. Also, wire up the internationalization message server for your portlet.

web.xml

<!-- This sets the encoding on every request and response to be UTF-8 -->
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!-- Add the i18n message servlet and its mapping -->
<servlet>
<servlet-name>i18n</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>4</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>i18n</servlet-name>
<url-pattern>/i18n/*</url-pattern>
</servlet-mapping>

Edit your ehcache.xml file

Add the following cache to cache the locale values for the user.

ehcache.xml

<cache name="locale" maxElementsInMemory="1000" eternal="false" timeToIdleSeconds="1800"  timeToLiveSeconds="1800" overflowToDisk="true" />

Add an i18n-servlet.xml file

Copy it from another portlet or from below. You do not need to edit anything in this file.

i18n-servlet.xml

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!-- - Application context definition for "springapp" DispatcherServlet. -->
<beans>
<description>Contains definitions for beans used by the Sample Portlet user interface</description>

<!-- map requests to controllers by mapping url to the controller name -->
<bean id="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/messages">MessageController</prop>
</props>
</property>
</bean>

<!-- controllers -->
<bean id="methodNameResolver"
class="org.springframework.web.servlet.mvc.multiaction.InternalPathMethodNameResolver" />

<bean id="MessageController" class="com.teradata.portlets.i18n.MessageServer">
<description>controller for javascript data requests</description>
</bean>
</beans>

Edit your portlet.xml

Add a resource-bundle element pointing to the properties file containing portlet metadata.

portlet.xml

<portlet>
<portlet-name>FilteredQueries</portlet-name>
...

<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>edit</portlet-mode>
</supports>
<supported-locale>ja</supported-locale>
<resource-bundle>filteredqueries-portlet</resource-bundle>
...
</portlet>

Edit your viewpoint-portlet.xml

Add the supported-locale and resource-bundle element to your viewpoint-portlet.xml

viewpoint-portlet.xml

<portlet id="FilteredQueries" label="Filtered Queries">
<version>13.0.0</version>
<category>Monitoring</category>
...
<supported-locale>ja</supported-locale>
<resource-bundle>filteredqueries-portlet</resource-bundle>
<domain id="FilteredQueries">
<permission scope="domain" name="SET_PREFS" description="If granted, the user can access the preferencess view" />
...
</domain>
</portlet>

Add/update properties files

Properties files are extensively used for localization. We use two different properties files to localize portlet text, one for portlet content (e.g. use by the fmt:message tag), and another for portlet metadata (title, category, permission, etc.)

Messages.properties

This is the properties file to use to store text that will be retrieved by the JSTL tag library, your custom tags, controllers etc. In order for tooltips to localized correctly, it needs to be called messages.properties. It is typically stored at \src\resources\messages.properties, although it can be anywhere in your classpath.

messages.properties

#SHARED
label.username=Username
label.password=Password

button.next=Next
button.cancel=Cancel
button.ok=OK

This message source will be loaded when you define a messageSource bean in your applicationContext.xml. Again, PDK generated portlets will have this automatically.

applicationContext.xml

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages" />
</bean>

<portletname>-portlet.properties

This is what you will use to localize portlet titles, categories and permissions. It is good practice use the naming convention <portletname>-portlet.properties, especially if you have multiple portlets in one war.

filteredqueries-portlet.properties

#TITLE
javax.portlet.title=Filtered Queries

#CATEGORY
com.teradata.viewpoint.category=Monitoring

#PERMISSIONS
com.teradata.viewpoint.permission.SET_PREFS=SET PREFS
com.teradata.viewpoint.permission.SHARE_PORTLET=SHARE PORTLET

com.teradata.viewpoint.permission.VIEW_SUMMARY=VIEW SUMMARY
com.teradata.viewpoint.permission.VIEW_DETAIL=VIEW DETAIL

That's it! This lays the groundwork for i18n-izing your portlet.

Update tool tips

Tool tip messages are now stored with all of your other strings (see How to use Internationalized messsages) insrc/resources/messages.properties; the separate tool tip properties files should be removed. The format is also slightly different. Tool tip .properties files used to look like this:

propertyKeyName = 'teradata_portlets_test';
myStaticTip = 'This is my static tooltip. The text will never change.';
myDynamicTip = 'This my dynamic tooltip. The time is now {time}. The day is {day}.';

The messages.properties file format instead looks like this:

myStaticTip=This is my static tooltip. The text will never change.
myDynamicTip=This my dynamic tooltip. The time is now {time}. The day is {day}.

Note the lack of whitespace around =, the lack of quotes around the message, and the lack of line-ending semicolons.

TDTTM's registerToolTips() function's arguments have changed:

TDPortalManager.onPortletReady('${context}', function() {
TDToolTipManager.registerToolTips('${context}', {
propertyMap:{
'teradata_portlets_SystemHealth':'SystemHealthPortlet',
},
elementId:'${context}_Container'
});
});

The registerToolTips() function requires two parameters:

  1. The first parameter is the unique context id of portlet that is registering the tooltips.
  2. The second parameter is a javascript hash map that requires two elements in the hash map:
    • propertyMap: The propertyMap hash should contain a javascript hash of all the tool tip sources that will be loaded and used for tool tips on this portlet. Each key in the hash specifies the propertyKeyName used in your JSP (see below), and each value is the internationalization context which contains your tool tips (XXX XREF).
    • elementId: The elementId hash is the string name id that represents the outer-most element in which all tool tips reside. Usually, this is the id of the outer-most container div for the portlet in getting tool tips.

Run your new 13.0.1-compatible portlet

Your portlet is now ready to be deployed within the Viewpoint 13.0.1 environment.