Commits

tm_jee  committed 27ae148

WW-1432
- Anchor tag inserts newline at end of tag

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@2867573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits 1490800

Comments (0)

Files changed (4)

File src/java/template/simple/a-close.ftl

-</a>
+</a><#rt/>

File src/java/template/simple/a.ftl

-<a
-	<#if parameters.id?if_exists != "">id="${parameters.id?html}"</#if>
-	<#if parameters.href?if_exists != "">href="${parameters.href}"</#if>
-
+<a<#rt/>
+<#if parameters.id?if_exists != "">
+ id="${parameters.id?html}"<#rt/>
+</#if>
+<#if parameters.href?if_exists != "">
+ href="${parameters.href}"<#rt/>
+</#if>
 <#if parameters.tabindex?exists>
  tabindex="${parameters.tabindex?html}"<#rt/>
 </#if>
 </#if>
 <#include "/${parameters.templateDir}/simple/scripting-events.ftl" />
 <#include "/${parameters.templateDir}/simple/common-attributes.ftl" />
->
+><#rt/>

File src/java/template/simple/common-attributes.ftl

 <#if parameters.accesskey?exists>
  accesskey="${parameters.accesskey?html}"<#rt/>
-</#if>
+</#if>

File src/test/com/opensymphony/webwork/views/jsp/AnchorTagTest.java

 /*
- * Copyright (c) 2002-2003 by OpenSymphony
+ * Copyright (c) 2002-2007 by OpenSymphony
  * All rights reserved.
  */
 package com.opensymphony.webwork.views.jsp;
 import com.opensymphony.webwork.views.jsp.ui.AnchorTag;
 import com.opensymphony.webwork.views.jsp.ui.WebWorkBodyContent;
 
-import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.JspWriter;
 import java.io.StringWriter;
 
 
 /**
- *
  * @author Mike Porter
- * @version $Revision$
+ * @author Claus Ibsen
+ * @version $Date$ $Id$
  */
 public class AnchorTagTest extends AbstractUITagTest {
     private StringWriter writer = new StringWriter();
     private AnchorTag tag;
 
-    public void testActionURL() {
-        tag.setHref("TestAction.action");
-        try {
-            tag.doStartTag();
-            tag.doEndTag();
-            assertTrue( writer.toString().indexOf("href=\"TestAction.action\"") > -1);
-        } catch (JspException ex) {
-            ex.printStackTrace();
-            fail();
-        }
-    }
+    public void testActionURL() throws Exception {
+		tag.setHref("TestAction.action");
+		tag.doStartTag();
+		tag.doEndTag();
+		assertTrue(writer.toString().indexOf("href=\"TestAction.action\"") > -1);
+	}
+    
+    public void testNoNewLineAtEnd() throws Exception {
+		tag.setHref("TestAction.action");
+		tag.doStartTag();
+		tag.doEndTag();
+		assertFalse(writer.toString().endsWith("\n"));
+	}
+
+    public void testAccessKey() throws Exception {
+		tag.setHref("TestAction.action");
+		tag.setAccesskey("T");
+		tag.doStartTag();
+		tag.doEndTag();
+		assertTrue(writer.toString().indexOf("accesskey=\"T\"") > -1);
+		assertFalse(writer.toString().endsWith("\n"));
+	}
+
+	public void testAddParameters() throws Exception {
+		tag.setHref("/TestAction.action");
+		String bodyText = "<img src=\"#\"/>";
+		WebWorkBodyContent bodyContent = new WebWorkBodyContent(null);
+		bodyContent.print(bodyText);
+		tag.setBodyContent(bodyContent);
+
+		tag.doStartTag();
+		tag.doEndTag();
+	}
+	
+
+	public void testId() throws Exception {
+		tag.setId("home&improvements");
+		tag.doStartTag();
+		tag.doEndTag();
+		assertEquals("<a id=\"home&amp;improvements\"></a>", writer.toString());
+		assertFalse(writer.toString().endsWith("\n"));
+	}
+
+	public void testTitle() throws Exception {
+		tag.setHref("home.ftl");
+		tag.setTitle("home & improvements");
+		tag.doStartTag();
+		tag.doEndTag();
+		assertEquals(
+				"<a href=\"home.ftl\" title=\"home &amp; improvements\"></a>",
+				writer.toString());
+		assertFalse(writer.toString().endsWith("\n"));
+	}
+
+	public void testOnMouseOver() throws Exception {
+		tag.setHref("TestAction.action");
+		tag.setOnmouseover("over");
+		tag.doStartTag();
+		tag.doEndTag();
+		assertTrue(writer.toString().indexOf("onmouseover=\"over\"") > -1);
+		assertFalse(writer.toString().endsWith("\n"));
+	}
+
+	public void testOnMouseOverAndFocus() throws Exception {
+		tag.setHref("TestAction.action");
+		tag.setOnmouseover("overme");
+		tag.setOnfocus("focusme");
+		tag.doStartTag();
+		tag.doEndTag();
+		assertTrue(writer.toString().indexOf("onmouseover=\"overme\"") > -1);
+		assertTrue(writer.toString().indexOf("onfocus=\"focusme\"") > -1);
+		assertFalse(writer.toString().endsWith("\n"));
+	}
+
+	public void testWithContent() throws Exception {
+		tag.setHref("TestAction.action");
+		tag.doStartTag();
+		writer.write("Home");
+		tag.doEndTag();
+		assertEquals("<a href=\"TestAction.action\">Home</a>", writer
+				.toString());
+		assertFalse(writer.toString().endsWith("\n"));
+	}
+
+	
 
-    public void testAddParameters() {
-        tag.setHref("/TestAction.action");
-        String bodyText = "<img src=\"#\"/>";
-        try {
-            WebWorkBodyContent bodyContent = new WebWorkBodyContent(null);
-            bodyContent.print(bodyText);
-            tag.setBodyContent(bodyContent);
-
-            tag.doStartTag();
-            tag.doEndTag();
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            fail();
-        }
-    }
 
 
     protected void setUp() throws Exception {