Author: chris.laprun(a)jboss.com
Date: 2008-03-31 13:28:28 -0400 (Mon, 31 Mar 2008)
New Revision: 10436
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-war/WEB-INF/jsp/content/portlet_editor.jsp
Log:
- JBPORTAL-1967: Avoid NPEs, use proper locales.
- Minor improvements (in particular avoid querying for a value when a local variable can
be used).
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-war/WEB-INF/jsp/content/portlet_editor.jsp
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-war/WEB-INF/jsp/content/portlet_editor.jsp 2008-03-31
17:27:40 UTC (rev 10435)
+++
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-war/WEB-INF/jsp/content/portlet_editor.jsp 2008-03-31
17:28:28 UTC (rev 10436)
@@ -1,6 +1,6 @@
+<%@ page import="org.jboss.portal.common.i18n.LocalizedString" %>
<%@ page import="org.jboss.portal.common.util.IteratorStatus" %>
<%@ page import="org.jboss.portal.core.model.instance.Instance" %>
-<%@ page import="org.jboss.portal.core.portlet.info.CorePortletInfo" %>
<%@ page import="org.jboss.portal.core.portlet.info.PortletIconInfo" %>
<%@ page import="org.jboss.portal.core.portlet.info.PortletInfoInfo" %>
<%@ page
import="org.jboss.portal.core.ui.content.portlet.PortletContentEditorPortlet"
%>
@@ -8,167 +8,172 @@
<%@ taglib
uri="http://java.sun.com/portlet" prefix="portlet"
%>
<%
- Collection instances = (Collection)request.getAttribute("INSTANCES");
- Instance selectedInstance =
(Instance)request.getAttribute("SELECTED_INSTANCE");
+ Collection instances = (Collection)request.getAttribute("INSTANCES");
+ Instance selectedInstance =
(Instance)request.getAttribute("SELECTED_INSTANCE");
%>
<%@page import="org.jboss.portal.portlet.Portlet" %>
<%@page import="org.jboss.portal.portlet.PortletInvokerException" %>
<%@page import="org.jboss.portal.portlet.info.MetaInfo" %>
<%@page import="org.jboss.portal.portlet.info.PortletInfo" %>
<%@page import="java.util.Collection" %>
+<%@ page import="java.util.Locale" %>
<portlet:defineObjects/>
<script type='text/javascript'
src='/portal-admin/js/domLib.js'></script>
<script type="text/javascript"
src="/portal-admin/js/fadomatic.js"></script>
<script type='text/javascript'
src='/portal-admin/js/domTT.js'></script>
<script type="text/javascript">
- //<![CDATA[
- var domTT_styleClass = 'domTTOverlib';
- var domTT_maxWidth = false;
- //]]>
+ //<![CDATA[
+ var domTT_styleClass = 'domTTOverlib';
+ var domTT_maxWidth = false;
+ //]]>
</script>
<table style="width:500px;">
<tr>
- <td><h3 class="sectionTitle tenpx-top-bottom">Portlet instance
associated to this window:</h3></td>
+ <td><h3 class="sectionTitle tenpx-top-bottom">Portlet instance
associated to this window:</h3></td>
</tr>
<%
- if (selectedInstance != null)
- {
- String displayName =
selectedInstance.getDisplayName().getString(renderRequest.getLocale(), true);
- if (displayName == null)
- {
- displayName = selectedInstance.getId();
- }
+ Locale locale = renderRequest.getLocale();
+ if (selectedInstance != null)
+ {
+ String displayName = selectedInstance.getDisplayName().getString(locale, true);
+ if (displayName == null)
+ {
+ displayName = selectedInstance.getId();
+ }
%>
<%
- Portlet portlet = null;
- try
- {
- portlet = selectedInstance.getPortlet();
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- if (portlet != null)
- {
- MetaInfo metaInfo = portlet.getInfo().getMeta();
+ Portlet portlet = null;
+ try
+ {
+ portlet = selectedInstance.getPortlet();
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ if (portlet != null)
+ {
+ PortletInfo info = portlet.getInfo();
+ MetaInfo metaInfo = info.getMeta();
- PortletInfo info = portlet.getInfo();
+ LocalizedString localizedDesc = metaInfo.getMetaValue(MetaInfo.DESCRIPTION);
+ String desc = "";
+ if (localizedDesc != null)
+ {
+ desc = localizedDesc.getString(locale, true);
+ }
- String iconLocation = getIcon(info);
-
+ String iconLocation = getIcon(info);
%>
<tr class="portlet-section-selected">
- <td>
- <img src="<%= iconLocation %>" align="middle"
style="margin:0 4px 0 0"/>
- <span><%= displayName %></span>
+ <td>
+ <img src="<%= iconLocation %>" align="middle"
style="margin:0 4px 0 0" alt="icon"/>
+ <span><%= displayName %></span>
- <div>
- <span
- class="portlet-form-field-label">Portlet
name:</span><%= metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString()
%>
- </div>
- <div>
- <span
- class="portlet-form-field-label">Portlet
description:</span><%=
metaInfo.getMetaValue(MetaInfo.DESCRIPTION).getDefaultString() %>
- </div>
+ <div>
+ <span class="portlet-form-field-label">Portlet
name:</span><%= displayName %>
+ </div>
+ <div>
+ <span class="portlet-form-field-label">Portlet
description:</span><%= desc %>
+ </div>
- </td>
+ </td>
</tr>
<%
- }
- }
+ }
+ }
%>
<tr>
- <td>
+ <td>
- <div style="height:300px; width:500px; overflow: auto; overflow-x: hidden;
border: 1px solid #333;">
- <table style="width:100%;" cellspacing="0"
cellpadding="0">
- <%
- for (IteratorStatus i = new IteratorStatus(instances); i.hasNext();)
- {
- Instance instance = (Instance)i.next();
- String rowClass = instance == selectedInstance ?
"portlet-section-selected" : (i.getIndex() % 2 == 0 ?
"portlet-section-body" : "portlet-section-alternate");
- String displayName =
instance.getDisplayName().getString(renderRequest.getLocale(), true);
- MetaInfo portletMetaInfo = instance.getPortlet().getInfo().getMeta();
+ <div style="height:300px; width:500px; overflow: auto; overflow-x: hidden;
border: 1px solid #333;">
+ <table style="width:100%;" cellspacing="0"
cellpadding="0">
+ <%
+ for (IteratorStatus i = new IteratorStatus(instances); i.hasNext();)
+ {
+ Instance instance = (Instance)i.next();
+ String rowClass = instance == selectedInstance ?
"portlet-section-selected" : (i.getIndex() % 2 == 0 ?
"portlet-section-body" : "portlet-section-alternate");
+ String displayName = instance.getDisplayName().getString(locale, true);
+ PortletInfo info = instance.getPortlet().getInfo();
+ MetaInfo portletMetaInfo = info.getMeta();
- if (displayName == null)
- {
- displayName = instance.getId();
- }
+ if (displayName == null)
+ {
+ displayName = instance.getId();
+ }
- PortletInfo info = instance.getPortlet().getInfo();
+ String iconLocation = getIcon(info);
- String iconLocation = getIcon(info);
+ LocalizedString localizedDesc =
portletMetaInfo.getMetaValue(MetaInfo.DESCRIPTION);
+ String desc = "";
+ if (localizedDesc != null)
+ {
+ desc = localizedDesc.getString(locale, true);
+ }
+ %>
+ <portlet:actionURL var="url">
+ <portlet:param name="content.action.select"
value="true"/>
+ <portlet:param name="content.uri" value="<%=
instance.getId() %>"/>
+ </portlet:actionURL>
- %>
- <portlet:actionURL var="url">
- <portlet:param name="content.action.select"
value="true"/>
- <portlet:param name="content.uri" value="<%=
instance.getId() %>"/>
- </portlet:actionURL>
+ <div style="display:none">
+ <div class="darktip" id="info-container-<%= displayName
%>">
+ <div class="toolbar" style="width: 250px;">
+ <div class="title"><%=
portletMetaInfo.getMetaValue(MetaInfo.TITLE).getDefaultString() %>
+ </div>
+ </div>
+ <div class="content">
- <div style="display:none">
- <div class="darktip" id="info-container-<%=
displayName %>">
- <div class="toolbar" style="width: 250px;">
- <div class="title"><%=
portletMetaInfo.getMetaValue(MetaInfo.TITLE).getDefaultString() %>
- </div>
- </div>
- <div class="content">
+ <div>
+ <span class="portlet-form-field-label">Portlet
name:</span><%= displayName %>
+ </div>
+ <div>
+ <span class="portlet-form-field-label">Portlet
description:</span><%= desc %>
+ </div>
+ </div>
+ </div>
- <div>
- <span
- class="portlet-form-field-label">Portlet
name:</span><%=
portletMetaInfo.getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString() %>
- </div>
- <div>
- <span
- class="portlet-form-field-label">Portlet
description:</span><%=
portletMetaInfo.getMetaValue(MetaInfo.DESCRIPTION).getDefaultString() %>
- </div>
- </div>
- </div>
+ </div>
- </div>
-
- <tr class="<%= rowClass %>">
- <td>
- <img src="<%= iconLocation %>"
align="middle" style="margin:0 4px 0 0"/>
- <span
- onmouseover="domTT_activate(this, event, 'content',
document.getElementById('info-container-<%= displayName
%>'),'delay', 0, 'trail', false, 'fade', 'both',
'fadeMax', 95, 'styleClass', 'none');"><a
- href="<%= url %>"
id="portlet-instance-link"><%= displayName %>
- </a></span></td>
- </tr>
- <%
- }
- %>
- </table>
- </div>
- </td>
+ <tr class="<%= rowClass %>">
+ <td>
+ <img src="<%= iconLocation %>" align="middle"
style="margin:0 4px 0 0" alt="icon"/>
+ <span onmouseover="domTT_activate(this, event, 'content',
document.getElementById('info-container-<%= displayName
%>'),'delay', 0, 'trail', false, 'fade', 'both',
'fadeMax', 95, 'styleClass', 'none');"><a
+ href="<%= url %>"
id="portlet-instance-link"><%= displayName %>
+ </a></span></td>
+ </tr>
+ <%
+ }
+ %>
+ </table>
+ </div>
+ </td>
</tr>
</table>
<%!
- private String getIcon(PortletInfo info)
- {
- String iconLocation = null;
- CorePortletInfo cInfo = info.getAttachment(CorePortletInfo.class);
- if (cInfo != null)
+ private String getIcon(PortletInfo info)
+ {
+ String iconLocation = PortletContentEditorPortlet.DEFAULT_PORTLET_ICON;
+ PortletInfoInfo portletInfo = info.getAttachment(PortletInfoInfo.class);
+
+ if (portletInfo != null)
+ {
+ PortletIconInfo iconInfo = portletInfo.getPortletIconInfo();
+ if (iconInfo != null && iconInfo.getIconLocation(PortletIconInfo.SMALL) !=
null)
{
- PortletInfoInfo portletInfo = cInfo.getPortletInfo();
- if (portletInfo != null && portletInfo.getPortletIconInfo() != null
&& portletInfo.getPortletIconInfo().getIconLocation(PortletIconInfo.SMALL) !=
null)
- {
- iconLocation =
portletInfo.getPortletIconInfo().getIconLocation(PortletIconInfo.SMALL);
- }
+ iconLocation = iconInfo.getIconLocation(PortletIconInfo.SMALL);
}
- if (iconLocation == null)
- {
- iconLocation = PortletContentEditorPortlet.DEFAULT_PORTLET_ICON;
- }
- return iconLocation;
- }
+ }
+
+ return iconLocation;
+ }
%>
\ No newline at end of file