Upgrading a Viewpoint 12.0 Portlet to 13.0

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 12.0 Portlet to 13.0

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

Modify ivy.xml to use 13.0 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.0.0-SNAPSHOT" for all "tdcommons-X" projects, "3.0-SNAPSHOT" for "anterage", and leave it at "12.0.0.0" for "TeraJDBC". Here's an example of what the end result should look like:

<dependency org="teradata" name="tdcommons-portlets" rev="13.0.0.0-SNAPSHOT" conf="runtime->runtime" changing="true" />
<dependency org="teradata" name="tdcommons-model" rev="13.0.0.0-SNAPSHOT" conf="runtime->runtime" changing="true" />
<dependency org="teradata" name="tdcommons-security" rev="13.0.0.0-SNAPSHOT" conf="runtime->runtime" changing="true" />
<dependency org="teradata" name="tdcommons-testutil" rev="13.0.0.0-SNAPSHOT" conf="build->build" changing="true" />
<dependency org="teradata" name="tdcommons-taglib" rev="13.0.0.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.00.01\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.00.01 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.00.01\viewpoint-portal\webapps\DynamicQuery\web\WEB-INF\lib

Update portlet.xml to enable maximized mode and make the portlet shareable



<init-param>
<name>portletMaximizable</name>
<value>true</value>
</init-param>
<init-param>
<name>portletShareable</name>
<value>true</value>
</init-param>


Edit viewpoint-portlet.xml, and modify the portlet element to indicate whether or not this portlet is shareable. Instead of "YourPortletName", you should see the actual name of your portlet.

<portlet id="YourPortletName" label="YourPortletName" shareable="true">

Add permissions for setting preferences and sharing the portlet.


<permission scope="domain" name="SET_PREFS" description="If granted, the user can access the preferencess view" />
<permission scope="domain" name="SHARE_PORTLET" description="If granted, the user can share the portlet" />


Fix validation

Change "TjsValidate.js" to "TjsValidator.js"

<script type="text/javascript" src="/CommonsWeb/js/TjsValidator.js"></script>

Add functionality for "Clear defaults" button in preferences

Add the following code at the end of preferences.jsp to hook up the "Clear Defaults" button to a backend controller. Replace "YourPortletName" with the name of your portlet, with the first letter capitalized:


<script type="text/javascript">
TDPortalManager.onPortletReady('${context}', function()
{
// add click handler for clearPreferences button
jQuery('#clearDefaultsBtn').click(function() {
TDAjaxManager.post("/YourPortletNamePortlet/dataserver/clearPreferences",
{ portletName: '${portletName}', context: '${context}' },
null,
{ target: ".removedefaultsbutton"});
});

<c:if test="${securityDomain != tdPortletId}">
jQuery('.defaultcheckbox').hide();
jQuery('.removedefaultsbutton').hide();
jQuery('.centerbuttons').width('100%');
</c:if>
});
</script>


Add a new property as shown below to use your portlet's View Controller for clearing default preferences. Replace "yourPortletName" with the actual name of your portlet, where the first word is lowercase.

<props>
<prop key="/summary">yourPortletNameViewController</prop>
<prop key="/configuration">yourPortletNameViewPreferencesController</prop>

<prop key="/clearPreferences">yourPortletNameViewController</prop>
</props>

Now we need to add a clearPreferences() method to your controller. Replace both instances of "YourPortletName" with the actual name of your portlet, this time with the first letter capitalized.

src\java\com\teradata\portlets\YourPortletName\controllers\YourPortletNameViewController.java

    {
// set 'summary.jsp' as the view for this page.
ctx.setViewName("summary");
}

/**
* Clears the preferences, uses the common controller code to clear the preferences
*
* @param ctx the controllerContext
*/
public void clearPreferences (ControllerContext ctx)
{
ctx.removePreferences(ctx.getPortletName());
ctx.setViewName("clearPrefs-feedback");
ctx.addViewObject("result", "defaults cleared");
}


Create a new file, clearPrefs-feedback.jsp. This will be used to display the success/failure message when the user presses the "Clear Defaults" button in the preferences.



<%@ page contentType="text/html" language="java" %>
${result}


Run your new 13.0-compatible portlet

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