Author: jcompagner Date: Thu Apr 19 15:18:25 2007 New Revision: 530570 URL: http://svn.apache.org/viewvc?view=rev&rev=530570 Log: MarkupComponentBorder fixes
Added: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BeforeAndAfterBorder.html (with props) incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BeforeAndAfterBorder.java (with props) incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java (with props) incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage.html (with props) incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage.java (with props) incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage_ExpectedResult.html (with props) Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java Modified: incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java?view=diff&rev=530570&r1=530569&r2=530570 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java (original) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java Thu Apr 19 15:18:25 2007 @@ -36,7 +36,10 @@ import org.apache.wicket.util.resource.locator.IResourceStreamLocator; /** - * @TODO Comment + * This is a IComponentBorder implementation that can be used if you have + * markup that should be around a component. It works just like [EMAIL PROTECTED] Border} + * so you have to have a <wicket:border>HTML before<wicket:body/>HTML after</wicket:border> + * in the html of your subclass. * * @author jcompagner */ @@ -78,6 +81,7 @@ if (wt.isBorderTag() && wt.isOpen()) { insideBorderMarkup = true; + continue; } else { @@ -124,54 +128,25 @@ final MarkupStream stream = getMarkupStream(component); final Response response = component.getResponse(); - boolean insideBorderMarkup = false; - boolean complete = false; while (stream.hasMore()) { MarkupElement e = stream.next(); if (e instanceof WicketTag) { WicketTag wt = (WicketTag)e; - if (!insideBorderMarkup) + if (wt.isBorderTag() && wt.isClose()) { - if (wt.isBodyTag() && (wt.isClose() || wt.isOpenClose())) - { - insideBorderMarkup = true; - } - else if (!(wt.isBorderTag() && wt.isOpen() || wt.isBodyTag())) - { - throw new WicketRuntimeException( - "Unexpected tag encountered in markup of component border " - + getClass().getName() + ". Tag: " + wt.toString() - + ", expected tag: <wicket:border> or <wicket:body>"); - } + break; } else { - if (wt.isBorderTag() && wt.isClose()) - { - complete = true; - break; - } - else - { - throw new WicketRuntimeException( - "Unexpected tag encountered in markup of component border " - + getClass().getName() + ". Tag: " + wt.toString() - + ", expected tag: </wicket:border>"); - } + throw new WicketRuntimeException( + "Unexpected tag encountered in markup of component border " + + getClass().getName() + ". Tag: " + wt.toString() + + ", expected tag: </wicket:border>"); } } - if (insideBorderMarkup) - { - response.write(e.toCharSequence()); - } - } - if (!complete) - { - throw new WicketRuntimeException( - "Missing </wicket:border> tag in markup of markup component border: " - + getClass().getName()); + response.write(e.toCharSequence()); } } @@ -186,9 +161,6 @@ private MarkupStream findMarkupStream(Component owner) { - // TODO we should open up the api to do this for any class - // not just a - // MarkupContainer so all this logic does not have to be duplicated here final String markupType = getMarkupType(owner); // Get locator to search for the resource @@ -212,12 +184,9 @@ // Did we find it already? if (resourceStream != null) { - ContainerInfo ci = new ContainerInfo(containerClass, locale, style, null, - markupType); + ContainerInfo ci = new ContainerInfo(containerClass, locale, style,null, markupType); markupResourceStream = new MarkupResourceStream(resourceStream, ci, containerClass); - - break; // TODO jcompagner: was this break missing here on - // purpose? + break; } // Walk up the class hierarchy one level, if markup has not @@ -253,7 +222,7 @@ } else { - extension = component.getParent().getMarkupId(); + extension = component.getParent().getMarkupType(); } return extension; } Added: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BeforeAndAfterBorder.html URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BeforeAndAfterBorder.html?view=auto&rev=530570 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BeforeAndAfterBorder.html (added) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BeforeAndAfterBorder.html Thu Apr 19 15:18:25 2007 @@ -0,0 +1,5 @@ +<html> +<body> +<wicket:border>[[<wicket:body/>]]</wicket:border> +</body> +</html> \ No newline at end of file Propchange: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BeforeAndAfterBorder.html ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BeforeAndAfterBorder.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BeforeAndAfterBorder.java?view=auto&rev=530570 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BeforeAndAfterBorder.java (added) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BeforeAndAfterBorder.java Thu Apr 19 15:18:25 2007 @@ -0,0 +1,34 @@ +/* + * 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.IComponentBorder; +import org.apache.wicket.markup.html.border.MarkupComponentBorder; + +/** + * @author jcompagner + * + */ +public class BeforeAndAfterBorder extends MarkupComponentBorder +{ + private static final long serialVersionUID = 1L; + + public static final IComponentBorder INSTANCE = new BeforeAndAfterBorder(); +} Propchange: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/BeforeAndAfterBorder.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java?view=auto&rev=530570 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java (added) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java Thu Apr 19 15:18:25 2007 @@ -0,0 +1,44 @@ +/* + * 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.WicketTestCase; + +/** + * @author jcompagner + */ +public class ComponentBorderTest extends WicketTestCase +{ + /** + * Create the test. + * + * @param name + * The test name + */ + public ComponentBorderTest(String name) + { + super(name); + } + + /** + * @throws Exception + */ + public void testMarkupComponentBorder() throws Exception + { + executeTest(MarkupComponentBorderTestPage.class, "MarkupComponentBorderTestPage_ExpectedResult.html"); + } +} Propchange: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/ComponentBorderTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage.html URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage.html?view=auto&rev=530570 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage.html (added) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage.html Thu Apr 19 15:18:25 2007 @@ -0,0 +1,5 @@ +<html> +<body> +<span wicket:id="label"></span> +</body> +</html> \ No newline at end of file Propchange: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage.html ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage.java URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage.java?view=auto&rev=530570 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage.java (added) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage.java Thu Apr 19 15:18:25 2007 @@ -0,0 +1,42 @@ +/* + * 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; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.model.Model; + + +/** + * Mock page for testing. + * + * @author Chris Turner + */ +public class MarkupComponentBorderTestPage extends WebPage +{ + private static final long serialVersionUID = 1L; + + /** + * Construct. + * + * + */ + public MarkupComponentBorderTestPage() + { + add(new Label("label",new Model("label")).setComponentBorder(BeforeAndAfterBorder.INSTANCE)); + } +} Propchange: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage_ExpectedResult.html URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage_ExpectedResult.html?view=auto&rev=530570 ============================================================================== --- incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage_ExpectedResult.html (added) +++ incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage_ExpectedResult.html Thu Apr 19 15:18:25 2007 @@ -0,0 +1,5 @@ +<html> +<body> +[[<span wicket:id="label">label</span>]] +</body> +</html> \ No newline at end of file Propchange: incubator/wicket/trunk/jdk-1.4/wicket/src/test/java/org/apache/wicket/markup/html/border/MarkupComponentBorderTestPage_ExpectedResult.html ------------------------------------------------------------------------------ svn:eol-style = native