Author: jcompagner
Date: Wed Dec 20 08:22:06 2006
New Revision: 489132
URL: http://svn.apache.org/viewvc?view=rev&rev=489132
Log:
stateless improvements and unit test (from 2.0)
everything should be synched now between 1.3 and 2.0
added filename into the 2 Resources (ByteArray and DynamicWeb)
Added:
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_home_result.html
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_mount_result.html
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/DynamicWebResource.java
incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/request/AbstractWebRequestCodingStrategy.java
incubator/wicket/trunk/wicket/src/main/java/wicket/request/compound/DefaultRequestTargetResolverStrategy.java
incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java
incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/resource/ResourceStreamRequestTarget.java
incubator/wicket/trunk/wicket/src/main/java/wicket/resource/ByteArrayResource.java
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/autolink/MyPageExpectedResult.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/autolink/PageAExpectedResult.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/basic/SimplePageExpectedResult_12.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_1.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_2.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_3.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_4.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/BookmarkableHomePageLinksPage_result.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageDefaultContextResult.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageEmptyContextResult.html
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageRootContextResult.html
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage.java
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_result.html
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentTest.java
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/DynamicWebResource.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/DynamicWebResource.java?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/DynamicWebResource.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/markup/html/DynamicWebResource.java
Wed Dec 20 08:22:06 2006
@@ -14,221 +14,252 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package wicket.markup.html;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Locale;
-
-import wicket.util.resource.IResourceStream;
-import wicket.util.resource.ResourceStreamNotFoundException;
-import wicket.util.time.Time;
-
-/**
- * An WebResource subclass for dynamic resources (resources created
- * programmatically).
- *
- * @author Jonathan Locke
- * @author Johan Compagner
- * @author Gili Tzabari
- */
-public abstract class DynamicWebResource extends WebResource
-{
- /**
- * The resource state returned by the getResourceState() method. This
state
- * needs to be thread-safe and its methods must return the same values
no
- * matter how many times they are invoked. A ResourceState may assume
- * getParameters() will remain unchanged during its lifetime.
- *
- * @author jcompagner
- */
- public static class ResourceState
- {
- protected Time lastModifiedTime;
-
- /**
- * @return The Byte array for this resource
- */
- public byte[] getData()
- {
- return null;
- }
-
- /**
- * @return The content type of this resource
- */
- public String getContentType()
- {
- return null;
- }
-
- /**
- * @return The last modified time of this resource
- */
- public Time lastModifiedTime()
- {
- if (lastModifiedTime == null)
- {
- lastModifiedTime = Time.now();
- }
- return lastModifiedTime;
- }
-
- /**
- * @return The length of the data
- */
- public int getLength()
- {
- byte[] data = getData();
- return data != null ? data.length : 0;
- }
- }
-
- /**
- * The resource locale.
- */
- private Locale locale;
-
- /**
- * Creates a dynamic resource.
- */
- public DynamicWebResource()
- {
- setCacheable(false);
- }
-
- /**
- * Creates a dynamic resource from for the given locale
- *
- * @param locale
- * The locale of this resource
- */
- public DynamicWebResource(Locale locale)
- {
- this();
- this.locale = locale;
- }
-
- /**
- * Returns the resource locale.
- *
- * @return The locale of this resource
- */
- public Locale getLocale()
- {
- return locale;
- }
-
- /**
- * @return Gets the resource to attach to the component.
- */
- @Override
- public IResourceStream getResourceStream()
- {
- return new IResourceStream()
- {
- private static final long serialVersionUID = 1L;
-
- private Locale locale =
DynamicWebResource.this.getLocale();
-
- /** Transient input stream to resource */
- private transient InputStream inputStream = null;
-
- /**
- * Transient ResourceState of the resources, will
always be deleted
- * in the close
- */
- private transient ResourceState data = null;
-
- /**
- * @see wicket.util.resource.IResourceStream#close()
- */
- public void close() throws IOException
- {
- if (inputStream != null)
- {
- inputStream.close();
- inputStream = null;
- }
- data = null;
- }
-
- /**
- * @see
wicket.util.resource.IResourceStream#getContentType()
- */
- public String getContentType()
- {
- checkLoadData();
- return data.getContentType();
- }
-
- /**
- * @see
wicket.util.resource.IResourceStream#getInputStream()
- */
- public InputStream getInputStream() throws
ResourceStreamNotFoundException
- {
- checkLoadData();
- if (inputStream == null)
- {
- inputStream = new
ByteArrayInputStream(data.getData());
- }
- return inputStream;
- }
-
- /**
- * @see wicket.util.watch.IModifiable#lastModifiedTime()
- */
- public Time lastModifiedTime()
- {
- checkLoadData();
- return data.lastModifiedTime();
- }
-
- /**
- * @see wicket.util.resource.IResourceStream#length()
- */
- public long length()
- {
- checkLoadData();
- return data.getLength();
- }
-
- /**
- * @see wicket.util.resource.IResourceStream#getLocale()
- */
- public Locale getLocale()
- {
- return locale;
- }
-
- /**
- * @see
wicket.util.resource.IResourceStream#setLocale(java.util.Locale)
- */
- public void setLocale(Locale loc)
- {
- locale = loc;
- }
-
- /**
- * Check whether the data was loaded yet. If not, load
it now.
- */
- private void checkLoadData()
- {
- if (data == null)
- {
- data = getResourceState();
- }
- }
- };
- }
-
- /**
- * Gets the byte array for our dynamic resource. If the subclass
regenerates
- * the data, it should set the lastModifiedTime too. This ensures that
- * resource caching works correctly.
- *
- * @return The byte array for this dynamic resource.
- */
- protected abstract ResourceState getResourceState();
-}
+package wicket.markup.html;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Locale;
+
+import wicket.protocol.http.WebResponse;
+import wicket.util.resource.IResourceStream;
+import wicket.util.resource.ResourceStreamNotFoundException;
+import wicket.util.time.Time;
+
+/**
+ * An WebResource subclass for dynamic resources (resources created
+ * programmatically).
+ *
+ * @author Jonathan Locke
+ * @author Johan Compagner
+ * @author Gili Tzabari
+ */
+public abstract class DynamicWebResource extends WebResource
+{
+ /**
+ * The resource state returned by the getResourceState() method. This
state
+ * needs to be thread-safe and its methods must return the same values
no
+ * matter how many times they are invoked. A ResourceState may assume
+ * getParameters() will remain unchanged during its lifetime.
+ *
+ * @author jcompagner
+ */
+ public static abstract class ResourceState
+ {
+ protected Time lastModifiedTime;
+
+ /**
+ * @return The Byte array for this resource
+ */
+ public abstract byte[] getData();
+
+ /**
+ * @return The content type of this resource
+ */
+ public abstract String getContentType();
+
+ /**
+ * @return The last modified time of this resource
+ */
+ public Time lastModifiedTime()
+ {
+ if (lastModifiedTime == null)
+ lastModifiedTime = Time.now();
+ return lastModifiedTime;
+ }
+
+ /**
+ * @return The length of the data
+ */
+ public int getLength()
+ {
+ byte[] data = getData();
+ return data != null ? data.length : 0;
+ }
+ }
+
+ /**
+ * The resource locale.
+ */
+ private Locale locale;
+
+ /** The filename that will be set as the Content-Disposition header. */
+ private final String filename;
+
+ /**
+ * Creates a dynamic resource.
+ */
+ public DynamicWebResource()
+ {
+ this(null,null);
+ }
+
+ /**
+ * Creates a dynamic resource.
+ *
+ * @param filename
+ * The filename that will be set as the
Content-Disposition header.
+ */
+ public DynamicWebResource(String filename)
+ {
+ this(null,filename);
+ }
+
+ /**
+ * Creates a dynamic resource from for the given locale
+ *
+ * @param locale
+ * The locale of this resource
+ */
+ public DynamicWebResource(Locale locale)
+ {
+ this(locale,null);
+ }
+ /**
+ * Creates a dynamic resource from for the given locale
+ *
+ * @param locale
+ * The locale of this resource
+ * @param filename
+ * The filename that will be set as the
Content-Disposition header.
+ */
+ public DynamicWebResource(Locale locale, String filename)
+ {
+ this.locale = locale;
+ this.filename = filename;
+ setCacheable(false);
+ }
+
+ /**
+ * @see
wicket.markup.html.WebResource#setHeaders(wicket.protocol.http.WebResponse)
+ */
+ protected void setHeaders(WebResponse response)
+ {
+ super.setHeaders(response);
+ if(filename != null)
+ {
+ response.setAttachmentHeader(filename);
+ }
+ }
+ /**
+ * Returns the resource locale.
+ *
+ * @return The locale of this resource
+ */
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ /**
+ * @return Gets the resource to attach to the component.
+ */
+ // this method is deliberately non-final. some users depend on it
+ public IResourceStream getResourceStream()
+ {
+ return new IResourceStream()
+ {
+ private static final long serialVersionUID = 1L;
+
+ private Locale locale =
DynamicWebResource.this.getLocale();
+
+ /** Transient input stream to resource */
+ private transient InputStream inputStream = null;
+
+ /**
+ * Transient ResourceState of the resources, will
always be deleted
+ * in the close
+ */
+ private transient ResourceState data = null;
+
+ /**
+ * @see wicket.util.resource.IResourceStream#close()
+ */
+ public void close() throws IOException
+ {
+ if (inputStream != null)
+ {
+ inputStream.close();
+ inputStream = null;
+ }
+ data = null;
+ }
+
+ /**
+ * @see
wicket.util.resource.IResourceStream#getContentType()
+ */
+ public String getContentType()
+ {
+ checkLoadData();
+ return data.getContentType();
+ }
+
+ /**
+ * @see
wicket.util.resource.IResourceStream#getInputStream()
+ */
+ public InputStream getInputStream() throws
ResourceStreamNotFoundException
+ {
+ checkLoadData();
+ if (inputStream == null)
+ {
+ inputStream = new
ByteArrayInputStream(data.getData());
+ }
+ return inputStream;
+ }
+
+ /**
+ * @see wicket.util.watch.IModifiable#lastModifiedTime()
+ */
+ public Time lastModifiedTime()
+ {
+ checkLoadData();
+ return data.lastModifiedTime();
+ }
+
+ /**
+ * @see wicket.util.resource.IResourceStream#length()
+ */
+ public long length()
+ {
+ checkLoadData();
+ return data.getLength();
+ }
+
+ /**
+ * @see wicket.util.resource.IResourceStream#getLocale()
+ */
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ /**
+ * @see
wicket.util.resource.IResourceStream#setLocale(java.util.Locale)
+ */
+ public void setLocale(Locale loc)
+ {
+ locale = loc;
+ }
+
+ /**
+ * Check whether the data was loaded yet. If not, load
it now.
+ */
+ private void checkLoadData()
+ {
+ if (data == null)
+ {
+ data = getResourceState();
+ }
+ }
+ };
+ }
+
+ /**
+ * Gets the byte array for our dynamic resource. If the subclass
regenerates
+ * the data, it should set the lastModifiedTime too. This ensures that
+ * resource caching works correctly.
+ *
+ * @return The byte array for this dynamic resource.
+ */
+ protected abstract ResourceState getResourceState();
+}
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/request/AbstractWebRequestCodingStrategy.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/request/AbstractWebRequestCodingStrategy.java?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/request/AbstractWebRequestCodingStrategy.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/protocol/http/request/AbstractWebRequestCodingStrategy.java
Wed Dec 20 08:22:06 2006
@@ -325,9 +325,11 @@
}
}
+ String responseRequestEncoding =
application.getRequestCycleSettings().getResponseRequestEncoding();
+
boolean firstParameter = true;
- if (!application.getHomePage().equals(pageClass) ||
!"".equals(pageMapName)
- || requestTarget instanceof
BookmarkableListenerInterfaceRequestTarget)
+ if (!application.getHomePage().equals(pageClass) ||
!"".equals(pageMapName) ||
+ (application.getHomePage().equals(pageClass) &&
requestTarget instanceof BookmarkableListenerInterfaceRequestTarget) )
{
firstParameter = false;
url.append('?');
@@ -349,35 +351,14 @@
*/
try
{
- pageClassName =
URLEncoder.encode(pageClassName, "UTF-8");
+ url.append(URLEncoder.encode(pageMapName +
Component.PATH_SEPARATOR + pageClassName,responseRequestEncoding));
}
- catch (UnsupportedEncodingException e)
+ catch (UnsupportedEncodingException ex)
{
- throw new RuntimeException(e);
+ log.error(ex.getMessage(), ex);
+ url.append(pageMapName +
Component.PATH_SEPARATOR + pageClassName);
}
- url.append(pageMapName + Component.PATH_SEPARATOR +
pageClassName);
- }
-
- // Is it a bookmarkable interface listener?
- if (requestTarget instanceof
BookmarkableListenerInterfaceRequestTarget)
- {
- BookmarkableListenerInterfaceRequestTarget
listenerTarget = (BookmarkableListenerInterfaceRequestTarget)requestTarget;
- if (firstParameter == true)
- {
- url.append("?");
- }
- else
- {
- url.append("&");
- }
- firstParameter = false;
- url.append(INTERFACE_PARAMETER_NAME);
- url.append("=");
- url.append(Component.PATH_SEPARATOR);
- url.append(listenerTarget.getComponentPath());
- url.append(Component.PATH_SEPARATOR);
- url.append(Component.PATH_SEPARATOR);
- url.append(listenerTarget.getInterfaceName());
+
}
// Get page parameters
@@ -393,8 +374,7 @@
String escapedValue = value;
try
{
- escapedValue =
URLEncoder.encode(escapedValue, application
-
.getRequestCycleSettings().getResponseRequestEncoding());
+ escapedValue =
URLEncoder.encode(escapedValue, responseRequestEncoding);
}
catch (UnsupportedEncodingException ex)
{
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/request/compound/DefaultRequestTargetResolverStrategy.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/request/compound/DefaultRequestTargetResolverStrategy.java?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/request/compound/DefaultRequestTargetResolverStrategy.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/request/compound/DefaultRequestTargetResolverStrategy.java
Wed Dec 20 08:22:06 2006
@@ -23,12 +23,16 @@
import wicket.Application;
import wicket.IRequestTarget;
+import wicket.Page;
+import wicket.PageParameters;
import wicket.RequestCycle;
import wicket.Session;
import wicket.protocol.http.request.WebErrorCodeResponseTarget;
import wicket.protocol.http.request.WebExternalResourceRequestTarget;
import wicket.request.IRequestCodingStrategy;
import wicket.request.RequestParameters;
+import
wicket.request.target.component.BookmarkableListenerInterfaceRequestTarget;
+import wicket.request.target.component.IBookmarkablePageRequestTarget;
import wicket.request.target.resource.SharedResourceRequestTarget;
import wicket.util.string.Strings;
@@ -67,7 +71,31 @@
IRequestTarget mounted =
requestCodingStrategy.targetForRequest(requestParameters);
if (mounted != null)
{
- // the path was mounted, so return that directly
+ if(mounted instanceof IBookmarkablePageRequestTarget)
+ {
+ IBookmarkablePageRequestTarget
bookmarkableTarget = (IBookmarkablePageRequestTarget)mounted;
+ // the path was mounted, so return that directly
+ if (requestParameters.getComponentPath() != null
+ &&
requestParameters.getInterfaceName() != null)
+ {
+ final String componentPath =
requestParameters.getComponentPath();
+ final Page<?> page =
Session.get().getPage(requestParameters.getPageMapName(), componentPath,
+
requestParameters.getVersionNumber());
+
+ if(page != null && page.getClass() ==
bookmarkableTarget.getPageClass())
+ {
+ return
resolveListenerInterfaceTarget(requestCycle, page, componentPath,
+
requestParameters.getInterfaceName(), requestParameters);
+ }
+ else
+ {
+ PageParameters params = new
PageParameters(requestParameters.getParameters());
+ return new
BookmarkableListenerInterfaceRequestTarget(requestParameters
+
.getPageMapName(), bookmarkableTarget.getPageClass(), params,
requestParameters.getComponentPath(),
+
requestParameters.getInterfaceName());
+ }
+ }
+ }
return mounted;
}
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/component/BookmarkableListenerInterfaceRequestTarget.java
Wed Dec 20 08:22:06 2006
@@ -23,6 +23,8 @@
import wicket.PageParameters;
import wicket.RequestCycle;
import wicket.RequestListenerInterface;
+import wicket.protocol.http.request.WebRequestCodingStrategy;
+import wicket.util.string.AppendingStringBuffer;
import wicket.util.string.Strings;
/**
@@ -37,7 +39,9 @@
private String interfaceName;
/**
- * Construct.
+ * This constructor is called when a stateless link is clicked on but
the page
+ * wasn't found in the session. Then this class will recreate the page
and call
+ * the interface method on the component that is targetted with the
component path.
*
* @param pageMapName
* @param pageClass
@@ -55,7 +59,10 @@
}
/**
- * Construct.
+ * This constructor is called for generating the urls
(RequestCycle.urlFor())
+ * So it will alter the PageParameters to include the 2 wicket params
+ * [EMAIL PROTECTED]
WebRequestCodingStrategy#BOOKMARKABLE_PAGE_PARAMETER_NAME} and
+ * [EMAIL PROTECTED] WebRequestCodingStrategy#INTERFACE_PARAMETER_NAME}
*
* @param pageMapName
* @param pageClass
@@ -64,17 +71,36 @@
* @param listenerInterface
*/
public BookmarkableListenerInterfaceRequestTarget(String pageMapName,
- Class<? extends Page> pageClass, PageParameters
pageParameters, Component component,
+ Class<? extends Page> pageClass, PageParameters
pageParameters, Component<?> component,
RequestListenerInterface listenerInterface)
{
this(pageMapName, pageClass, pageParameters,
component.getPath(),
listenerInterface.getName());
+
+ int version = component.getPage().getCurrentVersionNumber();
+
+ // add the wicket:interface param to the params.
+ AppendingStringBuffer param = new AppendingStringBuffer(3 +
componentPath.length() + interfaceName.length());
+ if(pageMapName != null)
+ {
+ param.append(pageMapName);
+ }
+ param.append(Component.PATH_SEPARATOR);
+ param.append(getComponentPath());
+ param.append(Component.PATH_SEPARATOR);
+ if(version != 0)
+ {
+ param.append(version);
+ }
+ param.append(Component.PATH_SEPARATOR);
+ param.append(getInterfaceName());
+
+
pageParameters.put(WebRequestCodingStrategy.INTERFACE_PARAMETER_NAME,param.toString());
}
- @Override
public void processEvents(RequestCycle requestCycle)
{
- Page page = getPage(requestCycle);
+ Page<?> page = getPage(requestCycle);
final String pageRelativeComponentPath =
Strings.afterFirstPathComponent(componentPath,
Component.PATH_SEPARATOR);
Component<?> component = page.get(pageRelativeComponentPath);
@@ -83,7 +109,6 @@
listenerInterface.invoke(page, component);
}
- @Override
public void respond(RequestCycle requestCycle)
{
getPage(requestCycle).renderPage();
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/resource/ResourceStreamRequestTarget.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/resource/ResourceStreamRequestTarget.java?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/resource/ResourceStreamRequestTarget.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/request/target/resource/ResourceStreamRequestTarget.java
Wed Dec 20 08:22:06 2006
@@ -195,10 +195,13 @@
* @param fileName
* Optional filename, used to set the content disposition
header.
* Only meaningful when using with web requests.
+ * @return this
+ *
*/
- public void setFileName(String fileName)
+ public ResourceStreamRequestTarget setFileName(String fileName)
{
this.fileName = fileName;
+ return this;
}
/**
Modified:
incubator/wicket/trunk/wicket/src/main/java/wicket/resource/ByteArrayResource.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/main/java/wicket/resource/ByteArrayResource.java?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/main/java/wicket/resource/ByteArrayResource.java
(original)
+++
incubator/wicket/trunk/wicket/src/main/java/wicket/resource/ByteArrayResource.java
Wed Dec 20 08:22:06 2006
@@ -22,15 +22,16 @@
import java.util.Locale;
import wicket.markup.html.WebResource;
+import wicket.protocol.http.WebResponse;
import wicket.util.resource.IResourceStream;
import wicket.util.resource.ResourceStreamNotFoundException;
import wicket.util.time.Time;
/**
* This class can be used to easy make a Resource from a predefined byte array.
- * If your data comes from a database then a DynamicWebResource is a better
- * choice. Only use this class if you have to have the byte array in memory.
- * Like a pdf that is generated on the fly.
+ * If your data comes from a database then a DynamicWebResource is a
+ * better choice. Only use this class if you have to have the byte array in
+ * memory. Like a pdf that is generated on the fly.
*
* @author Johan Compagner
*/
@@ -50,6 +51,8 @@
/** the time that this resource was last modified; same as construction
time. */
private final Time lastModified = Time.now();
+ private final String filename;
+
/**
* Creates a Resource from the given byte array with its content type
*
@@ -63,6 +66,25 @@
this.contentType = contentType;
this.array = array;
this.locale = null;
+ this.filename = null;
+ }
+
+ /**
+ * Creates a Resource from the given byte array with its content type
+ *
+ * @param contentType
+ * The Content type of the array.
+ * @param array
+ * The binary content
+ * @param filename
+ * The filename that will be set as the
Content-Disposition header.
+ */
+ public ByteArrayResource(String contentType, byte[] array, String
filename)
+ {
+ this.contentType = contentType;
+ this.array = array;
+ this.filename = filename;
+ this.locale = null;
}
/**
@@ -81,12 +103,45 @@
this.contentType = contentType;
this.array = array;
this.locale = locale;
+ this.filename = null;
}
/**
+ * Creates a Resource from the given byte array with its content type
and
+ * the locale for which it is valid.
+ *
+ * @param contentType
+ * The Content type of the array.
+ * @param array
+ * The binary content.
+ * @param locale
+ * The locale of this resource
+ * @param filename
+ * The filename that will be set as the
Content-Disposition header.
+ */
+ public ByteArrayResource(String contentType, byte[] array, Locale
locale, String filename)
+ {
+ this.contentType = contentType;
+ this.array = array;
+ this.locale = locale;
+ this.filename = filename;
+ }
+
+ /**
+ * @see
wicket.markup.html.WebResource#setHeaders(wicket.protocol.http.WebResponse)
+ */
+ protected void setHeaders(WebResponse response)
+ {
+ super.setHeaders(response);
+ if(filename != null)
+ {
+ response.setAttachmentHeader(filename);
+ }
+ }
+
+ /**
* @see wicket.Resource#getResourceStream()
*/
- @Override
public IResourceStream getResourceStream()
{
return new IResourceStream()
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/autolink/MyPageExpectedResult.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/autolink/MyPageExpectedResult.html?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/autolink/MyPageExpectedResult.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/autolink/MyPageExpectedResult.html
Wed Dec 20 08:22:06 2006
@@ -3,13 +3,13 @@
<body>
<wicket:link>
<span><em>My Page</em></span>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.autolink.PageA">Page
A</a>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.autolink.sub.PageB">Page
B</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.autolink.PageA">Page
A</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.autolink.sub.PageB">Page
B</a>
</wicket:link>
START<br>
<wicket:child><wicket:extend>
<wicket:link>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.autolink.PageA">Page
A</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.autolink.PageA">Page
A</a>
</wicket:link>
MyPage
</wicket:extend></wicket:child>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/autolink/PageAExpectedResult.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/autolink/PageAExpectedResult.html?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/autolink/PageAExpectedResult.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/autolink/PageAExpectedResult.html
Wed Dec 20 08:22:06 2006
@@ -2,9 +2,9 @@
<html>
<body>
<wicket:link>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.autolink.MyPage">My
Page</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.autolink.MyPage">My
Page</a>
<span><em>Page A</em></span>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.autolink.sub.PageB">Page
B</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.autolink.sub.PageB">Page
B</a>
</wicket:link>
START<br>
<wicket:child><wicket:extend>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/basic/SimplePageExpectedResult_12.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/basic/SimplePageExpectedResult_12.html?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/basic/SimplePageExpectedResult_12.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/basic/SimplePageExpectedResult_12.html
Wed Dec 20 08:22:06 2006
@@ -9,23 +9,23 @@
<wicket:link>
<!--[if IE]>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.basic.SimplePage_3">Link</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.basic.SimplePage_3">Link</a>
<![endif]-->
<!--[if IE 6]>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.basic.SimplePage_3">Link</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.basic.SimplePage_3">Link</a>
<![endif]-->
<!--[if gte IE 5.5]>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.basic.SimplePage_3">Link</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.basic.SimplePage_3">Link</a>
<![endif]-->
<!--[if lte IE 5.5999]>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.basic.SimplePage_3">Link</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.basic.SimplePage_3">Link</a>
<![endif]-->
<!--[if lt IE 5.1]>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.basic.SimplePage_3"
wicket:id="link">Link</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.basic.SimplePage_3"
wicket:id="link">Link</a>
<![endif]-->
<!--[if IE]>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_1.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_1.html?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_1.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_1.html
Wed Dec 20 08:22:06 2006
@@ -3,33 +3,33 @@
<title>Mock Page</title>
</head>
<body>
-<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.Page1">Home</a>
+<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.Page1">Home</a>
<wicket:link>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.Page1">Home</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.Page1">Home</a>
</wicket:link>
<wicket:link autolink="false">
<a href="/WicketTester$DummyWebApplication/Page1.html">Home</a>
</wicket:link>
<wicket:link autolink="true">
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.Page1"><span
wicket:id="myLabel">Home</span></a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.Page1"><span
wicket:id="myLabel">Home</span></a>
</wicket:link>
<wicket:link autolink="false">
<a href="/WicketTester$DummyWebApplication/Page1.html">Home</a>
<wicket:link autolink="true">
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.Page1&name=test&id=123">Home</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.Page1&name=test&id=123">Home</a>
</wicket:link>
</wicket:link>
<!-- valid till the end of the document or the next link tag -->
<wicket:link autolink="false"/>
<a href="/WicketTester$DummyWebApplication/Page1.html">Home</a>
<wicket:link autolink="true"/>
-<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.subdir.Page1">Home</a>
+<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.subdir.Page1">Home</a>
<link
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication/resources/wicket.markup.html.link.AutolinkPage_1/test_myStyle.css"/>
<link
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication/resources/wicket.markup.html.link.AutolinkPage_1/test2_myStyle.css"/>
<link
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication/resources/wicket.markup.html.link.AutolinkPage_1/test3_myStyle_de_DE.css"/>
<link
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication/resources/wicket.markup.html.link.AutolinkPage_1/../../html/link/test2_myStyle.css"/>
<a href="/root/test.html">Home</a>
-<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.Page1">Home</a>
+<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.Page1">Home</a>
<a href="http://www.google.com">Google</a>
</body>
</html>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_2.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_2.html?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_2.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_2.html
Wed Dec 20 08:22:06 2006
@@ -3,30 +3,30 @@
<title>Mock Page</title>
</head>
<body>
-<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.Page1">Home</a>
+<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.Page1">Home</a>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.Page1">Home</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.Page1">Home</a>
<a href="/WicketTester$DummyWebApplication/Page1.html">Home</a>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.Page1"><span>Home</span></a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.Page1"><span>Home</span></a>
<a href="/WicketTester$DummyWebApplication/Page1.html">Home</a>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.Page1&name=test&id=123">Home</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.Page1&name=test&id=123">Home</a>
<!-- valid till the end of the document or the next link tag -->
<a href="/WicketTester$DummyWebApplication/Page1.html">Home</a>
-<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.subdir.Page1">Home</a>
+<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.subdir.Page1">Home</a>
<link
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication/resources/wicket.markup.html.link.AutolinkPage_2/test_myStyle.css"/>
<a href="/root/test.html">Home</a>
-<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.Page1">Home</a>
+<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.Page1">Home</a>
<a href="http://www.google.com">Google</a>
</body>
</html>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_3.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_3.html?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_3.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_3.html
Wed Dec 20 08:22:06 2006
@@ -1,7 +1,7 @@
<html xmlns:wicket>
<body>
<wicket:link autolink="true">
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.XmlPage">Home</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.XmlPage">Home</a>
</wicket:link>
</body>
</html>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_4.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_4.html?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_4.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/AutolinkPageExpectedResult_4.html
Wed Dec 20 08:22:06 2006
@@ -8,7 +8,7 @@
<!-- Not sure what it should do, but it is obviously valid => Do not change
href at all -->
<a href="">Link 1</a>
<!-- Supported since 1.2 -->
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.Page1#link1">Link
1</a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.Page1#link1">Link
1</a>
<!-- Supported since 2.0 -->
<a href="Page.html?0=whatever">Link with parameter</a>
</wicket:link>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/BookmarkableHomePageLinksPage_result.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/BookmarkableHomePageLinksPage_result.html?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/BookmarkableHomePageLinksPage_result.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/BookmarkableHomePageLinksPage_result.html
Wed Dec 20 08:22:06 2006
@@ -16,6 +16,6 @@
<body>
<a href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication"
wicket:id="defaulthompage"></a>
<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?param2=test&param1=1"
wicket:id="defaulthompagewithparams"></a>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=testpagemap:wicket.util.tester.DummyHomePage"
wicket:id="defaulthompagewithpagemap"></a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=testpagemap%3Awicket.util.tester.DummyHomePage"
wicket:id="defaulthompagewithpagemap"></a>
</body>
</html>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageDefaultContextResult.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageDefaultContextResult.html?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageDefaultContextResult.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageDefaultContextResult.html
Wed Dec 20 08:22:06 2006
@@ -14,7 +14,7 @@
-->
<html>
<body>
- <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.ContextPathPage"
wicket:id="bookmarkablelink"></a>
+ <a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.ContextPathPage"
wicket:id="bookmarkablelink"></a>
<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:interface=:0:resourcelink::IResourceListener"
wicket:id="resourcelink"/>
<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:interface=:0:onclick::ILinkListener"
wicket:id="onclick"/>
</body>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageEmptyContextResult.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageEmptyContextResult.html?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageEmptyContextResult.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageEmptyContextResult.html
Wed Dec 20 08:22:06 2006
@@ -14,7 +14,7 @@
-->
<html>
<body>
- <a
href="/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.ContextPathPage"
wicket:id="bookmarkablelink"></a>
+ <a
href="/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.ContextPathPage"
wicket:id="bookmarkablelink"></a>
<a
href="/WicketTester$DummyWebApplication?wicket:interface=:0:resourcelink::IResourceListener"
wicket:id="resourcelink"/>
<a
href="/WicketTester$DummyWebApplication?wicket:interface=:0:onclick::ILinkListener"
wicket:id="onclick"/>
</body>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageRootContextResult.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageRootContextResult.html?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageRootContextResult.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/markup/html/link/ContextPathPageRootContextResult.html
Wed Dec 20 08:22:06 2006
@@ -14,7 +14,7 @@
-->
<html>
<body>
- <a
href="/root/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.markup.html.link.ContextPathPage"
wicket:id="bookmarkablelink"></a>
+ <a
href="/root/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.markup.html.link.ContextPathPage"
wicket:id="bookmarkablelink"></a>
<a
href="/root/WicketTester$DummyWebApplication?wicket:interface=:0:resourcelink::IResourceListener"
wicket:id="resourcelink"/>
<a
href="/root/WicketTester$DummyWebApplication?wicket:interface=:0:onclick::ILinkListener"
wicket:id="onclick"/>
</body>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage.java?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage.java
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage.java
Wed Dec 20 08:22:06 2006
@@ -16,6 +16,7 @@
*/
package wicket.stateless;
+import wicket.WicketRuntimeException;
import wicket.markup.html.WebPage;
import wicket.markup.html.link.StatelessLink;
@@ -38,7 +39,7 @@
@Override
public void onClick()
{
- // test
+ throw new WicketRuntimeException("wanted
exception");
}
};
Added:
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_home_result.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_home_result.html?view=auto&rev=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_home_result.html
(added)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_home_result.html
Wed Dec 20 08:22:06 2006
@@ -0,0 +1,5 @@
+<html>
+<body>
+<a
href="/WicketTester$1/WicketTester$1?wicket:bookmarkablePage=%3Awicket.stateless.StatelessComponentPage&wicket:interface=%3A0%3Alink%3A%3AILinkListener"
wicket:id="link">test</a>
+</body>
+</html>
\ No newline at end of file
Added:
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_mount_result.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_mount_result.html?view=auto&rev=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_mount_result.html
(added)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_mount_result.html
Wed Dec 20 08:22:06 2006
@@ -0,0 +1,5 @@
+<html>
+<body>
+<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication/stateless/wicket:interface/%3A0%3Alink%3A%3AILinkListener"
wicket:id="link">test</a>
+</body>
+</html>
\ No newline at end of file
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_result.html
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_result.html?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_result.html
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentPage_result.html
Wed Dec 20 08:22:06 2006
@@ -1,5 +1,5 @@
<html>
<body>
-<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.stateless.StatelessComponentPage&wicket:interface=:0:link::ILinkListener"
wicket:id="link">test</a>
+<a
href="/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=%3Awicket.stateless.StatelessComponentPage&wicket:interface=%3A0%3Alink%3A%3AILinkListener"
wicket:id="link">test</a>
</body>
</html>
Modified:
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentTest.java
URL:
http://svn.apache.org/viewvc/incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentTest.java?view=diff&rev=489132&r1=489131&r2=489132
==============================================================================
---
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentTest.java
(original)
+++
incubator/wicket/trunk/wicket/src/test/java/wicket/stateless/StatelessComponentTest.java
Wed Dec 20 08:22:06 2006
@@ -17,6 +17,7 @@
package wicket.stateless;
import wicket.WicketTestCase;
+import wicket.util.tester.WicketTester;
/**
* @author jcompagner
@@ -32,12 +33,68 @@
{
super(name);
}
-
+
+ /**
+ * @throws Exception
+ */
+ public void testStatelessComponentPageWithHomePage() throws Exception
+ {
+ tester = new WicketTester(StatelessComponentPage.class);
+ executeTest(StatelessComponentPage.class,
"StatelessComponentPage_home_result.html");
+
+ tester.setupRequestAndResponse();
+
tester.getServletRequest().setURL("/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.stateless.StatelessComponentPage&wicket:interface=:0:link::ILinkListener");
+ try
+ {
+ tester.processRequestCycle();
+ assertTrue(false);
+ }
+ catch (Exception e)
+ {
+ assertEquals(e.getMessage(),"wanted exception");
+ }
+
+ }
/**
* @throws Exception
*/
public void testStatelessComponentPage() throws Exception
- {
- executeTest(StatelessComponentPage.class,
"StatelessComponentPage_result.html");
- }
+ {
+ executeTest(StatelessComponentPage.class,
"StatelessComponentPage_result.html");
+
+ tester.setupRequestAndResponse();
+
tester.getServletRequest().setURL("/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication?wicket:bookmarkablePage=:wicket.stateless.StatelessComponentPage&wicket:interface=:0:link::ILinkListener");
+ try
+ {
+ tester.processRequestCycle();
+ assertTrue(false);
+ }
+ catch (Exception e)
+ {
+ assertEquals(e.getMessage(),"wanted exception");
+ }
+
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testStatelessComponentPageWithMount() throws Exception
+ {
+ tester.getApplication().mountBookmarkablePage("/stateless",
StatelessComponentPage.class);
+
+ executeTest(StatelessComponentPage.class,
"StatelessComponentPage_mount_result.html");
+ tester.setupRequestAndResponse();
+
tester.getServletRequest().setURL("/WicketTester$DummyWebApplication/WicketTester$DummyWebApplication/stateless/wicket:interface/:0:link::ILinkListener");
+ try
+ {
+ tester.processRequestCycle();
+ assertTrue(false);
+ }
+ catch (Exception e)
+ {
+ assertEquals(e.getMessage(),"wanted exception");
+ }
+ }
+
}