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 2009/09/16 22:48:27 UTC
svn commit: r815959 [1/3] - in /wicket/trunk:
wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/
wicket-examples/src/main/java/org/apache/wicket/examples/repeater/
wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/ma...
Author: jdonnerstag
Date: Wed Sep 16 20:48:23 2009
New Revision: 815959
URL: http://svn.apache.org/viewvc?rev=815959&view=rev
Log:
First release if IMarkupFragment. See Component.getMarkup()
Added:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupFragment.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupFragment.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/list/AbstractItem.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/list/LoopItem.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/BaseMarkupFilter.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/RootMarkupFilter.java
Removed:
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupResourceData.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/resolver/EnclosureResolver.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/resolver/WicketLinkResolver.java
Modified:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/PagingPage.java
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeatingPage.java
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/repeater/data/table/AjaxFallbackHeadersToolbar.java
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/HeadersToolbar.java
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tabs/TabbedPanel.java
wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/rating/RatingPanel.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/IComponentBorder.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/Page.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/Markup.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupResourceStream.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupStream.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/WicketTag.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/HeaderPartContainer.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/internal/Enclosure.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/internal/HtmlHeaderContainer.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/list/ListItem.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/list/ListView.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/list/Loop.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/navigation/paging/PagingNavigation.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/panel/Fragment.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/panel/Panel.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/tree/AbstractTree.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/loader/InheritedMarkupMarkupLoader.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/IXmlPullParser.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/XmlPullParser.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/XmlTag.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/EnclosureHandler.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/HeadForceTagIdHandler.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHandler.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/HtmlHeaderSectionHandler.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/HtmlProblemFinder.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/RelativePathPrefixHandler.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/WicketLinkTagHandler.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/WicketMessageTagHandler.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/WicketNamespaceHandler.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/WicketRemoveTagHandler.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/parser/filter/WicketTagIdentifier.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/repeater/AbstractRepeater.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/repeater/Item.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/repeater/RepeatingView.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoComponentResolver.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/resolver/AutoLinkResolver.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/resolver/MarkupInheritanceResolver.java
wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/resolver/WicketMessageResolver.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/MarkupCacheTest.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/MarkupParserTest.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/ScopedComponentResolverTest.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/html/panel/InlinePanelPage_5.java
wicket/trunk/wicket/src/test/java/org/apache/wicket/markup/parser/XmlPullParserTest.java
Modified: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java (original)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/portlet/menu/MenuPage.java Wed Sep 16 20:48:23 2009
@@ -23,6 +23,7 @@
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.list.Loop;
+import org.apache.wicket.markup.html.list.LoopItem;
import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
/**
@@ -41,14 +42,14 @@
@Override
protected void populateItem(LoopItem item)
{
- final int index = item.getIteration();
+ final int index = item.getIndex();
ExampleApplication ea = WicketExamplesMenuApplication.getExamples().get(index + 1);
Link link = new Link("example")
{
@Override
public void onClick()
{
- int index = ((LoopItem)getParent()).getIteration();
+ int index = ((LoopItem)getParent()).getIndex();
ExampleApplication ea = WicketExamplesMenuApplication.getExamples().get(
index + 1);
PortletSession session = ((PortletRequestContext)RequestContext.get()).getPortletRequest()
Modified: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/PagingPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/PagingPage.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/PagingPage.java (original)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/PagingPage.java Wed Sep 16 20:48:23 2009
@@ -39,7 +39,6 @@
{
DataView<Contact> dataView = new DataView<Contact>("pageable", new ContactDataProvider())
{
-
@Override
protected void populateItem(final Item<Contact> item)
{
Modified: wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeatingPage.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeatingPage.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeatingPage.java (original)
+++ wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/repeater/RepeatingPage.java Wed Sep 16 20:48:23 2009
@@ -19,8 +19,8 @@
import java.util.Iterator;
import org.apache.wicket.AttributeModifier;
-import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.list.AbstractItem;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.AbstractReadOnlyModel;
@@ -45,7 +45,8 @@
int index = 0;
while (contacts.hasNext())
{
- WebMarkupContainer item = new WebMarkupContainer(repeating.newChildId());
+ AbstractItem item = new AbstractItem(repeating.newChildId());
+
repeating.add(item);
Contact contact = contacts.next();
Modified: wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/repeater/data/table/AjaxFallbackHeadersToolbar.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/repeater/data/table/AjaxFallbackHeadersToolbar.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/repeater/data/table/AjaxFallbackHeadersToolbar.java (original)
+++ wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/repeater/data/table/AjaxFallbackHeadersToolbar.java Wed Sep 16 20:48:23 2009
@@ -49,7 +49,6 @@
table.setOutputMarkupId(true);
}
-
/**
* @see org.apache.wicket.extensions.markup.html.repeater.data.table.HeadersToolbar#newSortableHeader(java.lang.String,
* java.lang.String,
@@ -88,6 +87,4 @@
{
return null;
}
-
-
}
Modified: wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java (original)
+++ wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/DataTable.java Wed Sep 16 20:48:23 2009
@@ -22,6 +22,7 @@
import org.apache.wicket.extensions.markup.html.repeater.data.grid.DataGridView;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.list.AbstractItem;
import org.apache.wicket.markup.html.navigation.paging.IPageable;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.repeater.IItemReuseStrategy;
@@ -382,12 +383,11 @@
*
* @author igor.vaynberg
*/
- private final class ToolbarContainer extends WebMarkupContainer
+ private final class ToolbarContainer extends AbstractItem
{
private static final long serialVersionUID = 1L;
/**
- *
* Construct.
*
* @param id
@@ -396,6 +396,13 @@
{
super(id);
}
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean isVisible()
+ {
+ return ((Component)iterator().next()).isVisible();
+ }
}
/**
Modified: wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/HeadersToolbar.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/HeadersToolbar.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/HeadersToolbar.java (original)
+++ wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/HeadersToolbar.java Wed Sep 16 20:48:23 2009
@@ -19,6 +19,7 @@
import org.apache.wicket.extensions.markup.html.repeater.data.sort.ISortStateLocator;
import org.apache.wicket.extensions.markup.html.repeater.data.sort.OrderByBorder;
import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.list.AbstractItem;
import org.apache.wicket.markup.repeater.RepeatingView;
@@ -53,7 +54,7 @@
final IColumn<?>[] columns = table.getColumns();
for (final IColumn<?> column : columns)
{
- WebMarkupContainer item = new WebMarkupContainer(headers.newChildId());
+ AbstractItem item = new AbstractItem(headers.newChildId());
headers.add(item);
WebMarkupContainer header = null;
@@ -113,5 +114,4 @@
}
};
}
-
}
Modified: wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tabs/TabbedPanel.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tabs/TabbedPanel.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tabs/TabbedPanel.java (original)
+++ wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tabs/TabbedPanel.java Wed Sep 16 20:48:23 2009
@@ -25,7 +25,7 @@
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.list.Loop;
-import org.apache.wicket.markup.html.list.Loop.LoopItem;
+import org.apache.wicket.markup.html.list.LoopItem;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
@@ -131,7 +131,7 @@
@Override
protected void populateItem(LoopItem item)
{
- final int index = item.getIteration();
+ final int index = item.getIndex();
final ITab tab = (TabbedPanel.this.tabs.get(index));
final WebMarkupContainer titleLink = newLink("link", index);
@@ -169,13 +169,13 @@
{
cssClass = " ";
}
- cssClass += " tab" + getIteration();
+ cssClass += " tab" + getIndex();
- if (getIteration() == getSelectedTab())
+ if (getIndex() == getSelectedTab())
{
cssClass += " selected";
}
- if (getIteration() == getTabs().size() - 1)
+ if (getIndex() == getTabs().size() - 1)
{
cssClass += " last";
}
Modified: wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/rating/RatingPanel.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/rating/RatingPanel.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/rating/RatingPanel.java (original)
+++ wicket/trunk/wicket-extensions/src/main/java/org/apache/wicket/extensions/rating/RatingPanel.java Wed Sep 16 20:48:23 2009
@@ -25,6 +25,7 @@
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.Loop;
+import org.apache.wicket.markup.html.list.LoopItem;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
@@ -121,7 +122,7 @@
// of our rating component, so other components can also get
// updated in case of an AJAX event.
- onRated(item.getIteration() + 1, target);
+ onRated(item.getIndex() + 1, target);
// if we process an AJAX event, update this panel
if (target != null)
@@ -137,7 +138,7 @@
}
};
- int iteration = item.getIteration();
+ int iteration = item.getIndex();
// add the star image, which is either active (highlighted) or
// inactive (no star)
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Application.java Wed Sep 16 20:48:23 2009
@@ -36,17 +36,17 @@
import org.apache.wicket.markup.html.IHeaderContributor;
import org.apache.wicket.markup.html.IHeaderResponse;
import org.apache.wicket.markup.html.image.resource.DefaultButtonImageResourceFactory;
+import org.apache.wicket.markup.parser.filter.EnclosureHandler;
import org.apache.wicket.markup.parser.filter.RelativePathPrefixHandler;
+import org.apache.wicket.markup.parser.filter.WicketLinkTagHandler;
import org.apache.wicket.markup.parser.filter.WicketMessageTagHandler;
import org.apache.wicket.markup.resolver.AutoComponentResolver;
import org.apache.wicket.markup.resolver.BorderBodyResolver;
-import org.apache.wicket.markup.resolver.EnclosureResolver;
import org.apache.wicket.markup.resolver.FragmentResolver;
import org.apache.wicket.markup.resolver.HtmlHeaderResolver;
import org.apache.wicket.markup.resolver.MarkupInheritanceResolver;
import org.apache.wicket.markup.resolver.ParentResolver;
import org.apache.wicket.markup.resolver.WicketContainerResolver;
-import org.apache.wicket.markup.resolver.WicketLinkResolver;
import org.apache.wicket.markup.resolver.WicketMessageResolver;
import org.apache.wicket.protocol.http.IRequestLogger;
import org.apache.wicket.protocol.http.RequestLogger;
@@ -117,9 +117,7 @@
/** Configuration constant for the 2 types */
public static final String CONFIGURATION = "configuration";
- /**
- * Configuration type constant for getting the context path out of the web.xml
- */
+ /** Configuration type constant for getting the context path out of the web.xml */
public static final String CONTEXTPATH = "contextpath";
/** Configuration type constant for deployment */
@@ -908,12 +906,12 @@
pageSettings.addComponentResolver(new AutoComponentResolver());
pageSettings.addComponentResolver(new MarkupInheritanceResolver());
pageSettings.addComponentResolver(new HtmlHeaderResolver());
- pageSettings.addComponentResolver(new WicketLinkResolver());
+ pageSettings.addComponentResolver(new WicketLinkTagHandler());
pageSettings.addComponentResolver(new WicketMessageResolver());
pageSettings.addComponentResolver(new WicketMessageTagHandler());
pageSettings.addComponentResolver(new FragmentResolver());
pageSettings.addComponentResolver(new RelativePathPrefixHandler());
- pageSettings.addComponentResolver(new EnclosureResolver());
+ pageSettings.addComponentResolver(new EnclosureHandler());
pageSettings.addComponentResolver(new WicketContainerResolver());
pageSettings.addComponentResolver(new BorderBodyResolver());
@@ -1184,4 +1182,15 @@
}
}
}
+
+ /**
+ * TODO To be removed before we release 1.5. By default IMarkupFragment is enabled. In case it
+ * cases to much problems, you may disable by subclassing this method and returning false.
+ *
+ * @return true, if IMarkupFragment resp. getMarkup() shall be enabled.
+ */
+ public boolean getMarkupFragmentEnabled()
+ {
+ return true;
+ }
}
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Component.java Wed Sep 16 20:48:23 2009
@@ -33,6 +33,7 @@
import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.feedback.IFeedback;
import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.IMarkupFragment;
import org.apache.wicket.markup.MarkupException;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.WicketTag;
@@ -318,7 +319,9 @@
* Undo change for component border property
*
* @author ivaynberg
+ * @deprecated since 1.4 please use IBehavior renderBefore and renderAfter instead
*/
+ @Deprecated
private class ComponentBorderChange extends Change
{
private static final long serialVersionUID = 1L;
@@ -525,7 +528,12 @@
*/
public static final Action RENDER = new Action(Action.RENDER);
- /** meta data key for missing body tags logging. */
+ /**
+ * meta data key for missing body tags logging.
+ *
+ * @deprecated since 1.4 please use IBehavior renderBefore and renderAfter instead
+ */
+ @Deprecated
private static final MetaDataKey<IComponentBorder> BORDER_KEY = new MetaDataKey<IComponentBorder>()
{
private static final long serialVersionUID = 1L;
@@ -932,6 +940,42 @@
}
/**
+ * Get the Markup associated with the Component. If not subclassed, the parent container is
+ * asked to return the markup of this child component.
+ * <p/>
+ * Components like Panel and Border should return the "calling" markup fragment, e.g.
+ * <code><span wicket:id="myPanel">body</span></code>. You may use
+ * Panel/Border/Enclosure.getMarkup(null) to return the associated markup file. And
+ * Panel/Border/Enclosure.getMarkup(child) will search the child in the appropriate markup
+ * fragment.
+ *
+ * @see MarkupContainer#getMarkup(Component)
+ *
+ * @return The markup fragment
+ */
+ public IMarkupFragment getMarkup()
+ {
+ if (parent == null)
+ {
+ throw new MarkupException(
+ "Can not determine Markup. Component is not yet connected to a parent. " +
+ toString());
+ }
+ return parent.getMarkup(this);
+ }
+
+ /**
+ * Callback method invoked after the component was added to its parent AND you can walk up the
+ * hierarchy up until the Page. That is, all parents must be have been added to their parents as
+ * well. Add this point in time {@link #getMarkup() getMarkup} is guaranteed to be available.
+ * <p/>
+ * If you don't like constructors to initialize your component, this is the method to use.
+ */
+ protected void onConnectedToPage()
+ {
+ }
+
+ /**
* Adds a behavior modifier to the component.
*
* <p>
@@ -1344,7 +1388,9 @@
/**
* @return component border assigned to this component, or null if none
+ * @deprecated since 1.4 please use IBehavior renderBefore and renderAfter instead
*/
+ @Deprecated
public final IComponentBorder getComponentBorder()
{
return getMetaData(BORDER_KEY);
@@ -2370,6 +2416,15 @@
*/
public final void render(final MarkupStream markupStream)
{
+ if (getApplication().getMarkupFragmentEnabled())
+ {
+ IMarkupFragment markup = getMarkup();
+ if (!(this instanceof Page) && (markup == null))
+ {
+ throw new IllegalArgumentException("jdo: Markup not found: " + toString());
+ }
+ }
+
// We need to know the index before we do the visibility check.
// Otherwise we wouldn't know the markup index for invisible components
if (markupStream != null)
@@ -2739,7 +2794,9 @@
* @param border
* component border to assign, or <code>null</code> to clear any previous
* @return component for chaining
+ * @deprecated since 1.4 please use IBehavior renderBefore and renderAfter instead
*/
+ @Deprecated
public final Component setComponentBorder(final IComponentBorder border)
{
if (!Objects.equal(getComponentBorder(), border))
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/IComponentBorder.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/IComponentBorder.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/IComponentBorder.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/IComponentBorder.java Wed Sep 16 20:48:23 2009
@@ -24,7 +24,9 @@
* @author jcompagner
*
* @see MarkupComponentBorder
+ * @deprecated since 1.4 please use IBehavior renderBefore and renderAfter instead
*/
+@Deprecated
public interface IComponentBorder extends IClusterable
{
/**
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/MarkupContainer.java Wed Sep 16 20:48:23 2009
@@ -24,6 +24,8 @@
import java.util.List;
import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.IMarkupFragment;
+import org.apache.wicket.markup.Markup;
import org.apache.wicket.markup.MarkupElement;
import org.apache.wicket.markup.MarkupException;
import org.apache.wicket.markup.MarkupNotFoundException;
@@ -34,7 +36,6 @@
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.IWrapModel;
import org.apache.wicket.settings.IDebugSettings;
-import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.string.Strings;
import org.apache.wicket.version.undo.Change;
import org.slf4j.Logger;
@@ -145,7 +146,6 @@
throw new IllegalArgumentException(exceptionMessage("A child with id '" +
child.getId() + "' already exists"));
}
-
}
return this;
}
@@ -332,10 +332,50 @@
*/
public MarkupStream getAssociatedMarkupStream(final boolean throwException)
{
+ IMarkupFragment markup = getAssociatedMarkup();
+
+ // If we found markup for this container
+ if (markup != null)
+ {
+ return new MarkupStream(markup);
+ }
+
+ if (throwException == true)
+ {
+ // throw exception since there is no associated markup
+ throw new MarkupNotFoundException(
+ "Markup of type '" +
+ getMarkupType() +
+ "' for component '" +
+ getClass().getName() +
+ "' not found." +
+ " Enable debug messages for org.apache.wicket.util.resource to get a list of all filenames tried.: " +
+ toString());
+ }
+
+ return null;
+ }
+
+ /**
+ * Gets a fresh markup stream that contains the (immutable) markup resource for this class.
+ *
+ * @return A stream of MarkupElement elements
+ */
+ public IMarkupFragment getAssociatedMarkup()
+ {
try
{
- return getApplication().getMarkupSettings().getMarkupCache().getMarkupStream(this,
- false, throwException);
+ IMarkupFragment markup = getApplication().getMarkupSettings()
+ .getMarkupCache()
+ .getMarkup(this, false);
+
+ // If we found markup for this container
+ if ((markup != null) && (markup != Markup.NO_MARKUP))
+ {
+ return markup;
+ }
+
+ return null;
}
catch (MarkupException ex)
{
@@ -360,7 +400,6 @@
}
}
-
/**
* Get the markup stream set on this container.
*
@@ -371,6 +410,88 @@
return markupStream;
}
+ /**
+ * Get the childs markup
+ *
+ * @see Component#getMarkup()
+ *
+ * @param child
+ * The child component. If null, the container's markup will be returned. See Border,
+ * Panel or Enclosure where getMarkup(null) != getMarkup().
+ * @return The childs markup
+ */
+ public IMarkupFragment getMarkup(final Component child)
+ {
+ // Get the markup for the container
+ IMarkupFragment markup = getMarkup();
+ if (markup == null)
+ {
+ throw new MarkupException("Unable to determine Markup for Component: " + toString());
+ }
+ else if (child == null)
+ {
+ return markup;
+ }
+
+ // Find the childs markup
+ markup = markup.find(null, child.getId(), 0);
+ if (markup != null)
+ {
+ return markup;
+ }
+
+ // The following code makes sure that add(new Border()).setTransparentResolver(true) is
+ // properly covered as well.
+ markup = (IMarkupFragment)visitChildren(new IVisitor<Component>()
+ {
+ public Object component(final Component component)
+ {
+ if (component instanceof MarkupContainer)
+ {
+ MarkupContainer container = (MarkupContainer)component;
+ if (container.isTransparentResolver())
+ {
+ IMarkupFragment markup = container.getMarkup(child);
+ if (markup != null)
+ {
+ return markup;
+ }
+ return CONTINUE_TRAVERSAL;
+ }
+ }
+ return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
+ }
+ });
+
+ // This is to make migration for Items from 1.4 to 1.5 more easy
+ if (Character.isDigit(child.getId().charAt(0)))
+ {
+ String id = child.getId();
+ boolean miss = false;
+ for (int i = 1; i < id.length(); i++)
+ {
+ if (Character.isDigit(id.charAt(i)) == false)
+ {
+ miss = true;
+ break;
+ }
+ }
+
+ if (miss == false)
+ {
+ // The LoopItems markup is equal to the Loops markup
+ markup = getMarkup();
+
+ if (log.isWarnEnabled())
+ {
+ log.warn("1.4 to 1.5 migration issue: your item component should be derived from AbstractItem. Item=" +
+ child.toString());
+ }
+ }
+ }
+
+ return markup;
+ }
/**
* Get the type of associated markup for this component.
@@ -485,24 +606,6 @@
}
/**
- * NOT USED ANYMORE; it's here for helping people migrate from Wicket 1.2 to Wicket 1.3
- *
- * @param <C>
- *
- * @param containerClass
- * @return nothing
- * @throws IllegalStateException
- * throws an {@link IllegalStateException}
- */
- // TODO remove after release 1.3.0
- public final <C extends Component> IResourceStream newMarkupResourceStream(
- Class<C> containerClass)
- {
- throw new IllegalStateException(
- "this method is not used any more (and shouldn't be called by clients anyway)");
- }
-
- /**
* @param component
* Component to remove from this container
*/
@@ -905,46 +1008,62 @@
}
/**
- * @param component
+ * @param child
* Component being added
*/
- private final void addedComponent(final Component component)
+ private final void addedComponent(final Component child)
{
// Check for degenerate case
- if (component == this)
+ if (child == this)
{
throw new IllegalArgumentException("Component can't be added to itself");
}
- MarkupContainer parent = component.getParent();
+ MarkupContainer parent = child.getParent();
if (parent != null)
{
- parent.remove(component);
+ parent.remove(child);
}
// Set child's parent
- component.setParent(this);
+ child.setParent(this);
final Page page = findPage();
final IDebugSettings debugSettings = Application.get().getDebugSettings();
if (debugSettings.isLinePreciseReportingOnAddComponentEnabled())
{
- component.setMetaData(ADDED_AT_KEY, Strings.toString(component, new MarkupException(
+ child.setMetaData(ADDED_AT_KEY, Strings.toString(child, new MarkupException(
"added")));
}
if (page != null)
{
- page.componentAdded(component);
+ child.onConnectedToPage();
+
+ // Tell all children of "component" as well
+ if (child instanceof MarkupContainer)
+ {
+ MarkupContainer container = (MarkupContainer)child;
+ container.visitChildren(new IVisitor<Component>()
+ {
+ public Object component(final Component component)
+ {
+ component.onConnectedToPage();
+ return CONTINUE_TRAVERSAL;
+ }
+ });
+ }
+
+ // Tell the page a component has been added
+ page.componentAdded(child);
}
// if the PREPARED_FOR_RENDER flag is set, we have already called
- // beforeRender on this
- // component's children. So we need to initialize the newly added one
+ // beforeRender on this component's children. So we need to initialize the newly added one
if (isPreparedForRender())
{
- component.beforeRender();
+ child.beforeRender();
}
}
@@ -1959,6 +2078,5 @@
list.childs[idx1] = list.childs[idx2];
list.childs[idx2] = tmp;
}
-
}
}
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/Page.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/Page.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/Page.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/Page.java Wed Sep 16 20:48:23 2009
@@ -30,6 +30,7 @@
import org.apache.wicket.authorization.IAuthorizationStrategy;
import org.apache.wicket.authorization.UnauthorizedActionException;
import org.apache.wicket.authorization.strategies.page.SimplePageAuthorizationStrategy;
+import org.apache.wicket.markup.IMarkupFragment;
import org.apache.wicket.markup.MarkupException;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.html.WebPage;
@@ -1584,6 +1585,9 @@
{
}
+ /**
+ * @see org.apache.wicket.MarkupContainer#getMarkupType()
+ */
@Override
public String getMarkupType()
{
@@ -1601,4 +1605,13 @@
setStatelessHint(false);
return new PageReference(pageMapName, numericId, getCurrentVersionNumber());
}
+
+ /**
+ * @see org.apache.wicket.Component#getMarkup()
+ */
+ @Override
+ public IMarkupFragment getMarkup()
+ {
+ return getAssociatedMarkup();
+ }
}
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java Wed Sep 16 20:48:23 2009
@@ -74,7 +74,7 @@
private String path;
/** True, if attributes have been modified or added */
- private boolean modified = false;
+ private transient boolean modified = false;
/**
* If true, than the MarkupParser will ignore (remove) it. Temporary working variable
@@ -737,7 +737,7 @@
*
* @return True, if the component tag has been marked modified
*/
- public final boolean isModified()
+ final boolean isModified()
{
return modified;
}
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupCache.java Wed Sep 16 20:48:23 2009
@@ -62,8 +62,7 @@
* If true, throw an exception, if markup could not be found
* @return A stream of MarkupElement elements
*/
- MarkupStream getMarkupStream(final MarkupContainer container, final boolean enforceReload,
- final boolean throwException);
+ IMarkupFragment getMarkup(final MarkupContainer container, final boolean enforceReload);
/**
* Check if container has associated markup
@@ -83,7 +82,7 @@
* @param cacheKey
* @return The markup removed from the cache. Null, if nothing was found.
*/
- Markup removeMarkup(final String cacheKey);
+ IMarkupFragment removeMarkup(final String cacheKey);
/**
* @return the number of elements currently in the cache.
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupFragment.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupFragment.java?rev=815959&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupFragment.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/IMarkupFragment.java Wed Sep 16 20:48:23 2009
@@ -0,0 +1,82 @@
+/*
+ * 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;
+
+
+/**
+ * Any list of MarkupElements. May be the content of complete markup file or just a portion of it.
+ *
+ * @see Markup
+ * @see MarkupFragment
+ * @see MarkupElement
+ *
+ * @author Juergen Donnerstag
+ */
+public interface IMarkupFragment
+{
+ /**
+ * Get the MarkupElement at the index provided.
+ *
+ * @param index
+ * Index into markup list
+ * @return Markup element
+ * @throws IndexOutOfBoundsException
+ * if the index is out of range (<tt>index < 0 || index >= size()</tt>)
+ */
+ MarkupElement get(final int index);
+
+ /**
+ * Get the underlying markup resource stream, which might contain more than just the markup
+ * portion represented by the IMarkupFragment.
+ *
+ * @return The underlying markup resource stream
+ */
+ MarkupResourceStream getMarkupResourceStream();
+
+ /**
+ * The number of markup elements.
+ *
+ * @return Number of markup elements
+ */
+ int size();
+
+ /**
+ * Find the markup element index of the component with 'path'
+ *
+ * @param path
+ * The component path expression
+ * @param id
+ * The component's id to search for
+ * @param startIndex
+ * Index to start searching
+ * @return -1, if not found
+ */
+ int findComponentIndex(final String path, final String id, final int startIndex);
+
+ /**
+ * Find the markup element index of the component with 'path'
+ *
+ * @param path
+ * The component path expression
+ * @param id
+ * The component's id to search for
+ * @param startIndex
+ * Index to start searching
+ * @return -1, if not found
+ */
+ IMarkupFragment find(final String path, final String id, final int startIndex);
+}
\ No newline at end of file
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/Markup.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/Markup.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/Markup.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/Markup.java Wed Sep 16 20:48:23 2009
@@ -25,34 +25,34 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.wicket.util.resource.IFixedLocationResourceStream;
import org.apache.wicket.util.string.AppendingStringBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * A list of markup elements associated with a Markup. Might be all elements of a markup resource,
- * might be just the elements associated with a specific tag.
+ * The content of a markup file, consisting of aalist of markup elements.
*
- * @see org.apache.wicket.markup.MarkupResourceData
- * @see org.apache.wicket.markup.MarkupElement
- * @see org.apache.wicket.markup.ComponentTag
- * @see org.apache.wicket.markup.RawMarkup
+ * @see MarkupResourceStream
+ * @see MarkupElement
+ * @see ComponentTag
+ * @see RawMarkup
*
* @author Juergen Donnerstag
*/
-public class Markup
+public class Markup implements IMarkupFragment
{
private static final Logger log = LoggerFactory.getLogger(Markup.class);
/** Placeholder that indicates no markup */
- public static final Markup NO_MARKUP = new Markup(MarkupResourceData.NO_MARKUP_RESOURCE_DATA);
+ public static final Markup NO_MARKUP = new Markup();
/** The list of markup elements */
private/* final */List<MarkupElement> markupElements;
- /** The associated markup */
- private final MarkupResourceData markupResourceData;
+ /** The associated markup file */
+ private final MarkupResourceStream markupResourceStream;
/** A cache which maps (componentPath + id) to the componentTags index in the markup */
private Map<String, Integer> componentMap;
@@ -64,24 +64,32 @@
private StringBuffer currentPath;
/**
+ * Private Constructor for NO_MARKUP only
+ */
+ private Markup()
+ {
+ markupResourceStream = null;
+ }
+
+ /**
* Constructor
*
- * @param markupResourceData
+ * @param markupResourceStream
* The associated Markup
*/
- public Markup(final MarkupResourceData markupResourceData)
+ public Markup(final MarkupResourceStream markupResourceStream)
{
- this.markupResourceData = markupResourceData;
+ if (markupResourceStream == null)
+ {
+ throw new IllegalArgumentException("Parameter 'markupResourceStream' must not be null");
+ }
+
+ this.markupResourceStream = markupResourceStream;
markupElements = new ArrayList<MarkupElement>();
}
/**
- * For Wicket it would be sufficient for this method to be package protected. However to allow
- * wicket-bench easy access to the information ...
- *
- * @param index
- * Index into markup list
- * @return Markup element
+ * @see org.apache.wicket.markup.IMarkupFragment#get(int)
*/
public final MarkupElement get(final int index)
{
@@ -89,34 +97,32 @@
}
/**
- * Gets the associate markup
- *
- * @return The associated markup
+ * @see org.apache.wicket.markup.IMarkupFragment#getMarkupResourceStream()
*/
- public final MarkupResourceData getMarkupResourceData()
+ public final MarkupResourceStream getMarkupResourceStream()
{
- return markupResourceData;
+ return markupResourceStream;
}
/**
- * Allowing the markup to return its own location allows special types of Markup (i.e.
- * MergedMarkup) to override their location, as they are composed of multiple Markups in
- * different locations. SEE WICKET-1507 (Jeremy Thomerson)
+ * @see MarkupResourceStream#locationAsString()
+<<<<<<< HEAD:wicket/src/main/java/org/apache/wicket/markup/Markup.java
+ * @return Markup Resource Stream location as string
+=======
+ * @see IFixedLocationResourceStream#locationAsString()
*
- * @return the location of this markup
+ * @return The fixed location as a string, e.g. the file name or the URL
+>>>>>>> found a bug. Unfortunately it is not yet working correctly.:wicket/src/main/java/org/apache/wicket/markup/Markup.java
*/
public String locationAsString()
{
- return markupResourceData.getResource().locationAsString();
+ return markupResourceStream.locationAsString();
}
/**
- * For Wicket it would be sufficient for this method to be package protected. However to allow
- * wicket-bench easy access to the information ...
- *
- * @return Number of markup elements
+ * @see org.apache.wicket.markup.IMarkupFragment#size()
*/
- public int size()
+ public final int size()
{
return markupElements.size();
}
@@ -171,7 +177,7 @@
{
// Only if the tag has wicket:id="xx" and open or open-close
if ((tag.isOpen() || tag.isOpenClose()) &&
- tag.getAttributes().containsKey(getMarkupResourceData().getWicketId()))
+ tag.getAttributes().containsKey(getMarkupResourceStream().getWicketId()))
{
// Add the tag to the cache
if (componentMap == null)
@@ -211,7 +217,7 @@
{
// Only if the tag has wicket:id="xx" and open or open-close
if ((tag.isOpen() || tag.isOpenClose()) &&
- tag.getAttributes().containsKey(markupResourceData.getWicketId()))
+ tag.getAttributes().containsKey(markupResourceStream.getWicketId()))
{
// With open-close the path does not change. It can/will not have
// children. The same is true for HTML tags like <br> or <img>
@@ -246,7 +252,7 @@
{
// For example <wicket:message> does not have an id
if ((tag.getOpenTag() == null) ||
- tag.getOpenTag().getAttributes().containsKey(markupResourceData.getWicketId()))
+ tag.getOpenTag().getAttributes().containsKey(markupResourceStream.getWicketId()))
{
// Remove the last element from the component path
int index = currentPath.lastIndexOf(":");
@@ -265,15 +271,10 @@
}
/**
- * Find the markup element index of the component with 'path'
- *
- * @param path
- * The component path expression
- * @param id
- * The component's id to search for
- * @return -1, if not found
+ * @see org.apache.wicket.markup.IMarkupFragment#findComponentIndex(java.lang.String,
+ * java.lang.String, int)
*/
- public int findComponentIndex(final String path, final String id)
+ public final int findComponentIndex(final String path, final String id, final int startIndex)
{
if ((id == null) || (id.length() == 0))
{
@@ -296,41 +297,57 @@
completePath = matcher.replaceAll("");
// All component tags are registered with the cache
- if (componentMap == null)
+ if (componentMap != null)
{
- // not found
- return -1;
+ final Integer value = componentMap.get(completePath);
+ if (value != null)
+ {
+ // return the components position in the markup stream
+ return value.intValue();
+ }
}
- final Integer value = componentMap.get(completePath);
- if (value == null)
+ for (int i = Math.max(0, startIndex); i < size(); i++)
{
- // not found
- return -1;
+ MarkupElement elem = get(i);
+ if (elem instanceof ComponentTag)
+ {
+ ComponentTag tag = (ComponentTag)elem;
+ if (tag.isAutoComponentTag() && (tag.getId() != null) && tag.getId().startsWith(id))
+ {
+ return i;
+ }
+ }
}
- // return the components position in the markup stream
- return value.intValue();
+ return -1;
}
/**
+<<<<<<< HEAD:wicket/src/main/java/org/apache/wicket/markup/Markup.java
+ * Compare two Markups
+ *
* @param that
- * The markup to compare with
- * @return True if the two markups are equal
+ * @return true, if equal
+=======
+ *
+ * @see org.apache.wicket.markup.IMarkupFragment#find(java.lang.String, java.lang.String, int)
+>>>>>>> found a bug. Unfortunately it is not yet working correctly.:wicket/src/main/java/org/apache/wicket/markup/Markup.java
*/
- public boolean equalTo(final Markup that)
+ public final IMarkupFragment find(final String path, final String id, final int startIndex)
{
- final MarkupStream thisStream = new MarkupStream(this);
- final MarkupStream thatStream = new MarkupStream(that);
-
- // Compare the streams
- return thisStream.equalTo(thatStream);
+ int index = findComponentIndex(path, id, startIndex);
+ if (index >= 0)
+ {
+ return new MarkupFragment(this, index);
+ }
+ return null;
}
/**
* Initialize the index where wicket tags can be found
*/
- protected void initialize()
+ protected final void initialize()
{
// Reset
componentMap = null;
@@ -364,13 +381,13 @@
}
/**
- * @return String representation of markup list
+ * @see org.apache.wicket.markup.IMarkupFragment#toString()
*/
@Override
public final String toString()
{
final AppendingStringBuffer buf = new AppendingStringBuffer(400);
- buf.append(markupResourceData.toString());
+ buf.append(markupResourceStream.toString());
buf.append("\n");
final Iterator<MarkupElement> iter = markupElements.iterator();
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java Wed Sep 16 20:48:23 2009
@@ -113,7 +113,7 @@
/**
* @see org.apache.wicket.markup.IMarkupCache#removeMarkup(java.lang.String)
*/
- public final Markup removeMarkup(final String cacheKey)
+ public final IMarkupFragment removeMarkup(final String cacheKey)
{
if (cacheKey == null)
{
@@ -128,7 +128,7 @@
// Remove the markup and any other markup which depends on it
// (inheritance)
String locationString = (String)markupKeyCache.get(cacheKey);
- Markup markup = markupCache.get(locationString);
+ IMarkupFragment markup = markupCache.get(locationString);
if (markup != null)
{
markupCache.remove(locationString);
@@ -148,11 +148,11 @@
while (iter.hasNext())
{
Markup cacheMarkup = markupCache.get(iter.next());
- MarkupResourceData resourceData = cacheMarkup.getMarkupResourceData()
- .getBaseMarkupResourceData();
+ MarkupResourceStream resourceData = cacheMarkup.getMarkupResourceStream()
+ .getBaseMarkupResourceStream();
if (resourceData != null)
{
- String baseCacheKey = resourceData.getResource().getCacheKey();
+ String baseCacheKey = resourceData.getCacheKey();
String baseLocationString = (String)markupKeyCache.get(baseCacheKey);
if (baseLocationString != null &&
markupCache.get(baseLocationString) == null)
@@ -160,7 +160,7 @@
if (log.isDebugEnabled())
{
log.debug("Remove from cache: cacheKey=" +
- cacheMarkup.getMarkupResourceData().getResource().getCacheKey());
+ cacheMarkup.getMarkupResourceStream().getCacheKey());
}
iter.remove();
@@ -201,11 +201,11 @@
}
/**
- * @see org.apache.wicket.markup.IMarkupCache#getMarkupStream(org.apache.wicket.MarkupContainer,
- * boolean, boolean)
+ * @see org.apache.wicket.markup.IMarkupCache#getMarkup(org.apache.wicket.MarkupContainer,
+ * boolean)
*/
- public final MarkupStream getMarkupStream(final MarkupContainer container,
- final boolean enforceReload, final boolean throwException)
+ public final IMarkupFragment getMarkup(final MarkupContainer container,
+ final boolean enforceReload)
{
if (container == null)
{
@@ -213,28 +213,7 @@
}
// Look for associated markup
- final Markup markup = getMarkup(container, container.getClass(), enforceReload);
-
- // If we found markup for this container
- if (markup != Markup.NO_MARKUP)
- {
- return new MarkupStream(markup);
- }
-
- if (throwException == true)
- {
- // throw exception since there is no associated markup
- throw new MarkupNotFoundException(
- "Markup of type '" +
- container.getMarkupType() +
- "' for component '" +
- container.getClass().getName() +
- "' not found." +
- " Enable debug messages for org.apache.wicket.util.resource to get a list of all filenames tried.: " +
- container.toString());
- }
-
- return null;
+ return getMarkup(container, container.getClass(), enforceReload);
}
/**
Added: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupFragment.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupFragment.java?rev=815959&view=auto
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupFragment.java (added)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupFragment.java Wed Sep 16 20:48:23 2009
@@ -0,0 +1,254 @@
+/*
+ * 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;
+
+import org.apache.wicket.util.string.AppendingStringBuffer;
+
+/**
+ * Represents a portion of a markup file, but always spans a complete tag. E.g.
+ *
+ * <pre>
+ * open-body-close: <span>body</span>
+ * open-close: <span/>
+ * open-no-close: <input ...>body
+ * </pre>
+ *
+ * @see Markup
+ * @see MarkupElement
+ *
+ * @author Juergen Donnerstag
+ */
+public class MarkupFragment implements IMarkupFragment
+{
+ /** The parent markup. Must not be null. */
+ private final IMarkupFragment markup;
+
+ /** The index at which the fragment starts, relative to the parent markup */
+ private final int startIndex;
+
+ /** The size of the fragment (usually from open to close tag) */
+ private final int size;
+
+ /** the component id of the start tag */
+ private final String rootPath;
+
+ /**
+ * Construct.
+ *
+ * @param markup
+ * The parent markup. May not be null.
+ * @param startIndex
+ * The start index of the child markup
+ * @throws IndexOutOfBoundsException
+ * if the index is out of range (<tt>index < 0 || index >= size()</tt>)
+ */
+ public MarkupFragment(final IMarkupFragment markup, final int startIndex)
+ {
+ if (markup == null)
+ {
+ throw new IllegalArgumentException("Parameter 'markup' must not be null");
+ }
+
+ if (startIndex < 0)
+ {
+ throw new IllegalArgumentException("Parameter 'startIndex' must not be < 0");
+ }
+
+ if (startIndex >= markup.size())
+ {
+ throw new IllegalArgumentException(
+ "Parameter 'startIndex' must not be >= markup.size()");
+ }
+
+ this.markup = markup;
+ this.startIndex = startIndex;
+
+ // Make sure we are at an open tag
+ MarkupElement startElem = markup.get(startIndex);
+ if ((startElem instanceof ComponentTag) == false)
+ {
+ throw new IllegalArgumentException(
+ "Parameter 'index' does not point to a Wicket open tag");
+ }
+
+ // Determine the size. Find the close tag
+ int endIndex;
+ ComponentTag startTag = (ComponentTag)startElem;
+ if (startTag.isOpenClose())
+ {
+ endIndex = startIndex;
+ }
+ else if (startTag.hasNoCloseTag())
+ {
+ for (endIndex = startIndex + 1; endIndex < markup.size(); endIndex++)
+ {
+ MarkupElement elem = markup.get(endIndex);
+ if (elem instanceof ComponentTag)
+ {
+ endIndex--;
+ break;
+ }
+ }
+ }
+ else
+ {
+ for (endIndex = startIndex + 1; endIndex < markup.size(); endIndex++)
+ {
+ MarkupElement elem = markup.get(endIndex);
+ if (elem instanceof ComponentTag)
+ {
+ ComponentTag tag = (ComponentTag)elem;
+ if (tag.closes(startTag))
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ if (endIndex >= markup.size())
+ {
+ throw new MarkupException("Unable to find close tag for: '" + startTag.toString() +
+ "' in " + getRootMarkup().getMarkupResourceStream().toString());
+ }
+
+ size = endIndex - startIndex + 1;
+
+ // @TODO Setting the rootPath depending on specific tags is really ugly, since there is
+ // no way for user to enhance it in case he creates its own wicket tag. It probably can
+ // be removed once we switch to the markup resolution process.
+ if (startTag instanceof WicketTag)
+ {
+ WicketTag tag = (WicketTag)startTag;
+ if (tag.isFragementTag() || tag.isContainerTag())
+ {
+ rootPath = startTag.getId();
+ }
+ else
+ {
+ rootPath = null;
+ }
+ }
+ else
+ {
+ rootPath = startTag.getId();
+ }
+ }
+
+ /**
+ * @see org.apache.wicket.markup.IMarkupFragment#get(int)
+ */
+ public final MarkupElement get(final int index)
+ {
+ if ((index < 0) || (index > size))
+ {
+ throw new IndexOutOfBoundsException("Parameter 'index' is out of range: 0 <= " + index +
+ " <= " + size);
+ }
+
+ // Ask the parent markup
+ return markup.get(startIndex + index);
+ }
+
+ /**
+ * @see org.apache.wicket.markup.IMarkupFragment#findComponentIndex(java.lang.String,
+ * java.lang.String)
+ */
+ public final int findComponentIndex(String path, final String id, final int startIndex)
+ {
+ // Prepend rootPath to the 'path' parameter
+ path = (path == null ? rootPath : (rootPath == null ? path : rootPath + ":" + path));
+
+ // Search the markup
+ int index = markup.findComponentIndex(path, id, this.startIndex + startIndex) -
+ this.startIndex;
+
+ if ((index >= 0) && (index < size))
+ {
+ return index;
+ }
+
+ return -1;
+ }
+
+ /**
+ * @see org.apache.wicket.markup.IMarkupFragment#find(java.lang.String, java.lang.String, int)
+ */
+ public final IMarkupFragment find(final String path, final String id, final int startIndex)
+ {
+ int index = findComponentIndex(path, id, startIndex);
+ if (index >= 0)
+ {
+ return new MarkupFragment(this, index);
+ }
+ return null;
+ }
+
+ /**
+ * @see org.apache.wicket.markup.IMarkupFragment#getMarkupResourceStream()
+ */
+ public final MarkupResourceStream getMarkupResourceStream()
+ {
+ return markup.getMarkupResourceStream();
+ }
+
+ /**
+ * @see org.apache.wicket.markup.IMarkupFragment#size()
+ */
+ public final int size()
+ {
+ return size;
+ }
+
+ /**
+ * @return The parent markup. Null if that is a a markup file.
+ */
+ public final IMarkupFragment getParentMarkup()
+ {
+ return markup;
+ }
+
+ /**
+ * @return The Markup representing the underlying markup file with all its content
+ */
+ public final Markup getRootMarkup()
+ {
+ IMarkupFragment markup = getParentMarkup();
+ while ((markup != null) && ((markup instanceof Markup) == false))
+ {
+ markup = ((MarkupFragment)markup).getParentMarkup();
+ }
+ return (Markup)markup;
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ final AppendingStringBuffer buf = new AppendingStringBuffer(400);
+ buf.append(getRootMarkup().getMarkupResourceStream().toString());
+ buf.append("\n");
+
+ for (int i = 0; i < size(); i++)
+ {
+ buf.append(get(i));
+ }
+ return buf.toString();
+ }
+}
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupParser.java Wed Sep 16 20:48:23 2009
@@ -32,6 +32,7 @@
import org.apache.wicket.markup.parser.filter.HtmlHeaderSectionHandler;
import org.apache.wicket.markup.parser.filter.OpenCloseTagExpander;
import org.apache.wicket.markup.parser.filter.RelativePathPrefixHandler;
+import org.apache.wicket.markup.parser.filter.RootMarkupFilter;
import org.apache.wicket.markup.parser.filter.WicketLinkTagHandler;
import org.apache.wicket.markup.parser.filter.WicketMessageTagHandler;
import org.apache.wicket.markup.parser.filter.WicketNamespaceHandler;
@@ -115,10 +116,7 @@
this.xmlParser = xmlParser;
markupSettings = Application.get().getMarkupSettings();
- MarkupResourceData markup = new MarkupResourceData();
- markup.setResource(resource);
-
- this.markup = new Markup(markup);
+ markup = new Markup(resource);
// Initialize the markup filter chain
initializeMarkupFilters();
@@ -132,7 +130,7 @@
*/
public final void setWicketNamespace(final String namespace)
{
- markup.getMarkupResourceData().setWicketNamespace(namespace);
+ markup.getMarkupResourceStream().setWicketNamespace(namespace);
}
/**
@@ -143,7 +141,7 @@
*/
protected MarkupResourceStream getMarkupResourceStream()
{
- return markup.getMarkupResourceData().getResource();
+ return markup.getMarkupResourceStream();
}
/**
@@ -152,21 +150,20 @@
private final void initializeMarkupFilters()
{
// Chain together all the different markup filters and configure them
- markupFilterChain = xmlParser;
+ markupFilterChain = new RootMarkupFilter(xmlParser);
- MarkupResourceData markupResourceData = markup.getMarkupResourceData();
+ MarkupResourceStream markupResourceStream = markup.getMarkupResourceStream();
- appendMarkupFilter(new WicketTagIdentifier(markupResourceData));
+ appendMarkupFilter(new WicketTagIdentifier(markupResourceStream));
appendMarkupFilter(new HtmlHandler());
appendMarkupFilter(new WicketRemoveTagHandler());
appendMarkupFilter(new WicketLinkTagHandler());
- appendMarkupFilter(new WicketNamespaceHandler(markupResourceData));
+ appendMarkupFilter(new WicketNamespaceHandler(markupResourceStream));
// Provided the wicket component requesting the markup is known ...
- final MarkupResourceStream resource = markupResourceData.getResource();
- if (resource != null)
+ if ((markupResourceStream != null) && (markupResourceStream.getResource() != null))
{
- final ContainerInfo containerInfo = resource.getContainerInfo();
+ final ContainerInfo containerInfo = markupResourceStream.getContainerInfo();
if (containerInfo != null)
{
appendMarkupFilter(new WicketMessageTagHandler());
@@ -246,31 +243,31 @@
*/
public final Markup parse() throws IOException, ResourceStreamNotFoundException
{
- MarkupResourceData markupResourceData = markup.getMarkupResourceData();
+ MarkupResourceStream markupResourceStream = markup.getMarkupResourceStream();
// Initialize the xml parser
- xmlParser.parse(markupResourceData.getResource().getInputStream(),
+ xmlParser.parse(markupResourceStream.getResource().getInputStream(),
markupSettings.getDefaultMarkupEncoding());
// parse the xml markup and tokenize it into wicket relevant markup
// elements
parseMarkup();
- markupResourceData.setEncoding(xmlParser.getEncoding());
- markupResourceData.setXmlDeclaration(xmlParser.getXmlDeclaration());
+ markupResourceStream.setEncoding(xmlParser.getEncoding());
+ markupResourceStream.setXmlDeclaration(xmlParser.getXmlDeclaration());
if (xmlParser.getXmlDeclaration() == null)
{
if (markupSettings.getThrowExceptionOnMissingXmlDeclaration())
{
- throw new MarkupException(markupResourceData.getResource(),
+ throw new MarkupException(markupResourceStream.getResource(),
"The markup file does not have a XML declaration prolog. "
+ ". E.g. <?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
}
else
{
log.debug("The markup file does not have a XML declaration prolog: " +
- markupResourceData.getResource() +
+ markupResourceStream.getResource() +
". It is more save to use it. E.g. <?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
}
}
@@ -284,21 +281,16 @@
* @return The next tag
* @throws ParseException
*/
- public ComponentTag getNextTag() throws ParseException
+ private ComponentTag getNextTag() throws ParseException
{
return (ComponentTag)markupFilterChain.nextTag();
}
/**
* Scans the given markup and extracts balancing tags.
- *
*/
private void parseMarkup()
{
- // Get relevant settings from the Application
- final boolean stripComments = markupSettings.getStripComments();
- final boolean compressWhitespace = markupSettings.getCompressWhitespace();
-
try
{
// always remember the latest index (size)
@@ -318,24 +310,14 @@
if (add || tag.isModified() || (markup.size() != size))
{
// Add text from last position to the current tag position
- final CharSequence text = xmlParser.getInputFromPositionMarker(tag.getPos());
+ CharSequence text = xmlParser.getInputFromPositionMarker(tag.getPos());
if (text.length() > 0)
{
- String rawMarkup = text.toString();
-
- if (stripComments)
- {
- rawMarkup = removeComment(rawMarkup);
- }
-
- if (compressWhitespace)
- {
- rawMarkup = compressWhitespace(rawMarkup);
- }
+ text = handleRawText(text.toString());
// Make sure you add it at the correct location.
// IMarkupFilters might have added elements as well.
- markup.addMarkupElement(size, new RawMarkup(rawMarkup));
+ markup.addMarkupElement(size, new RawMarkup(text));
}
xmlParser.setPositionMarker();
@@ -372,8 +354,8 @@
markup.addMarkupElement(new RawMarkup(text));
}
- markup.getMarkupResourceData().setEncoding(xmlParser.getEncoding());
- markup.getMarkupResourceData().setXmlDeclaration(xmlParser.getXmlDeclaration());
+ markup.getMarkupResourceStream().setEncoding(xmlParser.getEncoding());
+ markup.getMarkupResourceStream().setXmlDeclaration(xmlParser.getXmlDeclaration());
final MarkupStream markupStream = new MarkupStream(markup);
markupStream.setCurrentIndex(markup.size() - 1);
@@ -381,24 +363,14 @@
}
// Add tail?
- final CharSequence text = xmlParser.getInputFromPositionMarker(-1);
+ CharSequence text = xmlParser.getInputFromPositionMarker(-1);
if (text.length() > 0)
{
- String rawMarkup = text.toString();
-
- if (stripComments)
- {
- rawMarkup = removeComment(rawMarkup);
- }
-
- if (compressWhitespace)
- {
- rawMarkup = compressWhitespace(rawMarkup);
- }
+ text = handleRawText(text.toString());
// Make sure you add it at the correct location.
// IMarkupFilters might have added elements as well.
- markup.addMarkupElement(new RawMarkup(rawMarkup));
+ markup.addMarkupElement(new RawMarkup(text));
}
// Make all tags immutable and the list of elements unmodifiable
@@ -406,6 +378,30 @@
}
/**
+ *
+ * @param rawMarkup
+ * @return The modified raw markup
+ */
+ protected CharSequence handleRawText(String rawMarkup)
+ {
+ // Get relevant settings from the Application
+ final boolean stripComments = markupSettings.getStripComments();
+ final boolean compressWhitespace = markupSettings.getCompressWhitespace();
+
+ if (stripComments)
+ {
+ rawMarkup = removeComment(rawMarkup);
+ }
+
+ if (compressWhitespace)
+ {
+ rawMarkup = compressWhitespace(rawMarkup);
+ }
+
+ return rawMarkup;
+ }
+
+ /**
* Remove whitespace from the raw markup
*
* @param rawMarkup
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupResourceStream.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupResourceStream.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupResourceStream.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupResourceStream.java Wed Sep 16 20:48:23 2009
@@ -26,6 +26,8 @@
import org.apache.wicket.util.resource.IResourceStream;
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;
import org.apache.wicket.util.time.Time;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -37,12 +39,12 @@
{
private static final long serialVersionUID = 1846489965076612828L;
+ private static final Logger log = LoggerFactory.getLogger(MarkupResourceStream.class);
+
/** The associated markup resource stream */
private final IResourceStream resourceStream;
- /**
- * Container info like Class, locale and style which were used to locate the resource
- */
+ /** Container info like Class, locale and style which were used to locate the resource */
private final ContainerInfo containerInfo;
/**
@@ -54,6 +56,36 @@
/** The key used to cache the markup resource stream */
private String cacheKey;
+ /** In case of the inherited markup, this is the base markup */
+ private Markup baseMarkup;
+
+ /** If found in the markup, the <?xml ...?> string */
+ private String xmlDeclaration;
+
+ /** The encoding as found in <?xml ... encoding="" ?>. Null, else */
+ private String encoding;
+
+ /**
+ * Wicket namespace: <html
+ * xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd>
+ */
+ private String wicketNamespace;
+
+ /** == wicket namespace name + ":id" */
+ private String wicketId;
+
+ /**
+ * Construct. Private by purpose.
+ */
+ private MarkupResourceStream()
+ {
+ resourceStream = null;
+ markupClassName = null;
+ containerInfo = null;
+
+ setWicketNamespace(ComponentTag.DEFAULT_WICKET_NAMESPACE);
+ }
+
/**
* Construct.
*
@@ -61,14 +93,7 @@
*/
public MarkupResourceStream(final IResourceStream resourceStream)
{
- this.resourceStream = resourceStream;
- containerInfo = null;
- markupClassName = null;
-
- if (resourceStream == null)
- {
- throw new IllegalArgumentException("Parameter 'resourceStream' must not be null");
- }
+ this(resourceStream, null, null);
}
/**
@@ -89,6 +114,8 @@
{
throw new IllegalArgumentException("Parameter 'resourceStream' must not be null");
}
+
+ setWicketNamespace(ComponentTag.DEFAULT_WICKET_NAMESPACE);
}
/**
@@ -208,12 +235,143 @@
}
/**
+ * Gets the resource that contains this markup
+ *
+ * @return The resource where this markup came from
+ */
+ public IResourceStream getResource()
+ {
+ return resourceStream;
+ }
+
+ /**
+ * Return the XML declaration string, in case if found in the markup.
+ *
+ * @return Null, if not found.
+ */
+ public String getXmlDeclaration()
+ {
+ return xmlDeclaration;
+ }
+
+ /**
+ * Gets the markup encoding. A markup encoding may be specified in a markup file with an XML
+ * encoding specifier of the form <?xml ... encoding="..." ?>.
+ *
+ * @return Encoding, or null if not found.
+ */
+ public String getEncoding()
+ {
+ return encoding;
+ }
+
+ /**
+ * Get the wicket namespace valid for this specific markup
+ *
+ * @return wicket namespace
+ */
+ public String getWicketNamespace()
+ {
+ return wicketNamespace;
+ }
+
+ /**
+ *
+ * @return usually it is "wicket:id"
+ */
+ final public String getWicketId()
+ {
+ return wicketId;
+ }
+
+ /**
+ * Sets encoding.
+ *
+ * @param encoding
+ * encoding
+ */
+ final void setEncoding(final String encoding)
+ {
+ this.encoding = encoding;
+ }
+
+ /**
+ * Sets wicketNamespace.
+ *
+ * @param wicketNamespace
+ * wicketNamespace
+ */
+ public final void setWicketNamespace(final String wicketNamespace)
+ {
+ this.wicketNamespace = wicketNamespace;
+ wicketId = wicketNamespace + ":id";
+
+ if (!ComponentTag.DEFAULT_WICKET_NAMESPACE.equals(wicketNamespace))
+ {
+ log.info("You are using a non-standard component name: " + wicketNamespace);
+ }
+ }
+
+ /**
+ * Sets xmlDeclaration.
+ *
+ * @param xmlDeclaration
+ * xmlDeclaration
+ */
+ final void setXmlDeclaration(final String xmlDeclaration)
+ {
+ this.xmlDeclaration = xmlDeclaration;
+ }
+
+ /**
+ * Get the resource stream containing the base markup (markup inheritance)
+ *
+ * @return baseMarkupResource Null, if not base markup
+ */
+ public MarkupResourceStream getBaseMarkupResourceStream()
+ {
+ if (baseMarkup == null)
+ {
+ return null;
+ }
+ return baseMarkup.getMarkupResourceStream();
+ }
+
+ /**
+ * In case of markup inheritance, the base markup.
+ *
+ * @param baseMarkup
+ * The base markup
+ */
+ public void setBaseMarkup(Markup baseMarkup)
+ {
+ this.baseMarkup = baseMarkup;
+ }
+
+ /**
+ * In case of markup inheritance, the base markup resource.
+ *
+ * @return The base markup
+ */
+ public Markup getBaseMarkup()
+ {
+ return baseMarkup;
+ }
+
+ /**
*
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
- return resourceStream.toString();
+ if (resourceStream != null)
+ {
+ return resourceStream.toString();
+ }
+ else
+ {
+ return "(unknown resource)";
+ }
}
}
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupStream.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupStream.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupStream.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MarkupStream.java Wed Sep 16 20:48:23 2009
@@ -42,7 +42,7 @@
*
* @author Jonathan Locke
*/
-public final class MarkupStream
+public class MarkupStream
{
/** Element at currentIndex */
private MarkupElement current;
@@ -51,7 +51,7 @@
private int currentIndex = 0;
/** The markup element list */
- private final Markup markup;
+ private final IMarkupFragment markup;
/**
* Constructor
@@ -59,7 +59,7 @@
* @param markup
* List of markup elements
*/
- public MarkupStream(final Markup markup)
+ public MarkupStream(final IMarkupFragment markup)
{
this.markup = markup;
@@ -198,7 +198,7 @@
*/
public final int findComponentIndex(final String path, final String id)
{
- return markup.findComponentIndex(path, id);
+ return markup.findComponentIndex(path, id, 0);
}
/**
@@ -226,7 +226,7 @@
*/
public final Class<? extends Component> getContainerClass()
{
- return markup.getMarkupResourceData().getResource().getMarkupClass();
+ return markup.getMarkupResourceStream().getMarkupClass();
}
/**
@@ -245,7 +245,7 @@
*/
public final String getEncoding()
{
- return markup.getMarkupResourceData().getEncoding();
+ return markup.getMarkupResourceStream().getEncoding();
}
/**
@@ -253,7 +253,7 @@
*/
public IResourceStream getResource()
{
- return markup.getMarkupResourceData().getResource();
+ return markup.getMarkupResourceStream().getResource();
}
/**
@@ -278,7 +278,7 @@
*/
public final String getWicketNamespace()
{
- return markup.getMarkupResourceData().getWicketNamespace();
+ return markup.getMarkupResourceStream().getWicketNamespace();
}
/**
@@ -288,7 +288,7 @@
*/
public String getXmlDeclaration()
{
- return markup.getMarkupResourceData().getXmlDeclaration();
+ return markup.getMarkupResourceStream().getXmlDeclaration();
}
/**
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/MergedMarkup.java Wed Sep 16 20:48:23 2009
@@ -59,23 +59,16 @@
*/
public MergedMarkup(final Markup markup, final Markup baseMarkup, int extendIndex)
{
- super(new MarkupResourceData());
+ super(markup.getMarkupResourceStream());
- // Copy settings from derived markup
- getMarkupResourceData().setResource(markup.getMarkupResourceData().getResource());
- getMarkupResourceData().setXmlDeclaration(
- markup.getMarkupResourceData().getXmlDeclaration());
- getMarkupResourceData().setEncoding(markup.getMarkupResourceData().getEncoding());
- getMarkupResourceData().setWicketNamespace(
- markup.getMarkupResourceData().getWicketNamespace());
- getMarkupResourceData().setBaseMarkup(baseMarkup);
+ getMarkupResourceStream().setBaseMarkup(baseMarkup);
if (log.isDebugEnabled())
{
- String derivedResource = Strings.afterLast(markup.getMarkupResourceData()
+ String derivedResource = Strings.afterLast(markup.getMarkupResourceStream()
.getResource()
.toString(), '/');
- String baseResource = Strings.afterLast(baseMarkup.getMarkupResourceData()
+ String baseResource = Strings.afterLast(baseMarkup.getMarkupResourceStream()
.getResource()
.toString(), '/');
log.debug("Merge markup: derived markup: " + derivedResource + "; base markup: " +
@@ -102,8 +95,8 @@
* does, the location is unique to this combination (or vice versa) SEE WICKET-1507 (Jeremy
* Thomerson)
*/
- return getMarkupResourceData().getBaseMarkup().locationAsString() + ":" +
- getMarkupResourceData().getResource().locationAsString();
+ return getMarkupResourceStream().getBaseMarkup().locationAsString() + ":" +
+ getMarkupResourceStream().locationAsString();
}
/**
@@ -116,7 +109,8 @@
* @param extendIndex
* Index where <wicket:extend> has been found
*/
- private void merge(final Markup markup, final Markup baseMarkup, int extendIndex)
+ private void merge(final IMarkupFragment markup, final IMarkupFragment baseMarkup,
+ int extendIndex)
{
// True if either <wicket:head> or <head> has been processed
boolean wicketHeadProcessed = false;
@@ -143,12 +137,10 @@
// Make sure all tags of the base markup remember where they are
// from
- if ((baseMarkup.getMarkupResourceData().getResource() != null) &&
+ if ((baseMarkup.getMarkupResourceStream().getResource() != null) &&
(tag.getMarkupClass() == null))
{
- tag.setMarkupClass(baseMarkup.getMarkupResourceData()
- .getResource()
- .getMarkupClass());
+ tag.setMarkupClass(baseMarkup.getMarkupResourceStream().getMarkupClass());
}
if (element instanceof WicketTag)
@@ -159,9 +151,7 @@
// level inheritance make sure the child tag is not from one of
// the deeper levels
if (wtag.isChildTag() &&
- (tag.getMarkupClass() == baseMarkup.getMarkupResourceData()
- .getResource()
- .getMarkupClass()))
+ (tag.getMarkupClass() == baseMarkup.getMarkupResourceStream().getMarkupClass()))
{
if (wtag.isOpenClose())
{
@@ -169,8 +159,7 @@
childTag = wtag;
WicketTag childOpenTag = (WicketTag)wtag.mutable();
childOpenTag.getXmlTag().setType(XmlTag.OPEN);
- childOpenTag.setMarkupClass(baseMarkup.getMarkupResourceData()
- .getResource()
+ childOpenTag.setMarkupClass(baseMarkup.getMarkupResourceStream()
.getMarkupClass());
addMarkupElement(childOpenTag);
break;
@@ -283,9 +272,7 @@
if (tag.isChildTag() && tag.isClose())
{
// Ok, skipped the childs content
- tag.setMarkupClass(baseMarkup.getMarkupResourceData()
- .getResource()
- .getMarkupClass());
+ tag.setMarkupClass(baseMarkup.getMarkupResourceStream().getMarkupClass());
addMarkupElement(tag);
break;
}
@@ -317,9 +304,7 @@
// But first add </wicket:child>
WicketTag childCloseTag = (WicketTag)childTag.mutable();
childCloseTag.getXmlTag().setType(XmlTag.CLOSE);
- childCloseTag.setMarkupClass(baseMarkup.getMarkupResourceData()
- .getResource()
- .getMarkupClass());
+ childCloseTag.setMarkupClass(baseMarkup.getMarkupResourceStream().getMarkupClass());
addMarkupElement(childCloseTag);
}
@@ -331,12 +316,10 @@
// Make sure all tags of the base markup remember where they are
// from
if ((element instanceof ComponentTag) &&
- (baseMarkup.getMarkupResourceData().getResource() != null))
+ (baseMarkup.getMarkupResourceStream().getResource() != null))
{
ComponentTag tag = (ComponentTag)element;
- tag.setMarkupClass(baseMarkup.getMarkupResourceData()
- .getResource()
- .getMarkupClass());
+ tag.setMarkupClass(baseMarkup.getMarkupResourceStream().getMarkupClass());
}
}
@@ -344,9 +327,7 @@
// it must enclose ALL of the <wicket:head> tags.
// Note: HtmlHeaderSectionHandler does something similar, but because
// markup filters are not called for merged markup again, ...
- if (Page.class.isAssignableFrom(markup.getMarkupResourceData()
- .getResource()
- .getMarkupClass()))
+ if (Page.class.isAssignableFrom(markup.getMarkupResourceStream().getMarkupClass()))
{
// Find the position inside the markup for first <wicket:head>,
// last </wicket:head> and <head>
@@ -407,7 +388,7 @@
* @param markup
* @param extendIndex
*/
- private void copyWicketHead(final Markup markup, int extendIndex)
+ private void copyWicketHead(final IMarkupFragment markup, int extendIndex)
{
boolean copy = false;
for (int i = 0; i < extendIndex; i++)
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/WicketTag.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/WicketTag.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/WicketTag.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/WicketTag.java Wed Sep 16 20:48:23 2009
@@ -75,6 +75,14 @@
}
/**
+ * @return True, if tag name equals 'wicket:container'
+ */
+ public final boolean isContainerTag()
+ {
+ return "container".equalsIgnoreCase(getName());
+ }
+
+ /**
* @return True, if tag name equals 'wicket:link'
*/
public final boolean isLinkTag()
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/HeaderPartContainer.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/HeaderPartContainer.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/HeaderPartContainer.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/HeaderPartContainer.java Wed Sep 16 20:48:23 2009
@@ -19,6 +19,7 @@
import org.apache.wicket.Component;
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.IMarkupFragment;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.resolver.IComponentResolver;
@@ -90,4 +91,13 @@
{
super.setMarkupStream(markupStream);
}
+
+ /**
+ * @see org.apache.wicket.Component#getMarkup()
+ */
+ @Override
+ public IMarkupFragment getMarkup()
+ {
+ return container.getAssociatedMarkup().find(null, "_head", 0);
+ }
}
\ No newline at end of file
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java Wed Sep 16 20:48:23 2009
@@ -20,6 +20,10 @@
import org.apache.wicket.MarkupContainer;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.markup.ComponentTag;
+import org.apache.wicket.markup.IMarkupFragment;
+import org.apache.wicket.markup.MarkupElement;
+import org.apache.wicket.markup.MarkupException;
+import org.apache.wicket.markup.MarkupFragment;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.WicketTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
@@ -109,10 +113,8 @@
implements
IComponentResolver
{
- /**
- *
- */
private static final long serialVersionUID = 1L;
+
static final String BODY = "body";
static final String BORDER = "border";
@@ -387,6 +389,19 @@
return false;
}
+
+ /**
+ * @see org.apache.wicket.MarkupContainer#getMarkup(org.apache.wicket.Component)
+ */
+ @Override
+ public IMarkupFragment getMarkup(final Component child)
+ {
+ // Find the Border component
+ MarkupContainer parent = findParent(Border.class);
+
+ // Get the "calling" markup
+ return parent.getMarkup();
+ }
}
/**
@@ -408,4 +423,70 @@
}
return bodyVisible;
}
+
+ /**
+ * @see org.apache.wicket.MarkupContainer#getMarkup(org.apache.wicket.Component)
+ */
+ @Override
+ public IMarkupFragment getMarkup(final Component child)
+ {
+ if ((child != null) && ("_body".equals(child.getId()) == false))
+ {
+ // First check if markup can be found in between <span wicket:id="myborder">...</span>
+ IMarkupFragment markup = getMarkup();
+ if (markup == null)
+ {
+ return null;
+ }
+
+ markup = markup.find(null, child.getId(), 0);
+ if (markup != null)
+ {
+ return markup;
+ }
+ }
+
+ // Than check if markup can be found in between <wicket:border>...</wicket:border>
+ IMarkupFragment markup = getAssociatedMarkup();
+ if (markup == null)
+ {
+ throw new MarkupException("Unable to find associated markup file for Border: " +
+ this.toString());
+ }
+
+ // Find <wicket:border>
+ int i;
+ for (i = 0; i < markup.size(); i++)
+ {
+ MarkupElement elem = markup.get(i);
+ if (elem instanceof WicketTag)
+ {
+ WicketTag tag = (WicketTag)elem;
+ if (tag.isBorderTag())
+ {
+ break;
+ }
+ }
+ }
+
+ // If child == null, return the markup fragment starting with the <wicket:border> tag
+ if (child == null)
+ {
+ return new MarkupFragment(markup, i);
+ }
+ else if ("_body".equals(child.getId()))
+ {
+ // Find <wicket:body>
+ int index = markup.findComponentIndex(null, child.getId(), i);
+ if (index == -1)
+ {
+ throw new MarkupException("Unable to find <wicket:body> tag. Border: " +
+ this.toString() + ". Associated Markup: " + markup.toString());
+ }
+ return new MarkupFragment(markup, index);
+ }
+
+ // Find the markup for the child component
+ return markup.find(null, child.getId(), i);
+ }
}
Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java?rev=815959&r1=815958&r2=815959&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java Wed Sep 16 20:48:23 2009
@@ -27,7 +27,7 @@
import org.apache.wicket.Session;
import org.apache.wicket.WicketRuntimeException;
import org.apache.wicket.markup.ContainerInfo;
-import org.apache.wicket.markup.Markup;
+import org.apache.wicket.markup.IMarkupFragment;
import org.apache.wicket.markup.MarkupElement;
import org.apache.wicket.markup.MarkupResourceStream;
import org.apache.wicket.markup.MarkupStream;
@@ -219,7 +219,7 @@
try
{
- Markup markup = Application.get()
+ IMarkupFragment markup = Application.get()
.getMarkupSettings()
.getMarkupParserFactory()
.newMarkupParser(markupResourceStream)