Author: ivaynberg
Date: Tue Dec 12 09:08:56 2006
New Revision: 486238
URL: http://svn.apache.org/viewvc?view=rev&rev=486238
Log:
bring back the ability to use manually defined markup ids
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/Component.java
Modified: incubator/wicket/trunk/wicket/src/main/java/wicket/Component.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/Component.java?view=diff&rev=486238&r1=486237&r2=486238
==============================================================================
--- incubator/wicket/trunk/wicket/src/main/java/wicket/Component.java (original)
+++ incubator/wicket/trunk/wicket/src/main/java/wicket/Component.java Tue Dec
12 09:08:56 2006
@@ -1061,25 +1061,28 @@
}
/**
- * Retrieves id by which this component is represented within the
markup.
+ * Retrieves id by which this component can be identified within the
markup.
* <p>
- * The point of this function is to generate a unique id to make it
easy to
- * locate this component in the generated markup for post-wicket
processing
- * 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.
+ * If an id attribute is defined in the markup or set in the markup
+ * attributes ([EMAIL PROTECTED] #getMarkupAttributes()} it will be
used, otherwise an
+ * autogenerated id will be assigned.
*
* @return markup id of the component
*/
public String getMarkupId()
{
- String markupId = getMetaData(MARKUP_ID_KEY);
- if (markupId == null)
+ // first try a manually set id
+ String markupId =
getMarkupAttributes().getString(MARKUP_ID_ATTR_NAME);
+ if (id == null)
{
- markupId = getId() + getPage().getAutoIndex();
- setMetaData(MARKUP_ID_KEY, markupId);
+ // then check the metadata
+ markupId = getMetaData(MARKUP_ID_KEY);
+ if (markupId == null)
+ {
+ // if the metadata is empty, generate one and
store it there
+ markupId = getId() + getPage().getAutoIndex();
+ setMetaData(MARKUP_ID_KEY, markupId);
+ }
}
return markupId;
}