Author: chris.laprun(a)jboss.com
Date: 2007-11-02 23:38:54 -0400 (Fri, 02 Nov 2007)
New Revision: 8824
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/PortletManagerBean.java
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/showPortletDetails.xhtml
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/portlets.xhtml
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/wizard/selectPortlet.xhtml
Log:
- JBPORTAL-1758: Fixed comparator to fall back to portlet id if there is no display name.
- Unified handling of portlet name by making AdminPropertyResolver smarter about resolving
portlet.name.
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2007-11-02
15:06:54 UTC (rev 8823)
+++
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2007-11-03
03:38:54 UTC (rev 8824)
@@ -117,9 +117,7 @@
public Object getValue(Object bean)
{
LocalizedString string = (LocalizedString)bean;
- FacesContext ctx = FacesContext.getCurrentInstance();
- Locale locale = ctx.getExternalContext().getRequestLocale();
- return string.getString(locale, true);
+ return getValueForRequestLocale(string);
}
});
registerDecorator(LocalizedString.class, localizedStringDecorator);
@@ -131,10 +129,12 @@
public Object getValue(Object bean) throws IllegalArgumentException
{
Portlet portlet = (Portlet)bean;
- return portlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+ String displayName =
getValueForRequestLocale(portlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME));
+
+ return displayName != null ? displayName : portlet.getContext().getId();
}
});
- portletDecorator.setProperty("description", new
AbstractPropertyDecorator(String.class)
+ portletDecorator.setProperty("description", new
AbstractPropertyDecorator(LocalizedString.class)
{
public Object getValue(Object bean) throws IllegalArgumentException
{
@@ -142,7 +142,7 @@
return portlet.getInfo().getMeta().getMetaValue(MetaInfo.DESCRIPTION);
}
});
- portletDecorator.setProperty("keywords", new
AbstractPropertyDecorator(String.class)
+ portletDecorator.setProperty("keywords", new
AbstractPropertyDecorator(LocalizedString.class)
{
public Object getValue(Object bean) throws IllegalArgumentException
{
@@ -150,7 +150,7 @@
return portlet.getInfo().getMeta().getMetaValue(MetaInfo.KEYWORDS);
}
});
- portletDecorator.setProperty("title", new
AbstractPropertyDecorator(String.class)
+ portletDecorator.setProperty("title", new
AbstractPropertyDecorator(LocalizedString.class)
{
public Object getValue(Object bean) throws IllegalArgumentException
{
@@ -158,7 +158,7 @@
return portlet.getInfo().getMeta().getMetaValue(MetaInfo.TITLE);
}
});
- portletDecorator.setProperty("remotable", new
AbstractPropertyDecorator(String.class)
+ portletDecorator.setProperty("remotable", new
AbstractPropertyDecorator(Boolean.class)
{
public Object getValue(Object bean) throws IllegalArgumentException
{
@@ -436,6 +436,13 @@
registerDecorator(ThemeService.class, themeServiceDecorator);
}
+ private String getValueForRequestLocale(LocalizedString string)
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ Locale locale = ctx.getExternalContext().getRequestLocale();
+ return string.getString(locale, true);
+ }
+
private static class PortletIconPropertyDecorator extends AbstractPropertyDecorator
{
private String iconType;
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/PortletManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/PortletManagerBean.java 2007-11-02
15:06:54 UTC (rev 8823)
+++
branches/JBoss_Portal_Branch_2_6/core-admin/src/main/org/jboss/portal/core/admin/ui/PortletManagerBean.java 2007-11-03
03:38:54 UTC (rev 8824)
@@ -24,6 +24,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.Mode;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.core.model.instance.InstanceContainer;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.portlet.Portlet;
@@ -417,7 +418,10 @@
portletInvokerItems = null;
}
- /** A comparator for portlets. Order portlets in the alphabetical order of their
display name. */
+ /**
+ * A comparator for portlets. Order portlets in the alphabetical order of their
display name. If there is no display
+ * name, fall back to portlet id.
+ */
final Comparator comparator = new Comparator()
{
FacesContext ctx = FacesContext.getCurrentInstance();
@@ -427,16 +431,28 @@
{
Portlet p1 = (Portlet)o1;
Portlet p2 = (Portlet)o2;
- String p1Name =
p1.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME).getString(locale, true);
- if (p1Name == null)
+ String p1Name;
+ String p2Name;
+ LocalizedString displayName1 =
p1.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+ LocalizedString displayName2 =
p2.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+
+ if (displayName1 != null && displayName2 != null)
{
- p1Name = p1.getContext().getId();
+ p1Name = displayName1.getString(locale, true);
+ p2Name = displayName2.getString(locale, true);
+
+ if (p1Name == null || p2Name == null)
+ {
+ p1Name = p1.getContext().getId();
+ p2Name = p2.getContext().getId();
+ }
}
- String p2Name =
p2.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME).getString(locale, true);
- if (p2Name == null)
+ else
{
+ p1Name = p1.getContext().getId();
p2Name = p2.getContext().getId();
}
+
return p1Name.compareToIgnoreCase(p2Name);
}
};
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/showPortletDetails.xhtml
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/showPortletDetails.xhtml 2007-11-02
15:06:54 UTC (rev 8823)
+++
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/common/showPortletDetails.xhtml 2007-11-03
03:38:54 UTC (rev 8824)
@@ -12,7 +12,7 @@
action="#{portletmgr.selectPortlet}">
<f:param name="id" value="#{portlet.context.id}"/>
<f:param name="plugin" value="manager"/>
- #{portlet.name.value}
+ #{portlet.name}
</h:commandLink></h:form></td>
</tr>
<tr>
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/portlets.xhtml
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/portlets.xhtml 2007-11-02
15:06:54 UTC (rev 8823)
+++
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/portlets.xhtml 2007-11-03
03:38:54 UTC (rev 8824)
@@ -48,9 +48,7 @@
title="#{portlet.context.id}">
<f:param name="id"
value="#{portlet.context.id}"/>
<f:param name="plugin"
value="manager"/>
- <h:outputText
- rendered="#{not empty
portlet.name.value}">#{portlet.name.value}</h:outputText>
- <h:outputText title="#{portlet.context.id}"
rendered="#{empty
portlet.name.value}">#{portlet.context.id}</h:outputText>
+ #{portlet.name}
</h:commandLink>
</td>
<td>#{portlet.description.value}</td>
@@ -98,7 +96,7 @@
</li>
<li class="pathSeparator"><h:graphicImage
url="/img/pathSeparator.png" alt=">"/></li>
<li class="selected">
- <span
class="objectName">#{portletmgr.selectedPortlet.name.value}</span>
details
+ <span
class="objectName">#{portletmgr.selectedPortlet.name}</span> details
</li>
</ul>
</h:form>
@@ -117,7 +115,7 @@
</li>
<li class="pathSeparator"><h:graphicImage
url="/img/pathSeparator.png" alt=">"/></li>
<li class="selected">
- <span
class="objectName">#{portletmgr.selectedPortlet.name.value}</span>
preferences
+ <span
class="objectName">#{portletmgr.selectedPortlet.name}</span>
preferences
</li>
</ul>
</h:form>
@@ -136,7 +134,7 @@
</li>
<li class="pathSeparator"><h:graphicImage
url="/img/pathSeparator.png" alt=">"/></li>
<li class="selected">
- <span
class="objectName">#{portletmgr.selectedPortlet.name.value}</span>
instance creation
+ <span
class="objectName">#{portletmgr.selectedPortlet.name}</span> instance
creation
</li>
</ul>
</h:form>
Modified:
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/wizard/selectPortlet.xhtml
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/wizard/selectPortlet.xhtml 2007-11-02
15:06:54 UTC (rev 8823)
+++
branches/JBoss_Portal_Branch_2_6/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/wizard/selectPortlet.xhtml 2007-11-03
03:38:54 UTC (rev 8824)
@@ -29,7 +29,7 @@
class="#{portlet.context.id ==
newWindowWizard.selectedPortletId ? 'portlet-section-selected' : (status.index % 2
== 0 ? 'portlet-section-body' : 'portlet-section-alternate')}">
<td title="#{portlet.description.value}">
<h:commandLink
action="#{newWindowWizard.selectPortlet}">
- <h:outputText>#{!empty portlet.name.value ?
portlet.name.value : "Unnamed"}</h:outputText>
+ <h:outputText>#{portlet.name}</h:outputText>
<f:param name="id"
value="#{portlet.context.id}"/>
<f:param name="portletInvokerId"
value="#{portletmgr.selectedPortletInvokerId}"/>
</h:commandLink></td>