You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2007/04/09 04:01:49 UTC
svn commit: r526631 -
/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Component.java
Author: ehillenius
Date: Sun Apr 8 19:01:49 2007
New Revision: 526631
URL: http://svn.apache.org/viewvc?view=rev&rev=526631
Log:
better exception message
Modified:
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Component.java
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Component.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Component.java?view=diff&rev=526631&r1=526630&r2=526631
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Component.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/wicket/Component.java Sun Apr 8 19:01:49 2007
@@ -880,8 +880,7 @@
* such as javascript or an xslt transform.
* <p>
* Note: This method should only be called after the component or its parent
- * have been added to the page. This will be relaxed in 2.0 where the page
- * is available on construction.
+ * have been added to the page.
*
* @return markup id of the component
*/
@@ -890,7 +889,15 @@
String markupId = (String)getMetaData(MARKUP_ID_KEY);
if (markupId == null)
{
- markupId = getId() + getPage().getAutoIndex();
+ Page page = findPage();
+ if (page == null)
+ {
+ throw new WicketRuntimeException(
+ "This component is not (yet) coupled to a page. It has to be able "
+ + "to find the page it is supposed to operate in before you can call "
+ + "this method (Component#getMarkupId)");
+ }
+ markupId = getId() + page.getAutoIndex();
setMetaData(MARKUP_ID_KEY, markupId);
}
return markupId;
@@ -2562,8 +2569,9 @@
for (Component current = getParent(); current != null; current = current.getParent())
{
// Get model
- // Dont call the getModel() that could initialize many inbetween completely useless models.
- //IModel model = current.getModel();
+ // Dont call the getModel() that could initialize many inbetween
+ // completely useless models.
+ // IModel model = current.getModel();
IModel model = current.model;
if (model instanceof IWrapModel)
@@ -2769,12 +2777,12 @@
// always detach children because components can be attached
// independently of their parents
detachChildren();
-
+
// reset the model to null when the current model is a IWrapModel and
// the model that created it/wrapped in it is a IComponentInheritedModel
// The model will be created next time.
- if (model instanceof IWrapModel &&
- ((IWrapModel)model).getWrappedModel() instanceof IComponentInheritedModel)
+ if (model instanceof IWrapModel
+ && ((IWrapModel)model).getWrappedModel() instanceof IComponentInheritedModel)
{
model = null;
}
@@ -3124,12 +3132,13 @@
{
setFlag(FLAG_AUTO, auto);
}
-
+
/**
- * @param model The model to wrap if need be
+ * @param model
+ * The model to wrap if need be
* @return The wrapped model
*/
- protected final IModel wrap(final IModel model)
+ protected final IModel wrap(final IModel model)
{
if (model instanceof IComponentAssignedModel)
{
@@ -3185,8 +3194,8 @@
}
/**
- * Finds the innermost IModel object for an IModel that might contain
- * nested IModel(s).
+ * Finds the innermost IModel object for an IModel that might contain nested
+ * IModel(s).
*
* @param model
* The model