You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2007/04/14 09:05:17 UTC
svn commit: r528774 - in
/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket:
Component.java markup/ComponentTag.java markup/WicketTag.java
markup/parser/XmlTag.java
Author: ivaynberg
Date: Sat Apr 14 00:05:16 2007
New Revision: 528774
URL: http://svn.apache.org/viewvc?view=rev&rev=528774
Log:
allow the creation of wickettag based on componenttag, this is tied with WICKET-460 and [Wicket-user] Multi page inheritance thread
Modified:
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/WicketTag.java
incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/parser/XmlTag.java
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java?view=diff&rev=528774&r1=528773&r2=528774
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java Sat Apr 14 00:05:16 2007
@@ -958,7 +958,7 @@
*
* @return The model
*/
- public IModel getModel()
+ public final IModel getModel()
{
// If model is null
if (model == null)
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java?view=diff&rev=528774&r1=528773&r2=528774
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/ComponentTag.java Sat Apr 14 00:05:16 2007
@@ -394,16 +394,28 @@
else
{
final ComponentTag tag = new ComponentTag(xmlTag.mutable());
- tag.id = id;
- tag.setMarkupClass(this.markupClass);
- tag.setHasNoCloseTag(this.hasNoCloseTag);
- tag.setPath(this.path);
- if (behaviors != null)
- {
- tag.behaviors = new ArrayList(behaviors.size());
- tag.behaviors.addAll(behaviors);
- }
+ copyPropertiesTo(tag);
return tag;
+ }
+ }
+
+ /**
+ * Copies all internal properties from this tag to <code>dest</code>.
+ * This is basically cloning without instance creation.
+ *
+ * @param dest
+ * tag whose properties will be set
+ */
+ void copyPropertiesTo(ComponentTag dest)
+ {
+ dest.id = id;
+ dest.setMarkupClass(this.markupClass);
+ dest.setHasNoCloseTag(this.hasNoCloseTag);
+ dest.setPath(this.path);
+ if (behaviors != null)
+ {
+ dest.behaviors = new ArrayList(behaviors.size());
+ dest.behaviors.addAll(behaviors);
}
}
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/WicketTag.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/WicketTag.java?view=diff&rev=528774&r1=528773&r2=528774
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/WicketTag.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/WicketTag.java Sat Apr 14 00:05:16 2007
@@ -37,12 +37,25 @@
* Constructor
*
* @param tag
- * The XML tag which this component tag is based upon.
+ * The XML tag which this wicket tag is based upon.
*/
public WicketTag(final XmlTag tag)
{
super(tag);
}
+
+ /**
+ * Constructor
+ *
+ * @param tag
+ * The ComponentTag tag which this wicket tag is based upon.
+ */
+ public WicketTag(final ComponentTag tag)
+ {
+ super(tag.getXmlTag());
+ tag.copyPropertiesTo(this);
+ }
+
/**
* Get the tag's name attribute: e.g. <wicket:region name=panel>
Modified: incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/parser/XmlTag.java
URL: http://svn.apache.org/viewvc/incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/parser/XmlTag.java?view=diff&rev=528774&r1=528773&r2=528774
==============================================================================
--- incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/parser/XmlTag.java (original)
+++ incubator/wicket/branches/wicket-1.x/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/parser/XmlTag.java Sat Apr 14 00:05:16 2007
@@ -39,7 +39,7 @@
{
/** A close tag, like </TAG>. */
public static final Type CLOSE = new Type("CLOSE");
-
+
/** An open tag, like <TAG componentId = "xyz">. */
public static final Type OPEN = new Type("OPEN");
@@ -91,11 +91,12 @@
public static final class Type extends EnumeratedType
{
private static final long serialVersionUID = 1L;
+
/**
* Construct.
*
* @param name
- * name of type
+ * name of type
*/
Type(final String name)
{
@@ -115,7 +116,7 @@
* Gets whether this tag closes the provided open tag.
*
* @param open
- * The open tag
+ * The open tag
* @return True if this tag closes the given open tag
*/
public final boolean closes(final XmlTag open)
@@ -147,7 +148,7 @@
}
return false;
}
-
+
/**
* Gets a hashmap of this tag's attributes.
*
@@ -157,7 +158,7 @@
{
if (attributes == null)
{
- if ((copyOf == this) || (copyOf == null) || (copyOf.attributes == null))
+ if ((copyOf == this) || (copyOf == null) || (copyOf.attributes == null))
{
attributes = new ValueMap();
}
@@ -176,7 +177,7 @@
{
return attributes != null && attributes.size() > 0;
}
-
+
/**
* Get the column number.
*
@@ -262,7 +263,7 @@
* Get a string attribute.
*
* @param key
- * The key
+ * The key
* @return The string value
*/
public CharSequence getString(final String key)
@@ -331,20 +332,20 @@
{
return false;
}
-
+
if ((getNamespace() == null) && (tag.getNamespace() == null))
{
return true;
}
-
+
if ((getNamespace() != null) && (tag.getNamespace() != null))
{
return getNamespace().equalsIgnoreCase(tag.getNamespace());
}
-
+
return false;
}
-
+
/**
* Makes this tag object immutable by making the attribute map unmodifiable.
* Immutable tags cannot be made mutable again. They can only be copied into
@@ -368,7 +369,7 @@
* it is immutable.
*
* @return This tag if it is already mutable, or a mutable copy of this tag
- * if it is immutable.
+ * if it is immutable.
*/
public XmlTag mutable()
{
@@ -379,31 +380,42 @@
else
{
final XmlTag tag = new XmlTag();
-
- tag.namespace = namespace;
- tag.name = name;
- tag.pos = pos;
- tag.length = length;
- tag.text = text;
- tag.type = type;
- tag.isMutable = true;
- tag.closes = closes;
- tag.copyOf = copyOf;
- if (attributes != null)
- {
- tag.attributes = new ValueMap(attributes);
- }
+ copyPropertiesTo(tag);
return tag;
}
}
/**
+ * Copies all internal properties from this tag to <code>dest</code>.
+ * This is basically cloning without instance creation.
+ *
+ * @param dest
+ * tag whose properties will be set
+ */
+ void copyPropertiesTo(XmlTag dest)
+ {
+ dest.namespace = namespace;
+ dest.name = name;
+ dest.pos = pos;
+ dest.length = length;
+ dest.text = text;
+ dest.type = type;
+ dest.isMutable = true;
+ dest.closes = closes;
+ dest.copyOf = copyOf;
+ if (attributes != null)
+ {
+ dest.attributes = new ValueMap(attributes);
+ }
+ }
+
+ /**
* Puts a boolean attribute.
*
* @param key
- * The key
+ * The key
* @param value
- * The value
+ * The value
* @return previous value associated with specified key, or null if there
* was no mapping for key. A null return can also indicate that the
* map previously associated null with the specified key, if the
@@ -418,9 +430,9 @@
* Puts an int attribute.
*
* @param key
- * The key
+ * The key
* @param value
- * The value
+ * The value
* @return previous value associated with specified key, or null if there
* was no mapping for key. A null return can also indicate that the
* map previously associated null with the specified key, if the
@@ -435,9 +447,9 @@
* Puts a string attribute.
*
* @param key
- * The key
+ * The key
* @param value
- * The value
+ * The value
* @return previous value associated with specified key, or null if there
* was no mapping for key. A null return can also indicate that the
* map previously associated null with the specified key, if the
@@ -452,9 +464,9 @@
* Puts a {@link StringValue}attribute.
*
* @param key
- * The key
+ * The key
* @param value
- * The value
+ * The value
* @return previous value associated with specified key, or null if there
* was no mapping for key. A null return can also indicate that the
* map previously associated null with the specified key, if the
@@ -469,11 +481,11 @@
* Puts all attributes in map
*
* @param map
- * A key/value map
+ * A key/value map
*/
public void putAll(final Map map)
{
- for (final Iterator iterator = map.keySet().iterator(); iterator.hasNext(); )
+ for (final Iterator iterator = map.keySet().iterator(); iterator.hasNext();)
{
final String key = (String)iterator.next();
Object value = map.get(key);
@@ -485,7 +497,7 @@
* Removes an attribute.
*
* @param key
- * The key to remove
+ * The key to remove
*/
public void remove(final String key)
{
@@ -496,7 +508,7 @@
* Sets the tag name.
*
* @param name
- * New tag name
+ * New tag name
*/
public void setName(final String name)
{
@@ -515,7 +527,7 @@
* Sets the tag namespace.
*
* @param namespace
- * New tag name
+ * New tag name
*/
public void setNamespace(final String namespace)
{
@@ -534,9 +546,9 @@
* Assuming this is a close tag, assign it's corresponding open tag.
*
* @param tag
- * the open-tag
+ * the open-tag
* @throws RuntimeException
- * if 'this' is not a close tag
+ * if 'this' is not a close tag
*/
public void setOpenTag(final XmlTag tag)
{
@@ -547,7 +559,7 @@
* Sets type of this tag if it is not immutable.
*
* @param type
- * The new type
+ * The new type
*/
public void setType(final Type type)
{
@@ -581,7 +593,7 @@
{
return toCharSequence().toString();
}
-
+
/**
* @see org.apache.wicket.markup.MarkupElement#toCharSequence()
*/
@@ -609,7 +621,7 @@
* Assuming some attributes have been changed, toXmlString() rebuilds the
* String on based on the tags informations.
*
- * @param attributeToBeIgnored
+ * @param attributeToBeIgnored
* @return A xml string matching the tag
*/
public CharSequence toXmlString(final String attributeToBeIgnored)
@@ -645,12 +657,12 @@
buffer.append(" ");
buffer.append(key);
CharSequence value = getString(key);
-
+
// Attributes without values are possible, e.g. 'disabled'
- if (value != null)
+ if (value != null)
{
buffer.append("=\"");
- value = Strings.replaceAll(value,"\"", "\\\"");
+ value = Strings.replaceAll(value, "\"", "\\\"");
buffer.append(value);
buffer.append("\"");
}