Author: thomas.heute(a)jboss.com
Date: 2007-08-14 09:13:41 -0400 (Tue, 14 Aug 2007)
New Revision: 7919
Modified:
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/ElementMetaData.java
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/LinkElementMetaData.java
trunk/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java
trunk/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd
trunk/core/src/resources/test/deployment/jboss-portlet.xml
Log:
JBPORTAL-1621: "title" attribute of "link" tag in jboss-portlet.xml is
unhandled
Modified: trunk/core/src/main/org/jboss/portal/core/metadata/portlet/ElementMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/ElementMetaData.java 2007-08-14
13:11:07 UTC (rev 7918)
+++
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/ElementMetaData.java 2007-08-14
13:13:41 UTC (rev 7919)
@@ -84,9 +84,9 @@
* @param media the media attribute of the link
* @return a new link header element
*/
- public static ElementMetaData createLinkElement(String type, String rel, String href,
String media)
+ public static ElementMetaData createLinkElement(String type, String rel, String href,
String media, String title)
{
- return new LinkElementMetaData(rel, type, href, media);
+ return new LinkElementMetaData(rel, type, href, media, title);
}
/**
Modified:
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/LinkElementMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/LinkElementMetaData.java 2007-08-14
13:11:07 UTC (rev 7918)
+++
trunk/core/src/main/org/jboss/portal/core/metadata/portlet/LinkElementMetaData.java 2007-08-14
13:13:41 UTC (rev 7919)
@@ -46,16 +46,21 @@
/** %MediaDesc : CDATA -- single or comma-separated list of media descriptors. */
private String mediaAttribute;
+ /** %Text : CDATA -- advisory title/amplification. */
+ private String titleAttribute;
+
public LinkElementMetaData(
String relAttribute,
String typeAttribute,
String hrefAttribute,
- String mediaAttribute)
+ String mediaAttribute,
+ String titleAttribute)
{
this.typeAttribute = typeAttribute;
this.relAttribute = relAttribute;
this.hrefAttribute = hrefAttribute;
this.mediaAttribute = mediaAttribute;
+ this.titleAttribute = titleAttribute;
}
public MarkupElement buildElement()
@@ -77,6 +82,10 @@
{
attributes.add(new MarkupAttribute("media", mediaAttribute,
MarkupAttribute.Type.MEDIA_DESC));
}
+ if (titleAttribute != null && titleAttribute.length() > 0)
+ {
+ attributes.add(new MarkupAttribute("title", titleAttribute,
MarkupAttribute.Type.TEXT));
+ }
return new MarkupElement("link", null, false,
(MarkupAttribute[])attributes.toArray(new MarkupAttribute[attributes.size()]));
}
@@ -99,4 +108,9 @@
{
return mediaAttribute;
}
+
+ public String getTitleAttribute()
+ {
+ return titleAttribute;
+ }
}
Modified:
trunk/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java 2007-08-14
13:11:07 UTC (rev 7918)
+++
trunk/core/src/main/org/jboss/portal/test/core/deployment/JBossApplicationMetaDataFactoryTestCase.java 2007-08-14
13:13:41 UTC (rev 7919)
@@ -65,7 +65,7 @@
//
assertNotNull(app.getPortlets());
- assertEquals(2, app.getPortlets().size());
+ assertEquals(3, app.getPortlets().size());
//
JBossPortletMetaData portlet =
(JBossPortletMetaData)app.getPortlets().get("Portlet1");
@@ -97,4 +97,40 @@
assertEquals("Portlet2", portlet.getName());
assertNull(portlet.getRemotable());
}
+
+ /** JBPORTAL-1621: "title" attribute of "link" tag */
+ public void testHeaderContentMetaDataTitleLink() throws Exception
+ {
+ URL jbossPortletXML =
Thread.currentThread().getContextClassLoader().getResource("test/deployment/jboss-portlet.xml");
+ assertTrue(URLTools.exists(jbossPortletXML));
+
+ //
+ JBossApplicationMetaDataFactory factory = new JBossApplicationMetaDataFactory();
+
+ //
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+
+ //
+ Object o = unmarshaller.unmarshal(jbossPortletXML.openStream(), factory, null);
+ assertNotNull(o);
+ assertTrue(o instanceof JBossApplicationMetaData);
+ JBossApplicationMetaData app = (JBossApplicationMetaData)o;
+
+ //
+ JBossPortletMetaData portlet =
(JBossPortletMetaData)app.getPortlets().get("Portlet3");
+ assertNotNull(portlet);
+ assertEquals("Portlet3", portlet.getName());
+
+ HeaderContentMetaData headerContent = portlet.getHeaderContent();
+ List elements = headerContent.getElements();
+
+ LinkElementMetaData link = (LinkElementMetaData)elements.get(0);
+ assertEquals("text/css", link.getTypeAttribute());
+ assertEquals("stylesheet", link.getRelAttribute());
+ assertEquals("screen", link.getMediaAttribute());
+ assertEquals("test.css", link.getHrefAttribute());
+ assertEquals("foo", link.getTitleAttribute());
+
+ }
+
}
Modified: trunk/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd
===================================================================
--- trunk/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd 2007-08-14 13:11:07
UTC (rev 7918)
+++ trunk/core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd 2007-08-14 13:13:41
UTC (rev 7919)
@@ -158,7 +158,8 @@
href CDATA #IMPLIED
rel CDATA #IMPLIED
type CDATA #IMPLIED
- media CDATA #IMPLIED>
+ media CDATA #IMPLIED
+ title CDATA #IMPLIED>
<!--
No content is allowed inside an link element.
Modified: trunk/core/src/resources/test/deployment/jboss-portlet.xml
===================================================================
--- trunk/core/src/resources/test/deployment/jboss-portlet.xml 2007-08-14 13:11:07 UTC
(rev 7918)
+++ trunk/core/src/resources/test/deployment/jboss-portlet.xml 2007-08-14 13:13:41 UTC
(rev 7919)
@@ -34,4 +34,10 @@
<portlet>
<portlet-name>Portlet2</portlet-name>
</portlet>
+ <portlet>
+ <portlet-name>Portlet3</portlet-name>
+ <header-content>
+ <link rel="stylesheet" type="text/css"
href="test.css" media="screen" title="foo"/>
+ </header-content>
+ </portlet>
</portlet-app>
\ No newline at end of file