You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by kn...@apache.org on 2008/11/16 23:04:29 UTC
svn commit: r718123 [2/10] - in /wicket/sandbox/knopp/experimental/wicket:
./ .settings/ src/main/java/org/apache/wicket/
src/main/java/org/apache/wicket/ajax/
src/main/java/org/apache/wicket/ajax/form/
src/main/java/org/apache/wicket/ajax/markup/html/...
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/AttributeModifier.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/AttributeModifier.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/AttributeModifier.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/AttributeModifier.java Sun Nov 16 14:04:19 2008
@@ -366,14 +366,14 @@
* gets replacement with null check.
*
* @param component
- * @return
+ * @return replacement value
*/
private Object getReplacementOrNull(final Component component)
{
IModel<?> model = replaceModel;
if (model instanceof IComponentAssignedModel)
{
- model = ((IComponentAssignedModel)model).wrapOnAssignment(component);
+ model = ((IComponentAssignedModel<?>)model).wrapOnAssignment(component);
}
return (model != null) ? model.getObject() : null;
}
@@ -382,7 +382,7 @@
* gets replacement as a string with null check.
*
* @param replacementValue
- * @return
+ * @return replacement value as a string
*/
private String toStringOrNull(final Object replacementValue)
{
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Component.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Component.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Component.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Component.java Sun Nov 16 14:04:19 2008
@@ -83,10 +83,10 @@
* <li><b>Construction </b>- A Component is constructed with the Java language new operator.
* Children may be added during construction if the Component is a MarkupContainer.
*
- * <li><b>Request Handling </b>- An incoming request is processed by a protocol request handler
- * such as WicketServlet. An associated Application object creates Session, Request and Response
- * objects for use by a given Component in updating its model and rendering a response. These
- * objects are stored inside a container called {@link RequestCycle} which is accessible via
+ * <li><b>Request Handling </b>- An incoming request is processed by a protocol request handler such
+ * as WicketServlet. An associated Application object creates Session, Request and Response objects
+ * for use by a given Component in updating its model and rendering a response. These objects are
+ * stored inside a container called {@link RequestCycle} which is accessible via
* {@link Component#getRequestCycle()}. The convenience methods {@link Component#getRequest()},
* {@link Component#getResponse()} and {@link Component#getSession()} provide easy access to the
* contents of this container.
@@ -124,8 +124,8 @@
* <li><b>Component Models </b>- The primary responsibility of a component is to use its model (an
* object that implements IModel), which can be set via
* {@link Component#setDefaultModel(IModel model)} and retrieved via
- * {@link Component#getDefaultModel()}, to render a response in an appropriate markup language,
- * such as HTML. In addition, form components know how to update their models based on request
+ * {@link Component#getDefaultModel()}, to render a response in an appropriate markup language, such
+ * as HTML. In addition, form components know how to update their models based on request
* information. Since the IModel interface is a wrapper around an actual model object, a convenience
* method {@link Component#getDefaultModelObject()} is provided to retrieve the model Object from
* its IModel wrapper. A further convenience method,
@@ -136,10 +136,9 @@
* isVisible() and will not render a response (nor will their children).
*
* <li><b>Page </b>- The Page containing any given Component can be retrieved by calling
- * {@link Component#getPage()}. If the Component is not attached to a Page, an
- * IllegalStateException will be thrown. An equivalent method, {@link Component#findPage()} is
- * available for special circumstances where it might be desirable to get a null reference back
- * instead.
+ * {@link Component#getPage()}. If the Component is not attached to a Page, an IllegalStateException
+ * will be thrown. An equivalent method, {@link Component#findPage()} is available for special
+ * circumstances where it might be desirable to get a null reference back instead.
*
* <li><b>Session </b>- The Page for a Component points back to the Session that contains the Page.
* The Session for a component can be accessed with the convenience method getSession(), which
@@ -155,12 +154,12 @@
* Application Localizer for easy access in Components.
*
* <li><b>Style </b>- The style ("skin") for a component is available through
- * {@link Component#getStyle()}, which is equivalent to getSession().getStyle(). Styles are
- * intended to give a particular look to a Component or Resource that is independent of its Locale.
- * For example, a style might be a set of resources, including images and markup files, which gives
- * the design look of "ocean" to the user. If the Session's style is set to "ocean" and these
- * resources are given names suffixed with "_ocean", Wicket's resource management logic will prefer
- * these resources to other resources, such as default resources, which are not as good of a match.
+ * {@link Component#getStyle()}, which is equivalent to getSession().getStyle(). Styles are intended
+ * to give a particular look to a Component or Resource that is independent of its Locale. For
+ * example, a style might be a set of resources, including images and markup files, which gives the
+ * design look of "ocean" to the user. If the Session's style is set to "ocean" and these resources
+ * are given names suffixed with "_ocean", Wicket's resource management logic will prefer these
+ * resources to other resources, such as default resources, which are not as good of a match.
*
* <li><b>Variation </b>- Whereas Styles are Session (user) specific, variations are component
* specific. E.g. if the Style is "ocean" and the Variation is "NorthSea", than the resources are
@@ -191,8 +190,8 @@
* {@link Component#setVersioned(boolean)} method. The versioning participation of a given Component
* can be retrieved with {@link Component#isVersioned()}.
*
- * <li><b>AJAX support</b>- Components can be re-rendered after the whole Page has been rendered
- * at least once by calling doRender().
+ * <li><b>AJAX support</b>- Components can be re-rendered after the whole Page has been rendered at
+ * least once by calling doRender().
*
* @author Jonathan Locke
* @author Chris Turner
@@ -501,8 +500,8 @@
* <li>The other use is when a component should block the rendering of the whole page. So
* instead of 'hiding' a component, what we generally want to achieve here is that we force the
* user to logon/give-credentials for a higher level of authorization. For this functionality,
- * the strategy implementation should throw a {@link AuthorizationException}, which will then
- * be handled further by the framework.</li>
+ * the strategy implementation should throw a {@link AuthorizationException}, which will then be
+ * handled further by the framework.</li>
* </ul>
* </p>
*/
@@ -707,8 +706,8 @@
* <ul>
* <li>Model (indicated by {@link #FLAG_MODEL_SET})
* <li>MetaDataEntry (optionally {@link MetaDataEntry}[] if more metadata entries are present) *
- * <li>{@link IBehavior}(s) added to component. The behaviors are not stored in separate
- * array, they are part of the {@link #data} array
+ * <li>{@link IBehavior}(s) added to component. The behaviors are not stored in separate array,
+ * they are part of the {@link #data} array
* </ul>
* If there is only one attribute set (i.e. model or MetaDataEntry([]) or one behavior), the
* #data object points directly to value of that attribute. Otherwise the data is of type
@@ -1049,11 +1048,12 @@
}
/**
- * We need to postpone calling beforeRender() on components that implement IFeedback, to be sure
- * that all other component's beforeRender() has been already called, so that IFeedbacks can
- * collect all feedback messages. This is the key under list of postponed IFeedback is stored to
- * request cycle metadata. The List is then iterated over in {@link #prepareForRender()} after
- * calling {@link #beforeRender()}, to initialize postponed components.
+ * We need to postpone calling beforeRender() on components that implement {@link IFeedback}, to
+ * be sure that all other component's beforeRender() has been already called, so that IFeedbacks
+ * can collect all feedback messages. This is the key under list of postponed {@link IFeedback}
+ * is stored to request cycle metadata. The List is then iterated over in
+ * {@link #prepareForRender()} after calling {@link #beforeRender()}, to initialize postponed
+ * components.
*/
private static final MetaDataKey<List<Component>> FEEDBACK_LIST = new MetaDataKey<List<Component>>()
{
@@ -1143,6 +1143,9 @@
setModelImpl(null);
setFlag(FLAG_INHERITABLE_MODEL, false);
}
+
+ // clear out enabled state metadata
+ setMetaData(ENABLED_IN_HIERARCHY_CACHE_KEY, null);
}
/**
@@ -1310,7 +1313,7 @@
* @deprecated To be removed. Please use/ override {@link #getConverter(Class)} instead.
*/
@Deprecated
- public final IConverter<?> getConverter()
+ public final IConverter getConverter()
{
throw new UnsupportedOperationException("use #getConverter(Class) instead");
}
@@ -1323,7 +1326,7 @@
*
* @return The converter that should be used by this component
*/
- public <X> IConverter<X> getConverter(Class<X> type)
+ public IConverter getConverter(Class<?> type)
{
return getApplication().getConverterLocator().getConverter(type);
}
@@ -1440,9 +1443,9 @@
* attribute set explicitly via a call to {@link #setMarkupId(String)}, id attribute defined in
* the markup, or an automatically generated id - in that order.
* <p>
- * If no id is set and <code>createIfDoesNotExist</code> is false, this method will return
- * null. Otherwise it will generate an id value that will be unique in the page. This is the
- * preferred way as there is no chance of id collision.
+ * If no id is set and <code>createIfDoesNotExist</code> is false, this method will return null.
+ * Otherwise it will generate an id value that will be unique in the page. This is the preferred
+ * way as there is no chance of id collision.
* <p>
* Note: This method should only be called after the component or its parent have been added to
* the page.
@@ -1507,6 +1510,7 @@
markupId = Strings.replaceAll(markupId, "_", "__").toString();
markupId = markupId.replace('.', '_');
markupId = markupId.replace('-', '_');
+ markupId = markupId.replace(' ', '_');
return markupId;
}
@@ -1639,7 +1643,6 @@
* Model object to convert to string
* @return The string
*/
- @SuppressWarnings("unchecked")
public final String getDefaultModelObjectAsString(final Object modelObject)
{
if (modelObject != null)
@@ -1647,7 +1650,7 @@
// Get converter
final Class<?> objectClass = modelObject.getClass();
- final IConverter<Object> converter = (IConverter<Object>)getConverter(objectClass);
+ final IConverter converter = getConverter(objectClass);
// Model string from property
final String modelString = converter.convertToString(modelObject, getLocale());
@@ -1710,14 +1713,6 @@
}
/**
- * @return The page factory for the session that this component is in
- */
- public final IPageFactory getPageFactory()
- {
- return getSession().getPageFactory();
- }
-
- /**
* Gets the path to this component relative to the page it is in.
*
* @return The path to this component relative to the page it is in
@@ -2184,40 +2179,11 @@
}
/**
- * Creates a new page using the component's page factory
- *
- * @param <C>
- *
- * @param c
- * The class of page to create
- * @return The new page
- */
- public final <C extends Page> Page newPage(final Class<C> c)
- {
- return getPageFactory().newPage(c);
- }
-
- /**
- * Creates a new page using the component's page factory
- *
- * @param <C>
- *
- * @param c
- * The class of page to create
- * @param parameters
- * Any parameters to pass to the constructor
- * @return The new page
- */
- public final <C extends Page> Page newPage(final Class<C> c, final PageParameters parameters)
- {
- return getPageFactory().newPage(c, parameters);
- }
-
- /**
* THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT USE IT!
- *
+ * <p>
* Prepares the component and it's children for rendering. On whole page render this method must
* be called on the page. On AJAX request, this method must be called on updated component.
+ * </p>
*
* @param setRenderingFlag
* Whether to set the rendering flag. This must be true if the page is about to be
@@ -2388,7 +2354,7 @@
try
{
- // Call implementation to render component
+ // Call implementation to render component
final IComponentBorder border = getComponentBorder();
if (border != null)
{
@@ -2402,7 +2368,7 @@
border.renderAfter(this);
}
// Component has been rendered
- rendered();
+ rendered();
}
catch (RuntimeException ex)
{
@@ -2610,7 +2576,7 @@
* rendered, and in development mode this would result in a runtime exception.
*/
public final void rendered()
- {
+ {
// Tell the page that the component rendered
getPage().componentRendered(this);
}
@@ -2656,8 +2622,10 @@
/**
* Replaces this component with another. The replacing component must have the same component id
- * as this component. This method serves as a shortcut to <code>
- * this.getParent().replace(replacement)</code>
+ * as this component. This method serves as a shortcut to
+ *
+ * <code>this.getParent().replace(replacement)</code>
+ *
* and provides a better context for errors.
*
* @since 1.2.1
@@ -2791,6 +2759,7 @@
setMetaData(MARKUP_ID_KEY, null);
return;
}
+
generatedMarkupId = -1;
setMetaData(MARKUP_ID_KEY, (String)markupId);
}
@@ -2908,9 +2877,7 @@
}
/**
- *
- *
- * @return
+ * @return model
*/
IModel<?> getModelImpl()
{
@@ -3149,7 +3116,7 @@
@Override
public String toString()
{
- return toString(true);
+ return toString(false);
}
/**
@@ -3311,7 +3278,7 @@
final IVisitor<Component> visitor)
{
// Start here
- Component current = this;
+ Component current = getParent();
// Walk up containment hierarchy
while (current != null)
@@ -3779,8 +3746,8 @@
/**
* Called just before a component is rendered.
* <p>
- * *NOTE* If you override this, you *must* call super.onBeforeRender() within your
- * implementation.
+ * <strong>NOTE</strong>: If you override this, you *must* call super.onBeforeRender() within
+ * your implementation.
*
* Because this method is responsible for cascading {@link #onBeforeRender()} call to its
* children it is strongly recommended that super call is made at the end of the override.
@@ -3835,6 +3802,14 @@
{
tag.put(MARKUP_ID_ATTR_NAME, getMarkupId());
}
+
+ if (getApplication().getDebugSettings().isOutputComponentPath())
+ {
+ String path = getPageRelativePath();
+ path = path.replace("_", "__");
+ path = path.replace(":", "_");
+ tag.put("wicketpath", path);
+ }
}
/**
@@ -4128,7 +4103,8 @@
}
/**
- *
+ * @param setRenderingFlag
+ * rendering flag
*/
void internalMarkRendering(boolean setRenderingFlag)
{
@@ -4316,8 +4292,7 @@
* Determines whether or not a component should be visible, taking into account all the factors:
* {@link #isVisible()}, {@link #isVisibilityAllowed()}, {@link #isRenderAllowed()}
*
- * @return <code>true</code> if the component should be visible, <code>false</code>
- * otherwise
+ * @return <code>true</code> if the component should be visible, <code>false</code> otherwise
*/
public final boolean determineVisibility()
{
@@ -4358,4 +4333,44 @@
s.defaultReadObject();
}
}
+
+ /**
+ * Calculates enabled state of the component taking its hierarchy into account. A component is
+ * enabled iff it is itself enabled ({@link #isEnabled()} and {@link #isEnableAllowed()} both
+ * return <code>true</code>), and all of its parents are enabled.
+ *
+ * @return <code>true</code> if this component is enabled</code>
+ */
+ public final boolean isEnabledInHierarchy()
+ {
+ Boolean state = getMetaData(ENABLED_IN_HIERARCHY_CACHE_KEY);
+ if (state == null)
+ {
+ state = isEnabled() && isEnableAllowed();
+ if (state)
+ {
+ Component parent = getParent();
+ if (parent != null)
+ {
+ state = state && parent.isEnabledInHierarchy();
+ }
+ }
+ setMetaData(ENABLED_IN_HIERARCHY_CACHE_KEY, state);
+ }
+ return state;
+ }
+
+
+ /**
+ * Keeps metadata about the enabled state of the component
+ *
+ * The states are: null - not calculated, true and false
+ */
+ private static final MetaDataKey<Boolean> ENABLED_IN_HIERARCHY_CACHE_KEY = new MetaDataKey<Boolean>()
+ {
+ private static final long serialVersionUID = 1L;
+
+ };
+
+
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/IConverterLocator.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/IConverterLocator.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/IConverterLocator.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/IConverterLocator.java Sun Nov 16 14:04:19 2008
@@ -30,7 +30,7 @@
*
* @author jcompagner
*
- * The converter object type
+ * The converter object type
*/
public interface IConverterLocator extends IClusterable
{
@@ -38,11 +38,8 @@
/**
* Returns the Converter for the class that is given.
*
- * @param <T>
- * converter type
- *
* @param type
* @return The converter for the given type.
*/
- public <T> IConverter<T> getConverter(Class<T> type);
+ public IConverter getConverter(Class<?> type);
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Localizer.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Localizer.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Localizer.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Localizer.java Sun Nov 16 14:04:19 2008
@@ -60,6 +60,7 @@
/** Cache properties */
private Map<String, String> cache = newCache();
+ /** */
private final ClassMetaDatabase metaDatabase = new ClassMetaDatabase();
/**
@@ -130,8 +131,8 @@
* @throws MissingResourceException
* If resource not found and configuration dictates that exception should be thrown
*/
- public String getString(final String key, final Component component,
- final String defaultValue) throws MissingResourceException
+ public String getString(final String key, final Component component, final String defaultValue)
+ throws MissingResourceException
{
return getString(key, component, null, defaultValue);
}
@@ -257,8 +258,8 @@
if (resourceSettings.getThrowExceptionOnMissingResource())
{
- AppendingStringBuffer message = new AppendingStringBuffer("Unable to find resource: " +
- key);
+ AppendingStringBuffer message = new AppendingStringBuffer("Unable to find property: '" +
+ key + "'");
if (component != null)
{
message.append(" for component: ");
@@ -269,7 +270,7 @@
? component.getClass().getName() : ""), key);
}
- return "[Warning: String resource for '" + key + "' not found]";
+ return "[Warning: Property for '" + key + "' not found]";
}
/**
@@ -281,7 +282,9 @@
protected void putIntoCache(final String cacheKey, final String string)
{
if (cache == null)
+ {
return;
+ }
// ConcurrentHashMap does not allow null values
if (string == null)
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/MarkupContainer.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/MarkupContainer.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/MarkupContainer.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/MarkupContainer.java Sun Nov 16 14:04:19 2008
@@ -81,8 +81,6 @@
* @see MarkupStream
* @author Jonathan Locke
*
- * @param <T>
- * The model object type
*/
public abstract class MarkupContainer extends Component
{
@@ -648,10 +646,18 @@
renderComponentTag(associatedMarkupOpenTag);
associatedMarkupStream.next();
+ String className = null;
+
if (getApplication().getDebugSettings().isOutputMarkupContainerClassName())
{
+ Class<?> klass = getClass();
+ while (klass.isAnonymousClass())
+ {
+ klass = klass.getSuperclass();
+ }
+ className = klass.getName();
getResponse().write("<!-- MARKUP FOR ");
- getResponse().write(getClass().getName());
+ getResponse().write(className);
getResponse().write(" BEGIN -->");
}
@@ -660,7 +666,7 @@
if (getApplication().getDebugSettings().isOutputMarkupContainerClassName())
{
getResponse().write("<!-- MARKUP FOR ");
- getResponse().write(getClass().getName());
+ getResponse().write(className);
getResponse().write(" END -->");
}
@@ -789,7 +795,7 @@
{
final StringBuffer buffer = new StringBuffer();
buffer.append("[MarkupContainer ");
- buffer.append(super.toString(true));
+ buffer.append(super.toString(detailed));
if (detailed)
{
if (getMarkupStream() != null)
@@ -967,6 +973,18 @@
}
/**
+ * Returns child component at the specified index
+ *
+ * @param index
+ * @throws ArrayIndexOutOfBoundsException
+ * @return child component at the specified index
+ */
+ public final Component get(int index)
+ {
+ return children_get(index);
+ }
+
+ /**
*
* @param index
* @return The child component
@@ -1863,4 +1881,50 @@
}
}
}
+
+ /**
+ * Swaps position of children. This method is particularly useful for adjusting positions of
+ * repeater's items without rebuilding the component hierarchy
+ *
+ * @param idx1
+ * index of first component to be swapped
+ * @param idx2
+ * index of second component to be swapped
+ */
+ public final void swap(int idx1, int idx2)
+ {
+ int size = children_size();
+ if (idx1 < 0 || idx1 >= size)
+ {
+ throw new IndexOutOfBoundsException("Argument idx is out of bounds: " + idx1 + "<>[0," +
+ size + ")");
+ }
+
+ if (idx2 < 0 || idx2 >= size)
+ {
+ throw new IndexOutOfBoundsException("Argument idx is out of bounds: " + idx2 + "<>[0," +
+ size + ")");
+ }
+
+ if (idx1 == idx2)
+ {
+ return;
+ }
+
+ if (children instanceof Object[])
+ {
+ final Object[] array = (Object[])children;
+ Object tmp = array[idx1];
+ array[idx1] = array[idx2];
+ array[idx2] = tmp;
+ }
+ else
+ {
+ ChildList list = (ChildList)children;
+ Object tmp = list.childs[idx1];
+ list.childs[idx1] = list.childs[idx2];
+ list.childs[idx2] = tmp;
+ }
+
+ }
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Page.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Page.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Page.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Page.java Sun Nov 16 14:04:19 2008
@@ -119,8 +119,6 @@
* @author Eelco Hillenius
* @author Johan Compagner
*
- * @param <T>
- * The model object type
*/
public abstract class Page extends MarkupContainer implements IRedirectListener, IPageMapEntry
{
@@ -418,7 +416,8 @@
* THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.
*
* This method is called when a component was rendered standalone. If it is a <code>
- * MarkupContainer</code> then the rendering for that container is checked.
+ * MarkupContainer</code>
+ * then the rendering for that container is checked.
*
* @param component
*
@@ -496,7 +495,6 @@
/**
* @see org.apache.wicket.session.pagemap.IPageMapEntry#getPageClass()
*/
- @SuppressWarnings("unchecked")
public final Class<? extends Page> getPageClass()
{
return getClass();
@@ -730,6 +728,19 @@
}
/**
+ * Determine the "statelessness" of the page while not changing the cached value.
+ *
+ * @return boolean value
+ */
+ private boolean peekPageStateless()
+ {
+ Boolean old = stateless;
+ Boolean res = isPageStateless();
+ stateless = old;
+ return res;
+ }
+
+ /**
* Gets whether the page is stateless. Components on stateless page must not render any
* statefull urls, and components on statefull page must not render any stateless urls.
* Statefull urls are urls, which refer to a certain (current) page instance.
@@ -847,6 +858,19 @@
*/
public final void renderPage()
{
+
+ if (getApplication().getDebugSettings().isOutputMarkupContainerClassName())
+ {
+ Class<?> klass = getClass();
+ while (klass.isAnonymousClass())
+ {
+ klass = klass.getSuperclass();
+ }
+ getResponse().write("<!-- Page Class ");
+ getResponse().write(klass.getName());
+ getResponse().write(" -->\n");
+ }
+
// first try to check if the page can be rendered:
if (!isActionAuthorized(RENDER))
{
@@ -1448,7 +1472,7 @@
// If any of the components on page is not stateless, we need to bind the session
// before we start rendering components, as then jsessionid won't be appended
// for links rendered before first stateful component
- if (getSession().isTemporary() && !isPageStateless())
+ if (getSession().isTemporary() && !peekPageStateless())
{
getSession().bind();
}
@@ -1603,4 +1627,24 @@
public void onPageAttached()
{
}
+
+ @Override
+ public String getMarkupType()
+ {
+ throw new UnsupportedOperationException(
+ "Page does not support markup. This error can happen if you have extended Page directly, instead extend WebPage");
+ }
+
+ /**
+ * Gets page instance's unique identifier
+ *
+ * @return instance unique identifier
+ */
+ public PageId getPageId()
+ {
+ setStatelessHint(false);
+ return new PageId(pageMapName, numericId, getCurrentVersionNumber());
+
+ }
+
}
Added: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/PageId.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/PageId.java?rev=718123&view=auto
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/PageId.java (added)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/PageId.java Sun Nov 16 14:04:19 2008
@@ -0,0 +1,122 @@
+/*
+ * 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;
+
+
+/**
+ * Unique identifier of a page instance
+ *
+ * @author igor.vaynberg
+ */
+public final class PageId implements IClusterable
+{
+ private static final long serialVersionUID = 1L;
+
+ private final String pageMapName;
+ private final int number;
+ private final int version;
+
+ /**
+ * Constructor
+ *
+ * @param pageMapName
+ * @param number
+ * @param version
+ */
+ PageId(String pageMapName, int number, int version)
+ {
+ this.pageMapName = pageMapName;
+ this.number = number;
+ this.version = version;
+ }
+
+ /**
+ * Gets pageMapName.
+ *
+ * @return pageMapName
+ */
+ public String getPageMapName()
+ {
+ return pageMapName;
+ }
+
+
+ /**
+ * Gets pageId.
+ *
+ * @return pageId
+ */
+ public int getPageNumber()
+ {
+ return number;
+ }
+
+
+ /**
+ * Gets pageVersion.
+ *
+ * @return pageVersion
+ */
+ public int getPageVersion()
+ {
+ return version;
+ }
+
+
+ /**
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + number;
+ result = prime * result + ((pageMapName == null) ? 0 : pageMapName.hashCode());
+ result = prime * result + version;
+ return result;
+ }
+
+ /**
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ PageId other = (PageId)obj;
+ if (number != other.number)
+ return false;
+ if (pageMapName == null)
+ {
+ if (other.pageMapName != null)
+ return false;
+ }
+ else if (!pageMapName.equals(other.pageMapName))
+ return false;
+ if (version != other.version)
+ return false;
+ return true;
+ }
+
+
+}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/PageParameters.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/PageParameters.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/PageParameters.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/PageParameters.java Sun Nov 16 14:04:19 2008
@@ -37,6 +37,7 @@
*
* @author Jonathan Locke
*/
+@SuppressWarnings("unused")
public final class PageParameters extends ValueMap
{
/**
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/RequestContext.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/RequestContext.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/RequestContext.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/RequestContext.java Sun Nov 16 14:04:19 2008
@@ -17,8 +17,28 @@
package org.apache.wicket;
import org.apache.wicket.markup.html.IHeaderResponse;
+import org.apache.wicket.protocol.http.portlet.PortletRequestContext;
+import org.apache.wicket.request.target.resource.ISharedResourceRequestTarget;
/**
+ * Handles url rewriting, provides access to the namespace for markup Ids and isolated session
+ * state.
+ *
+ * <p>
+ * This is the base strategy for encoding URLs, which is to leave them as is. This is mainly so that
+ * PortletRequestContext can implement it's portlet encoding strategies as portlets need to have
+ * special URLs encoded with portal information and portlet namespace.
+ *
+ * <p>
+ * For url rewriting, only three methods are needed to support creating Portlet ActionURLs, Portlet
+ * RenderURLs and Resource/Ajax URLs.
+ *
+ * The RequestContext is somewhat comparable to the JSF ExternalContext interface which abstracts
+ * the external environment (like web or portlet) in which the application is currently running.
+ * As this is request dependent (the same application can technically be accessed even concurrently
+ * as web or portlet), in Wicket this context has been termed RequestContext.
+ *
+ * @see PortletRequestContext
* @author Ate Douma
*/
public class RequestContext
@@ -48,7 +68,7 @@
}
/**
- *
+ * Resets the {@link RequestContext} for the current threads active request.
*/
public static final void unset()
{
@@ -56,6 +76,7 @@
}
/**
+ * Sets the {@link RequestContext} for the current threads active request.
*
* @param context
*/
@@ -65,7 +86,9 @@
}
/**
- * @return CharSequence
+ * @see PortletRequestContext#getNamespace()
+ * @return CharSequence the namespace of this request, typically overridden by the portlet
+ * implementation.
*/
public CharSequence getNamespace()
{
@@ -73,8 +96,12 @@
}
/**
+ * Encodes markup Ids, typically overridden by the portlet implementation.
+ *
+ * @see PortletRequestContext#encodeMarkupId(String)
* @param markupId
- * @return The encoded markup
+ * the markup Id to encode
+ * @return the encoded markup
*/
public String encodeMarkupId(String markupId)
{
@@ -82,8 +109,12 @@
}
/**
+ * Encodes URL's for action URLs, typically overridden by the portlet implementation.
+ *
+ * @see PortletRequestContext#encodeActionURL(CharSequence)
* @param path
- * @return The encoded url
+ * the URL to encode
+ * @return the encoded url
*/
public CharSequence encodeActionURL(CharSequence path)
{
@@ -91,8 +122,12 @@
}
/**
+ * Encodes URL's for render URLs, typically overridden by the portlet implementation.
+ *
+ * @see PortletRequestContext#encodeRenderURL(CharSequence)
* @param path
- * @return The encoded url
+ * the URL to encode
+ * @return the encoded url
*/
public CharSequence encodeRenderURL(CharSequence path)
{
@@ -100,8 +135,12 @@
}
/**
+ * Encodes URL's for resource targets, typically overridden by the portlet implementation.
+ *
+ * @see PortletRequestContext#encodeResourceURL(CharSequence)
* @param path
- * @return The encoded url
+ * the URL to encode
+ * @return the encoded url
*/
public CharSequence encodeResourceURL(CharSequence path)
{
@@ -109,8 +148,14 @@
}
/**
+ * Encodes URL's for shared resource targets, typically overridden by the portlet
+ * implementation.
+ *
+ * @see ISharedResourceRequestTarget
+ * @see PortletRequestContext#encodeSharedResourceURL(CharSequence)
* @param path
- * @return The encoded url
+ * the URL to encode
+ * @return the encoded url
*/
public CharSequence encodeSharedResourceURL(CharSequence path)
{
@@ -118,6 +163,14 @@
}
/**
+ * Used to override response objects, typically used by the portlet implementation.
+ * <p>
+ * In a Portlet environment, this allows the portlet container/portal to capture the
+ * HeaderResponse as a separate stream for merging in the overall page header (together
+ * with header output for other portlets).
+ * </p>
+ *
+ * @see PortletRequestContext#getHeaderResponse()
* @return The IHeaderResponse
*/
public IHeaderResponse getHeaderResponse()
@@ -126,7 +179,7 @@
}
/**
- * @return boolean if this is a portlet request
+ * @return boolean true if this is a portlet request
*/
public boolean isPortletRequest()
{
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/RequestCycle.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/RequestCycle.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/RequestCycle.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/RequestCycle.java Sun Nov 16 14:04:19 2008
@@ -35,6 +35,7 @@
import org.apache.wicket.request.target.component.ComponentRequestTarget;
import org.apache.wicket.request.target.component.IBookmarkablePageRequestTarget;
import org.apache.wicket.request.target.component.IPageRequestTarget;
+import org.apache.wicket.request.target.component.PageIdRequestTarget;
import org.apache.wicket.request.target.component.PageRequestTarget;
import org.apache.wicket.request.target.component.listener.BehaviorRequestTarget;
import org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget;
@@ -850,6 +851,10 @@
{
pageParameters = new PageParameters();
}
+ else
+ {
+ pageParameters = (PageParameters)pageParameters.clone();
+ }
if (params != null)
{
@@ -973,6 +978,20 @@
}
/**
+ * Returns a URL that references the page pointed to by <code>id</code>
+ *
+ * @see PageIdRequestTarget for more details
+ *
+ * @param id
+ * page id
+ * @return url pointing to the page
+ */
+ public final CharSequence urlFor(final PageId id)
+ {
+ return urlFor(new PageIdRequestTarget(id));
+ }
+
+ /**
* Returns a URL that references a shared resource through the provided resource reference.
*
* @param resourceReference
@@ -1352,6 +1371,7 @@
// if a redirect exception has been issued we abort what we
// were doing and begin responding to the top target on the
// stack
+ response.reset();
currentStep = RESPOND;
}
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Resource.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Resource.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Resource.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Resource.java Sun Nov 16 14:04:19 2008
@@ -48,6 +48,7 @@
* ImageButton components in this example are like all other components in Wicket and cannot be
* shared.
*
+ * @see SharedResources
* @author Jonathan Locke
* @author Johan Compagner
* @author Gili Tzabari
@@ -148,7 +149,7 @@
* @param parameters
* Map of query parameters that parameterize this resource
*/
- public final void setParameters(final Map< ? , ? > parameters)
+ public final void setParameters(final Map<?, ?> parameters)
{
if (parameters == null)
{
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Session.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Session.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Session.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/Session.java Sun Nov 16 14:04:19 2008
@@ -58,11 +58,10 @@
* holds the Page. So {@link Component#getSession()} traverses the component hierarchy to the root
* Page and then calls {@link Page#getSession()}.
*
- * <li><b>Access via Thread Local </b>- In the odd case where neither a RequestCycle nor a
- * Component is available, the currently active Session for the calling thread can be retrieved by
- * calling the static method Session.get(). This last form should only be used if the first two
- * forms cannot be used since thread local access can involve a potentially more expensive hash map
- * lookup.
+ * <li><b>Access via Thread Local </b>- In the odd case where neither a RequestCycle nor a Component
+ * is available, the currently active Session for the calling thread can be retrieved by calling the
+ * static method Session.get(). This last form should only be used if the first two forms cannot be
+ * used since thread local access can involve a potentially more expensive hash map lookup.
*
* <li><b>Locale </b>- A session has a Locale property to support localization. The Locale for a
* session can be set by calling {@link Session#setLocale(Locale)}. The Locale for a Session
@@ -104,9 +103,9 @@
* <li><b>Removal </b>- Pages can be removed from the Session forcibly by calling remove(Page) or
* removeAll(), although such an action should rarely be necessary.
*
- * <li><b>Flash Messages</b>- Flash messages are messages that are stored in session and are
- * removed after they are displayed to the user. Session acts as a store for these messages because
- * they can last across requests.
+ * <li><b>Flash Messages</b>- Flash messages are messages that are stored in session and are removed
+ * after they are displayed to the user. Session acts as a store for these messages because they can
+ * last across requests.
*
* @author Jonathan Locke
* @author Eelco Hillenius
@@ -392,8 +391,8 @@
* <p>
* By calling this method, the session will be bound (made not-temporary) if it was not bound
* yet. It is useful for cases where you want to be absolutely sure this session object will be
- * available in next requests. If the session was already bound ({@link ISessionStore#lookup(Request) returns a session}),
- * this call will be a noop.
+ * available in next requests. If the session was already bound (
+ * {@link ISessionStore#lookup(Request) returns a session}), this call will be a noop.
* </p>
*/
public final void bind()
@@ -681,8 +680,7 @@
* @return The page based on the first path component (the page id), or null if the requested
* version of the page cannot be found.
*/
- public final Page getPage(final String pageMapName, final String path,
- final int versionNumber)
+ public final Page getPage(final String pageMapName, final String path, final int versionNumber)
{
if (log.isDebugEnabled())
{
@@ -797,20 +795,6 @@
}
/**
- * @param page
- * The page, or null if no page context is available
- * @return The page factory for the page, or the default page factory if page was null
- */
- public final IPageFactory getPageFactory(final Page page)
- {
- if (page != null)
- {
- return page.getPageFactory();
- }
- return getPageFactory();
- }
-
- /**
* @return A list of all PageMaps in this session.
*/
public final List<IPageMap> getPageMaps()
@@ -881,6 +865,21 @@
getSessionStore().invalidate(RequestCycle.get().getRequest());
}
+
+ /**
+ * Replaces the underlying (Web)Session, invalidating the current one and creating a new one. By
+ * calling {@link ISessionStore#invalidate(Request)} and {@link #bind()}
+ * <p>
+ * Call upon login to protect against session fixation.
+ *
+ * @see "http://www.owasp.org/index.php/Session_Fixation"
+ */
+ public void replaceSession()
+ {
+ getSessionStore().invalidate(RequestCycle.get().getRequest());
+ bind();
+ }
+
/**
* Whether the session is invalid now, or will be invalidated by the end of the request. Clients
* should rarely need to use this method if ever.
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/SharedResources.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/SharedResources.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/SharedResources.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/SharedResources.java Sun Nov 16 14:04:19 2008
@@ -32,6 +32,13 @@
* Class which holds shared resources. Resources can be shared by name. An optional scope can be
* given to prevent naming conflicts and a locale and/or style can be given as well.
*
+ * <p>
+ * Unlike component hosted resources, shared resources have stable URLs, which makes them suitable
+ * for indexing by web crawlers and caching by web browsers. As they are also not synchronised on
+ * the {@link Session}, they can be loaded asynchronously, which is important with images and
+ * resources such as JavaScript and CSS.
+ *
+ * @see Resource
* @author Jonathan Locke
* @author Johan Compagner
* @author Gili Tzabari
@@ -42,8 +49,10 @@
private static final Logger log = LoggerFactory.getLogger(SharedResources.class);
/**
- * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT. Inserts _[locale] and
- * _[style] into path just before any extension that might exist.
+ * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.
+ *
+ * <p>
+ * Inserts _[locale] and _[style] into path just before any extension that might exist.
*
* @param path
* The resource path
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/AbstractDefaultAjaxBehavior.java Sun Nov 16 14:04:19 2008
@@ -159,8 +159,7 @@
* @param partialCall
* Javascript of a partial call to the function performing the actual ajax callback.
* Must be in format <code>function(params,</code> with signature
- * <code>function(params, onSuccessHandler, onFailureHandler</code>. Example:
- * <code>wicketAjaxGet('callbackurl'</code>
+ * <code>function(params, onSuccessHandler, onFailureHandler</code>. Example: <code>wicketAjaxGet('callbackurl'</code>
*
* @return script that performs ajax callback to this behavior
*/
@@ -260,10 +259,12 @@
}
/**
+ * Finds the markup id of the indicator. The default search order is: component, behavior,
+ * component's parent hieararchy.
*
- * @return String
+ * @return markup id or <code>null</code> if no indicator found
*/
- private String findIndicatorId()
+ protected String findIndicatorId()
{
if (getComponent() instanceof IAjaxIndicatorAware)
{
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java Sun Nov 16 14:04:19 2008
@@ -106,7 +106,7 @@
// only add the event handler when the component is enabled.
Component myComponent = getComponent();
- if (myComponent.isEnabled() && myComponent.isEnableAllowed())
+ if (myComponent.isEnabledInHierarchy())
{
tag.put(event, getEventHandler());
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/AjaxRequestTarget.java Sun Nov 16 14:04:19 2008
@@ -370,7 +370,10 @@
}
else if (component instanceof Page)
{
- throw new IllegalArgumentException("component cannot be a page");
+ if (component != page)
+ {
+ throw new IllegalArgumentException("component cannot be a page");
+ }
}
else if (component instanceof AbstractRepeater)
{
@@ -438,7 +441,11 @@
if (markupIdToComponent.size() > 0)
{
final Component component = markupIdToComponent.values().iterator().next();
- component.getPage().detach();
+ final Page page = (Page)component.findParent(Page.class);
+ if (page != null)
+ {
+ page.detach();
+ }
}
}
@@ -522,6 +529,17 @@
*/
public final void respond(final RequestCycle requestCycle)
{
+ final WebResponse response = (WebResponse)requestCycle.getResponse();
+
+ if (markupIdToComponent.values().contains(page))
+ {
+ // the page itself has been added to the request target, we simply issue a redirect back
+ // to the page
+ final String url = requestCycle.urlFor(page).toString();
+ response.redirect(url);
+ return;
+ }
+
for (ITargetRespondListener listener : respondListeners)
{
listener.onTargetRespond(this);
@@ -533,7 +551,6 @@
final String encoding = app.getRequestCycleSettings().getResponseRequestEncoding();
// Set content type based on markup type for page
- final WebResponse response = (WebResponse)requestCycle.getResponse();
response.setCharacterEncoding(encoding);
response.setContentType("text/xml; charset=" + encoding);
@@ -732,7 +749,7 @@
RequestCycle.get().setResponse(encodingBodyResponse);
// Initialize temporary variables
- final Page page = (Page)component.findParent(Page.class);
+ final Page page = component.findParent(Page.class);
if (page == null)
{
// dont throw an exception but just ignore this component, somehow
@@ -748,12 +765,39 @@
page.startComponentRender(component);
- component.prepareForRender();
+ try
+ {
+ component.prepareForRender();
- // render any associated headers of the component
- respondHeaderContribution(response, component);
+ // render any associated headers of the component
+ respondHeaderContribution(response, component);
+ }
+ catch (RuntimeException e)
+ {
+ try
+ {
+ component.afterRender();
+ }
+ catch (RuntimeException e2)
+ {
+ // ignore this one could be a result off.
+ }
+ // Restore original response
+ RequestCycle.get().setResponse(originalResponse);
+ encodingBodyResponse.reset();
+ throw e;
+ }
- component.renderComponent();
+ try
+ {
+ component.renderComponent();
+ }
+ catch (RuntimeException e)
+ {
+ RequestCycle.get().setResponse(originalResponse);
+ encodingBodyResponse.reset();
+ throw e;
+ }
page.endComponentRender(component);
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormChoiceComponentUpdatingBehavior.java Sun Nov 16 14:04:19 2008
@@ -134,9 +134,9 @@
*
* @return FormComponent
*/
- protected final FormComponent getFormComponent()
+ protected final FormComponent<?> getFormComponent()
{
- return (FormComponent)getComponent();
+ return (FormComponent<?>)getComponent();
}
/**
@@ -157,7 +157,7 @@
@Override
protected final void respond(final AjaxRequestTarget target)
{
- final FormComponent formComponent = getFormComponent();
+ final FormComponent<?> formComponent = getFormComponent();
try
{
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.java Sun Nov 16 14:04:19 2008
@@ -81,9 +81,9 @@
*
* @return FormComponent
*/
- protected final FormComponent getFormComponent()
+ protected final FormComponent<?> getFormComponent()
{
- return (FormComponent)getComponent();
+ return (FormComponent<?>)getComponent();
}
/**
@@ -117,7 +117,7 @@
@Override
protected final void onEvent(final AjaxRequestTarget target)
{
- final FormComponent formComponent = getFormComponent();
+ final FormComponent<?> formComponent = getFormComponent();
if (getEvent().toLowerCase().equals("onblur") && disableFocusOnBlur())
{
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/AjaxFallbackLink.java Sun Nov 16 14:04:19 2008
@@ -31,6 +31,8 @@
* @since 1.2
*
* @author Igor Vaynberg (ivaynberg)
+ * @param <T>
+ * type of model object
*/
public abstract class AjaxFallbackLink<T> extends Link<T> implements IAjaxLink
{
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/AjaxLink.java Sun Nov 16 14:04:19 2008
@@ -30,6 +30,8 @@
* @since 1.2
*
* @author Igor Vaynberg (ivaynberg)
+ * @param <T>
+ * type of model object
*
*/
public abstract class AjaxLink<T> extends AbstractLink implements IAjaxLink
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxButton.java Sun Nov 16 14:04:19 2008
@@ -21,6 +21,7 @@
import org.apache.wicket.ajax.form.AjaxFormSubmitBehavior;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.model.IModel;
import org.apache.wicket.util.string.AppendingStringBuffer;
import org.apache.wicket.util.string.Strings;
@@ -45,37 +46,46 @@
*/
public AjaxButton(String id)
{
- this(id, null);
+ this(id, null, null);
}
/**
- * Returns the form if it was set in constructor, otherwise returns the form nearest in parent
- * hierarchy.
*
- * @see org.apache.wicket.markup.html.form.FormComponent#getForm()
+ * Construct.
+ *
+ * @param id
+ * @param model
+ * model used to set <code>value</code> markup attribute
*/
- @Override
- public Form<?> getForm()
+ public AjaxButton(String id, IModel<String> model)
{
- if (form != null)
- {
- return form;
- }
- else
- {
- return super.getForm();
- }
+ this(id, model, null);
}
/**
+ *
* Construct.
*
* @param id
* @param form
*/
- public AjaxButton(String id, final Form<?> form)
+ public AjaxButton(String id, Form<?> form)
{
- super(id);
+ this(id, null, form);
+ }
+
+
+ /**
+ * Construct.
+ *
+ * @param id
+ * @param model
+ * model used to set <code>value</code> markup attribute
+ * @param form
+ */
+ public AjaxButton(String id, IModel<String> model, final Form<?> form)
+ {
+ super(id, model);
this.form = form;
add(new AjaxFormSubmitBehavior(form, "onclick")
@@ -136,6 +146,26 @@
}
/**
+ * Returns the form if it was set in constructor, otherwise returns the form nearest in parent
+ * hierarchy.
+ *
+ * @see org.apache.wicket.markup.html.form.FormComponent#getForm()
+ */
+ @Override
+ public Form<?> getForm()
+ {
+ if (form != null)
+ {
+ return form;
+ }
+ else
+ {
+ return super.getForm();
+ }
+ }
+
+
+ /**
* Returns the {@link IAjaxCallDecorator} that will be used to modify the generated javascript.
* This is the preferred way of changing the javascript in the onclick handler
*
@@ -160,7 +190,7 @@
* @param target
* @param form
*
- * TODO 1.3: Make abstract to be consistent with onSubmit()
+ * TODO 1.3: Make abstract to be consistent with onSubmit()
*/
protected void onError(AjaxRequestTarget target, Form<?> form)
{
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxFallbackButton.java Sun Nov 16 14:04:19 2008
@@ -156,6 +156,6 @@
*/
protected final boolean isButtonEnabled()
{
- return isEnabled() && isEnableAllowed();
+ return isEnabledInHierarchy();
}
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitButton.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitButton.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitButton.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitButton.java Sun Nov 16 14:04:19 2008
@@ -26,8 +26,6 @@
* @since 1.2
*
* @author Igor Vaynberg (ivaynberg)
- * @param <T>
- * The model object type
* @deprecated Use {@link AjaxButton} instead.
*/
@Deprecated
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/form/AjaxSubmitLink.java Sun Nov 16 14:04:19 2008
@@ -60,8 +60,6 @@
*
* @author Igor Vaynberg (ivaynberg)
*
- * @param <T>
- * The model object type
*/
public abstract class AjaxSubmitLink extends AbstractSubmitLink
{
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigation.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigation.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigation.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigation.java Sun Nov 16 14:04:19 2008
@@ -78,7 +78,7 @@
* @return the ajaxified page number link.
*/
@Override
- protected Link newPagingNavigationLink(String id, IPageable pageable, int pageIndex)
+ protected Link<?> newPagingNavigationLink(String id, IPageable pageable, int pageIndex)
{
return new AjaxPagingNavigationLink(id, pageable, pageIndex);
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigationBehavior.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigationBehavior.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigationBehavior.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigationBehavior.java Sun Nov 16 14:04:19 2008
@@ -76,7 +76,7 @@
owner.onClick(target);
// find the PagingNavigator parent of this link
- AjaxPagingNavigator navigator = (AjaxPagingNavigator)((Component)owner).findParent(AjaxPagingNavigator.class);
+ AjaxPagingNavigator navigator = ((Component)owner).findParent(AjaxPagingNavigator.class);
if (navigator == null)
{
throw new WicketRuntimeException(
@@ -103,7 +103,7 @@
@Override
protected void onComponentTag(ComponentTag tag)
{
- if (getComponent().isEnabled() && getComponent().isEnableAllowed())
+ if (getComponent().isEnabledInHierarchy())
{
super.onComponentTag(tag);
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigationIncrementLink.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigationIncrementLink.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigationIncrementLink.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigationIncrementLink.java Sun Nov 16 14:04:19 2008
@@ -24,33 +24,33 @@
/**
* An incremental Ajaxian link to a page of a PageableListView. Assuming your list view navigation
* looks like
- *
+ *
* <pre>
- *
+ *
* [first / << / <] 1 | 2 | 3 [> / >> /last]
- *
+ *
* </pre>
- *
+ *
* <p>
* and "<" meaning the previous and "<<" goto the "current page - 5", than it is this kind
* of incremental page links which can easily be created.
- *
+ *
* This link will update the pageable and itself or the navigator the link is part of using Ajax
* techniques, or perform a full refresh when ajax is not available.
- *
+ *
* @since 1.2
- *
+ *
* @author Martijn Dashorst
*/
-public class AjaxPagingNavigationIncrementLink extends PagingNavigationIncrementLink
- implements
- IAjaxLink
+public class AjaxPagingNavigationIncrementLink extends PagingNavigationIncrementLink<Void>
+ implements
+ IAjaxLink
{
private static final long serialVersionUID = 1L;
/**
* Constructor.
- *
+ *
* @param id
* See Component
* @param pageable
@@ -59,7 +59,7 @@
* increment by
*/
public AjaxPagingNavigationIncrementLink(final String id, final IPageable pageable,
- final int increment)
+ final int increment)
{
super(id, pageable, increment);
add(new AjaxPagingNavigationBehavior(this, pageable, "onclick"));
@@ -74,7 +74,7 @@
* NOTE: It is recommended that you only prepend additional javascript to the default handler
* because the default handler uses the return func() format so any appended javascript will not
* be evaluated by default.
- *
+ *
* @param defaultHandler
* default javascript event handler generated by this link
* @return javascript event handler for this link
@@ -87,9 +87,10 @@
/**
* Fallback event listener, will redisplay the current page.
- *
+ *
* @see org.apache.wicket.markup.html.link.Link#onClick()
*/
+ @Override
public void onClick()
{
onClick(null);
@@ -104,7 +105,7 @@
/**
* Performs the actual action of this component, performing a non-ajax fallback when there was
* no AjaxRequestTarget available.
- *
+ *
* @param target
* the request target, when <code>null</code>, a full page refresh will be
* generated
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigationLink.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigationLink.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigationLink.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigationLink.java Sun Nov 16 14:04:19 2008
@@ -23,18 +23,18 @@
/**
* An Ajax version of a link to a page of a PageableListView.
- *
+ *
* @since 1.2
- *
+ *
* @author Martijn Dashorst
*/
-public class AjaxPagingNavigationLink extends PagingNavigationLink implements IAjaxLink
+public class AjaxPagingNavigationLink extends PagingNavigationLink<Void> implements IAjaxLink
{
private static final long serialVersionUID = 1L;
/**
* Constructor.
- *
+ *
* @param id
* See Component
* @param pageable
@@ -52,7 +52,7 @@
/**
* Fallback event listener, will redisplay the current page.
- *
+ *
* @see org.apache.wicket.markup.html.link.Link#onClick()
*/
@Override
@@ -70,7 +70,7 @@
/**
* Performs the actual action of this component, performing a non-ajax fallback when there was
* no AjaxRequestTarget available.
- *
+ *
* @param target
* the request target, when <code>null</code>, a full page refresh will be
* generated
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigator.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigator.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigator.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/markup/html/navigation/paging/AjaxPagingNavigator.java Sun Nov 16 14:04:19 2008
@@ -91,7 +91,7 @@
* @return the increment link
*/
@Override
- protected Link newPagingNavigationIncrementLink(String id, IPageable pageable, int increment)
+ protected Link<?> newPagingNavigationIncrementLink(String id, IPageable pageable, int increment)
{
return new AjaxPagingNavigationIncrementLink(id, pageable, increment);
}
@@ -109,7 +109,7 @@
* @return the pagenumber link
*/
@Override
- protected Link newPagingNavigationLink(String id, IPageable pageable, int pageNumber)
+ protected Link<?> newPagingNavigationLink(String id, IPageable pageable, int pageNumber)
{
return new AjaxPagingNavigationLink(id, pageable, pageNumber);
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js Sun Nov 16 14:04:19 2008
@@ -271,12 +271,15 @@
}
// remove the original element
+ if(element.style.backgroundImage)
+ element.style.backgroundImage = "";
parent.removeChild(element);
-
element.outerHTML = "";
element = "";
if (window.parent == window || window.parent == null) {
+ if(tempDiv.style.backgroundImage)
+ tempDiv.style.backgroundImage = "";
document.body.removeChild(tempDiv);
}
@@ -833,14 +836,6 @@
var t = this.transport;
if (t != null) {
- if (Wicket.Browser.isGecko()) {
- var href = document.location.href;
- var lastIndexOf = href.lastIndexOf('/');
- if (lastIndexOf > 0)
- {
- url = href.substring(0,lastIndexOf+1) + url;
- }
- }
t.open("GET", url, this.async);
t.onreadystatechange = this.stateChangeCallback.bind(this);
// set a special flag to allow server distinguish between ajax and non-ajax requests
@@ -938,6 +933,10 @@
if (typeof(redirectUrl) != "undefined" && redirectUrl != null && redirectUrl != "") {
t.onreadystatechange = Wicket.emptyFunction;
+ // In case the page isn't really redirected. For example say the redirect is to an octet-stream.
+ // A file download popup will appear but the page in the browser won't change.
+ this.done();
+
// support/check for non-relative redirectUrl like as provided and needed in a portlet context
if (redirectUrl.charAt(0)==('/')||redirectUrl.match("^http://")=="http://"||redirectUrl.match("^https://")=="https://") {
window.location = redirectUrl;
@@ -1434,7 +1433,7 @@
var req = new Wicket.Ajax.Request(src, onLoad, false, false);
req.debugContent = false;
if (Wicket.Browser.isKHTML())
- // konqueror can't process the ajax response asynchronously, threfore the
+ // konqueror can't process the ajax response asynchronously, therefore the
// javascript loading must be also synchronous
req.async = false;
// get the javascript
@@ -1444,8 +1443,18 @@
// serialize the element content to string
var text = Wicket.DOM.serializeNodeChildren(node);
- // add javascript to document head
- Wicket.Head.addJavascript(text, node.getAttribute("id"));
+ var id = node.getAttribute("id");
+
+ if (typeof(id) == "string" && id.length > 0) {
+ // add javascript to document head
+ Wicket.Head.addJavascript(text, id);
+ } else {
+ try {
+ eval(text);
+ } catch (e) {
+ Wicket.Log.error(e);
+ }
+ }
// continue to next step
notify();
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/behavior/AttributeAppender.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/behavior/AttributeAppender.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/behavior/AttributeAppender.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/behavior/AttributeAppender.java Sun Nov 16 14:04:19 2008
@@ -33,8 +33,8 @@
* can be modified with these AttributeAppenders:
*
* <pre>
- * link.add(new AttributeAppender("class", new Model("hot"), " "));
- * link.add(new AttributeAppender("onmouseover", new Model("foo();return false;"), ";"));
+ * link.add(new AttributeAppender("class", new Model<String>("hot"), " "));
+ * link.add(new AttributeAppender("onmouseover", new Model<String>("foo();return false;"), ";"));
* </pre>
*
* this will result in the following markup:
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/behavior/HeaderContributor.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/behavior/HeaderContributor.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/behavior/HeaderContributor.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/behavior/HeaderContributor.java Sun Nov 16 14:04:19 2008
@@ -52,7 +52,7 @@
* The path
* @return the new header contributor instance
*/
- public static final HeaderContributor forCss(final Class< ? > scope, final String path)
+ public static final HeaderContributor forCss(final Class<?> scope, final String path)
{
return new HeaderContributor(new IHeaderContributor()
{
@@ -78,7 +78,7 @@
* The media type for this CSS ("print", "screen", etc.)
* @return the new header contributor instance
*/
- public static final HeaderContributor forCss(final Class< ? > scope, final String path,
+ public static final HeaderContributor forCss(final Class<?> scope, final String path,
final String media)
{
return new HeaderContributor(new IHeaderContributor()
@@ -203,7 +203,7 @@
* The path
* @return the new header contributor instance
*/
- public static final HeaderContributor forJavaScript(final Class< ? > scope, final String path)
+ public static final HeaderContributor forJavaScript(final Class<?> scope, final String path)
{
return new HeaderContributor(new IHeaderContributor()
{
@@ -276,7 +276,10 @@
}
else
{
- return RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot() + location;
+ return RequestCycle.get()
+ .getProcessor()
+ .getRequestCodingStrategy()
+ .rewriteStaticRelativeUrl(location);
}
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/IMarkupCacheKeyProvider.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/IMarkupCacheKeyProvider.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/IMarkupCacheKeyProvider.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/IMarkupCacheKeyProvider.java Sun Nov 16 14:04:19 2008
@@ -22,6 +22,11 @@
* To be implemented by MarkupContainers that wish to implement their own algorithms for the markup
* cache key.
*
+ * <p>
+ * If {@link #getCacheKey(MarkupContainer, Class)} method returns <code>null</code> the markup is
+ * not cached.
+ * </p>
+ *
* @see IMarkupResourceStreamProvider
*
* @author Juergen Donnerstag
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/MarkupCache.java Sun Nov 16 14:04:19 2008
@@ -346,7 +346,8 @@
}
// flag markup as non-existent
- return putIntoCache(cacheKey, Markup.NO_MARKUP);
+ markupKeyCache.put(cacheKey, cacheKey);
+ return putIntoCache(cacheKey, container, Markup.NO_MARKUP);
}
/**
@@ -358,7 +359,10 @@
* @param markup
* @return markup The markup provided, except if the cacheKey already existed in the cache, than
* the markup from the cache is provided.
+ *
+ * @deprecated see {@link #putIntoCache(String, MarkupContainer, Markup)}
*/
+ @Deprecated
protected Markup putIntoCache(final String locationString, Markup markup)
{
if (locationString != null)
@@ -383,6 +387,27 @@
}
/**
+ * Put the markup into the cache if cacheKey is not null and the cache does not yet contain the
+ * cacheKey. Return the markup stored in the cache if cacheKey is present already.
+ *
+ * More sophisticated implementations may call a container method to e.g. cache it per container
+ * instance.
+ *
+ * @param locationString
+ * If null, than ignore the cache
+ * @param container
+ * The container this markup is for.
+ * @param markup
+ * @return markup The markup provided, except if the cacheKey already existed in the cache, than
+ * the markup from the cache is provided.
+ */
+ protected Markup putIntoCache(final String locationString, MarkupContainer container,
+ Markup markup)
+ {
+ return putIntoCache(locationString, markup);
+ }
+
+ /**
* Wicket's default implementation just uses the cacheKey to retrieve the markup from the cache.
* More sophisticated implementations may call a container method to e.g. ignore the cached
* markup under certain situations.
@@ -392,8 +417,7 @@
* @param container
* @return null, if not found or to enforce reloading the markup
*/
- protected Markup getMarkupFromCache(final CharSequence cacheKey,
- final MarkupContainer container)
+ protected Markup getMarkupFromCache(final CharSequence cacheKey, final MarkupContainer container)
{
if (cacheKey != null)
{
@@ -442,7 +466,7 @@
}
// add the markup to the cache.
markupKeyCache.put(cacheKey, locationString);
- return putIntoCache(locationString, markup);
+ return putIntoCache(locationString, container, markup);
}
return markup;
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/basic/Label.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/basic/Label.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/basic/Label.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/basic/Label.java Sun Nov 16 14:04:19 2008
@@ -39,7 +39,7 @@
* <pre>
*
* add(new Label("myLabel", new PropertyModel(person, "name"));
- *
+ *
* </pre>
*
* In this case, the Label component will replace the body of the tag it is attached to with the
@@ -80,7 +80,7 @@
}
/**
- * Convenience constructor. Same as Label(String, new Model(String))
+ * Convenience constructor. Same as Label(String, new Model<String>(String))
*
* @param id
* See Component
@@ -89,10 +89,9 @@
*
* @see org.apache.wicket.Component#Component(String, IModel)
*/
- @SuppressWarnings("unchecked")
public Label(final String id, String label)
{
- this(id, new Model(label));
+ this(id, new Model<String>(label));
}
/**
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/basic/MultiLineLabel.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/basic/MultiLineLabel.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/basic/MultiLineLabel.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/basic/MultiLineLabel.java Sun Nov 16 14:04:19 2008
@@ -27,8 +27,8 @@
* A MultiLineLabel component replaces its body with the model object.
* <p>
* Unlike {@link Label}, {@link MultiLineLabel} shows text that spans multiple lines by inserting
- * line breaks (<code>BR</code> tags) for newlines and paragraph markers (<code>P</code> tags)
- * for sequences of more than one newline.
+ * line breaks (<code>BR</code> tags) for newlines and paragraph markers (<code>P</code> tags) for
+ * sequences of more than one newline.
*
* @author Jonathan Locke
*/
@@ -49,7 +49,7 @@
}
/**
- * Convenience constructor. Same as MultiLineLabel(String, new Model(String))
+ * Convenience constructor. Same as MultiLineLabel(String, new Modell<String>(String))
*
* @param id
* See Component
@@ -58,10 +58,9 @@
*
* @see org.apache.wicket.Component#Component(String, IModel)
*/
- @SuppressWarnings("unchecked")
public MultiLineLabel(final String id, String label)
{
- this(id, new Model(label));
+ this(id, new Model<String>(label));
}
/**
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/border/Border.java Sun Nov 16 14:04:19 2008
@@ -297,7 +297,7 @@
// body.isVisible(false) needs a little extra work. We must skip the
// markup between <span wicket:id="myBorder"> and </span>
- if (body.isVisible() == false)
+ if (isBodyVisible() == false)
{
originalMarkupStream.skipToMatchingCloseTag(openTag);
}
@@ -403,4 +403,24 @@
return false;
}
}
+
+ /**
+ * Determines whether or not the border body is visible.
+ *
+ * @return true if body of the border is visible, false otherwise
+ */
+ private boolean isBodyVisible()
+ {
+ // in order to determine this we have to visit all components between the border and the
+ // body because border body can be embedded inside other containers.
+
+ boolean bodyVisible = true;
+ Component cursor = body;
+ while (cursor != this && bodyVisible)
+ {
+ bodyVisible = cursor.determineVisibility();
+ cursor = cursor.getParent();
+ }
+ return bodyVisible;
+ }
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/border/MarkupComponentBorder.java Sun Nov 16 14:04:19 2008
@@ -71,7 +71,8 @@
boolean insideBorderMarkup = false;
while (stream.hasMore())
{
- MarkupElement e = stream.next();
+ MarkupElement e = stream.get();
+ stream.next();
if (e instanceof WicketTag)
{
WicketTag wt = (WicketTag)e;
@@ -129,7 +130,8 @@
while (stream.hasMore())
{
- MarkupElement e = stream.next();
+ MarkupElement e = stream.get();
+ stream.next();
if (e instanceof WicketTag)
{
WicketTag wt = (WicketTag)e;
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractChoice.java Sun Nov 16 14:04:19 2008
@@ -253,7 +253,7 @@
addStateChange(new ChoicesListChange());
}
}
- this.choices = new WildcardListModel<E>(choices);
+ this.choices = new WildcardListModel<E>(choices);
return this;
}
@@ -376,6 +376,7 @@
* @param selected
* The currently selected string value
*/
+ @SuppressWarnings("unchecked")
protected void appendOptionHtml(AppendingStringBuffer buffer, E choice, int index,
String selected)
{
@@ -385,7 +386,7 @@
String displayValue = "";
if (objectClass != null && objectClass != String.class)
{
- final IConverter<T> converter = getConverter(objectClass);
+ final IConverter converter = getConverter(objectClass);
displayValue = converter.convertToString(objectValue, getLocale());
}
Modified: wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractSubmitLink.java
URL: http://svn.apache.org/viewvc/wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractSubmitLink.java?rev=718123&r1=718122&r2=718123&view=diff
==============================================================================
--- wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractSubmitLink.java (original)
+++ wicket/sandbox/knopp/experimental/wicket/src/main/java/org/apache/wicket/markup/html/form/AbstractSubmitLink.java Sun Nov 16 14:04:19 2008
@@ -28,8 +28,6 @@
*
* @author Matej Knopp
*
- * @param <T>
- * The model object type
*/
public abstract class AbstractSubmitLink extends AbstractLink implements IFormSubmittingComponent
{