You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by jd...@apache.org on 2007/08/05 13:54:39 UTC
svn commit: r562852 - in /wicket/trunk/jdk-1.4/wicket/src:
main/java/org/apache/wicket/markup/html/border/
test/java/org/apache/wicket/markup/html/border/
Author: jdonnerstag
Date: Sun Aug 5 04:54:37 2007
New Revision: 562852
URL: http://svn.apache.org/viewvc?view=rev&rev=562852
Log:
fixed wicket-823: Empty content inserted into Border - throws ugly exceptions
Added:
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_10.html (with props)
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_10.java (with props)
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_10.html (with props)
Modified:
wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java
wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTest.java
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java?view=diff&rev=562852&r1=562851&r2=562852
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java Sun Aug 5 04:54:37 2007
@@ -18,6 +18,7 @@
import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
+import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.WicketTag;
@@ -26,6 +27,7 @@
import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
import org.apache.wicket.markup.parser.XmlTag;
import org.apache.wicket.markup.parser.filter.WicketTagIdentifier;
+import org.apache.wicket.markup.resolver.BorderBodyResolver;
import org.apache.wicket.markup.resolver.IComponentResolver;
import org.apache.wicket.model.IModel;
@@ -84,6 +86,9 @@
* markup. The preview region (everything in between the open and close tag)
* will automatically be removed.
*
+ * @see BorderBodyResolver
+ * @see BorderBodyContainer
+ *
* @author Jonathan Locke
* @author Juergen Donnerstag
*/
@@ -165,7 +170,7 @@
*/
public Border setBorderBodyVisible(boolean bodyVisible)
{
- this.body.setVisible(false);
+ body.setVisible(false);
return this;
}
@@ -181,7 +186,7 @@
*/
public final Border setTransparentResolver(final boolean enable)
{
- this.transparentResolver = enable;
+ transparentResolver = enable;
return this;
}
@@ -191,7 +196,7 @@
*/
public boolean isTransparentResolver()
{
- return this.transparentResolver;
+ return transparentResolver;
}
/**
@@ -238,11 +243,26 @@
return false;
}
- this.body.render(markupStream);
+ body.render(markupStream);
return true;
}
/**
+ * @see org.apache.wicket.Component#onComponentTag(org.apache.wicket.markup.ComponentTag)
+ */
+ protected void onComponentTag(final ComponentTag tag)
+ {
+ if (tag.isOpen() == false)
+ {
+ throw new WicketRuntimeException(
+ "The border tag must be an open tag. Open-close is not allowed: " +
+ tag.toString());
+ }
+
+ super.onComponentTag(tag);
+ }
+
+ /**
* @see org.apache.wicket.Component#onComponentTagBody(org.apache.wicket.markup.MarkupStream,
* org.apache.wicket.markup.ComponentTag)
*/
@@ -251,13 +271,13 @@
{
// Remember the data for easy access by the Body component
this.openTag = openTag;
- this.originalMarkupStream = getMarkupStream();
+ originalMarkupStream = getMarkupStream();
// body.isVisible(false) needs a little extra work. We must skip the
// markup between <span wicket:id="myBorder"> and </span>
- if (this.body.isVisible() == false)
+ if (body.isVisible() == false)
{
- this.originalMarkupStream.skipToMatchingCloseTag(openTag);
+ originalMarkupStream.skipToMatchingCloseTag(openTag);
}
// Render the associated markup
@@ -270,7 +290,7 @@
*/
public void renderHead(HtmlHeaderContainer container)
{
- this.renderHeadFromAssociatedMarkupFile(container);
+ renderHeadFromAssociatedMarkupFile(container);
super.renderHead(container);
}
@@ -304,7 +324,7 @@
{
tag.setType(XmlTag.OPEN);
tag.setModified(true);
- this.wasOpenCloseTag = true;
+ wasOpenCloseTag = true;
}
super.onComponentTag(tag);
@@ -317,17 +337,17 @@
protected void onComponentTagBody(final MarkupStream markupStream,
final ComponentTag openTag)
{
- if (this.wasOpenCloseTag == false)
+ if (wasOpenCloseTag == false)
{
// It is open-preview-close. Only RawMarkup is allowed within
// the preview region, which gets stripped from output
markupStream.skipRawMarkup();
}
- super.onComponentTagBody(Border.this.originalMarkupStream, Border.this.openTag);
+ super.onComponentTagBody(originalMarkupStream, Border.this.openTag);
// no longer needed.
- Border.this.originalMarkupStream = null;
+ originalMarkupStream = null;
Border.this.openTag = null;
}
@@ -342,7 +362,7 @@
// Usually you add child components to Border instead of Body. Hence
// we need to help Body to properly resolve the children.
String id = tag.getId();
- if (!id.equals(Border.this.BODY_ID))
+ if (!id.equals(BODY_ID))
{
Component component = Border.this.get(id);
if (component != null)
Modified: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTest.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTest.java?view=diff&rev=562852&r1=562851&r2=562852
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTest.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTest.java Sun Aug 5 04:54:37 2007
@@ -17,6 +17,7 @@
package org.apache.wicket.markup.html.border;
import org.apache.wicket.Application;
+import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.WicketTestCase;
import org.apache.wicket.markup.MarkupException;
import org.apache.wicket.markup.html.form.Form;
@@ -155,11 +156,11 @@
public void test7() throws Exception
{
final IMarkupSettings markupSettings = Application.get().getMarkupSettings();
- markupSettings.setCompressWhitespace(true);
- markupSettings.setStripComments(true);
- markupSettings.setStripWicketTags(true);
- markupSettings.setStripXmlDeclarationFromOutput(true);
-
+ markupSettings.setCompressWhitespace(true);
+ markupSettings.setStripComments(true);
+ markupSettings.setStripWicketTags(true);
+ markupSettings.setStripXmlDeclarationFromOutput(true);
+
executeTest(BoxBorderTestPage_1.class, "BoxBorderTestPage_ExpectedResult_7.html");
}
@@ -181,5 +182,27 @@
public void test9() throws Exception
{
executeTest(BoxBorderTestPage_9.class, "BoxBorderTestPage_ExpectedResult_9.html");
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void test10() throws Exception
+ {
+ Exception e = null;
+ try
+ {
+ executeTest(BoxBorderTestPage_10.class, "BoxBorderTestPage_ExpectedResult_10.html");
+ }
+ catch (WicketRuntimeException ex)
+ {
+ if (ex.getMessage().startsWith("The border tag must be an open tag."))
+ {
+ e = ex;
+ }
+ }
+ assertNotNull(
+ "Expected a WicketRuntimeException. Border tag must be open tags. Open-close tags are not allowed",
+ e);
}
}
Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_10.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_10.html?view=auto&rev=562852
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_10.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_10.html Sun Aug 5 04:54:37 2007
@@ -0,0 +1,5 @@
+<html>
+<body>
+<span wicket:id="border1" />
+</body>
+</html>
Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_10.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_10.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_10.java?view=auto&rev=562852
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_10.java (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_10.java Sun Aug 5 04:54:37 2007
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.markup.html.border;
+
+import org.apache.wicket.markup.html.WebPage;
+
+
+/**
+ * Mock page for testing.
+ *
+ * @author Chris Turner
+ */
+public class BoxBorderTestPage_10 extends WebPage
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ *
+ *
+ */
+ public BoxBorderTestPage_10()
+ {
+ add(new BorderComponent1("border1"));
+ }
+}
Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_10.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_10.html
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_10.html?view=auto&rev=562852
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_10.html (added)
+++ wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_10.html Sun Aug 5 04:54:37 2007
@@ -0,0 +1,28 @@
+<!--
+ ====================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html>
+<body>
+<span wicket:id="border1"><wicket:border>
+<!-- with open-close tag -->
+davor <wicket:body>middle-1</wicket:body> danach
+</wicket:border></span>
+<span wicket:id="border2"><wicket:border>
+<!-- with separate open and close tag. Body is treated as pre-view region and
+ will be removed from output
+-->
+davor <wicket:body>middle-2</wicket:body> danach
+</wicket:border></span>
+</body>
+</html>
Propchange: wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BoxBorderTestPage_ExpectedResult_10.html
------------------------------------------------------------------------------
svn:eol-style = native