Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

WICKET-2213: At the very beginning of Wicket we introduced FormComponent.setPersistence() with the idea to make creating Login panels very easy. Basically Wicket would deal with the Cookie handling for the login details. Now some years later it is evident that this feature is not very useful:

  • It basically is used for login panels only
  • Even in our examples Password.setPersistence is false which means that "rememberMe" doesn't really work. Only the user name is stored in a Cookie
  • Forcing formComponent.getPageRelativePath() as the Cookie name is too restrictive
  • You can not combine username and password into a single Cookie and e.g. decrypt it for safety reasons

So we removed that feature and introduced IAuthenticationStrategy. A default implementation has been provided and the examples have been updated. As usual it gets registered with ISecuritySettings.

...

Code Block
public StringResourceModel(final String resourceKey, final Component component,
	final IModel<?> model, final Object... parameters)

Wiki MarkupWhere the Object\[\] array is matched to the first parameter of the ellipsis and the defaultValue as the second parameter.

StringResourceModel#setLocalizer() was removed, if needed you can override #getLocalizer() instead.

...

We changed that to getStyle() now returning style only which as a consequence required us to change all resource related APIs to add variation. To migrate your code you might either provide component.getVariation() or null where not relevant.

Removed magic from Border Component

We had several issues with Border such as WICKET-2494 and WICKET-3702 the fact that all over core you could find code such as "if (comp instanceof Border) {}" . That is now all fixed, though at a (low) price. Because the magic is now gone, we think it is even clearer than it was before. The difference is you have to tell Border where to add the child component. Whether it will be added to <wicket:border>..</wicket:border> which is called the "border", or <span wicket:id="myBorder">..</span> which called the "border body". And because the body can be wrapped by a container such as a Form, you need to add (move) the body to the wrapper component via wrapper.add(getBodyContainer()) if needed. By doing so you create a clean component hierarchy with no more magic and ambiguities and transparent resolvers.

Component.getMarkupId() implementation changed

If an "id" attribute is specified in a component's markup, it is now used verbatim instead of being replaced with a unique, generated value. During your migration, verify that your setOutputMarkupId(true) components don't have "id" attributes. Otherwise multiple component instances will share the same markup ID, breaking AJAX updates.

Removed magic from Border Component

We had several issues with Border such as WICKET-2494 and WICKET-3702 the fact that all over core you could find code such as "if (comp instanceof Border) {}" . That is now all fixed, though at a (low) price. Because the magic is now gone, we think it is even clearer than it was before. The difference is you have to tell Border where to add the child component. Whether it will be added to <wicket:border>..</wicket:border> which is called the "border", or <span wicket:id="myBorder">..</span> which called the "border body". And because the body can be wrapped by a container such as a Form, you need to add (move) the body to the wrapper component via wrapper.add(getBodyContainer()) if needed. By doing so you create a clean component hierarchy with no more magic and ambiguities and transparent resolvers.

border.addToBorder() will add to the border, while border.add() is a convenient border.addToBorder() will add to the border, while border.add() is a convenient and explicit alias for border.getBodyContainer().add()

...

AbstractSingleSelectChoice now uses an empty String instead of NO_SELECTION_VALUE ("-1"), allowing negative values for choices. See WICKET-933.

AbstractChoice.setType() now throws an UnsupportedOperationException as type-conversion is performed by the assigned IChoiceRenderer. See WICKET-3745.

Component rendering

We used to have different entry points to render a Page, a Component for a web request and a Component for an AJAX request. That is history. Whenever you want to render a component, simply call component.render().

...

  • ITab.getPanel() now returns WebMarkupContainerWithAssociatedMarkup instead of Panel so it is now possible to create tabs using Fragments or Panels rather then just Panels.
  • TabbedPanel.setSelectedTab() is now chainable
  • TabbedPanel now takes a List<? extends ITab> rather then List<ITab>

MarkupContainer.isTransparentResolver() removed

Wizard

  • Wizard no longer invokes IWizardStep#init(IWizardModel), this is now the responsibility of the IWizardModel itself. WizardModel and DynamicWizardModel do it already, but you have to take care of this for yourself if you have a custom IWizardModel implementation.

MarkupContainer.isTransparentResolver() removed

We removed MarkupContainer.isTransparentResolver() in We removed MarkupContainer.isTransparentResolver() in favor of the more general IComponentResolver. To mitigate the transition, we provide a TransparentWebMarkupContainer. But please note it does not solve all use cases isTransparentResolver() did.

...

Code Block
formComponent.visitChildren(Radio.class, new IVisitor<Component, Void>()
{
	public void /*[1]*/ component(final Component component, final IVisit<Void> visit /*[2]*/)
	{
		if (value.equals(component.getDefaultModelObject()))
		{
			addFormComponentValue(formComponent,((Radio<?>)component).getValue());
			visit.stop(); /*[3]*/
		}
		else
		{
			visit.dontGoDeeper(); /*[4]*/
		}
	}
});

...

\[1\] The new style visitor no longer returns a value, instead the value can be returned using visit.stop(value) \
[2\] The new visit object is introduced to control the visitor traversal \
[3\] Instead of relying on magic return values the traversal is stopped by using the new visit object \
[4\] Same as \ [3\] but a different method on IVisit is used

Component Initialization - Component#onInitialize

...

Code Block
   StringValue parameterValue = RequestCycle.get().getRequest().getRequestParameters().getParameterValue(parameterName);

...

Page mounting

In 1.4 a custom IRequestCycleProcessor is needed.x the parameters of mounted pages where encoded in the path of the URL by default:

Code Block
public class MyApplication extends WebApplication
{
 	@Override
 	protected IRequestCycleProcessor newRequestCycleProcessor()
  	{
  		return new HttpsRequestCycleProcessor(new HttpsConfig());
  	}
}
 http://server/mount/path/parameter1/value1/parameter2/value2

But now pages are mounted with MountedMapper instead, which leads to the following URLs:

Code Block

   http://server/mount/path?parameter1=value1&parameter2=value2

To get the previous 1.4.x URLs you have to configure the mapper with a UrlPathPageParametersEncoder:

Code Block

   mount(new MountedMapper("/mount/path", MyPage.class,
			new UrlPathPageParametersEncoder()));

See Request mapping#MountedMapper for further mount options.

Switching to/from secured communication over https

In 1.4 a custom IRequestCycleProcessor is needed:

Code Block

public class MyApplication extends WebApplication
{
 	@Override
 	protected IRequestCycleProcessor newRequestCycleProcessor()
  	{
  		return new HttpsRequestCycleProcessor(new HttpsConfig());
  	}
}

In 1.5 this In 1.5 this is re-implemented with the new HttpsMapper:

...

In Wicket 1.4 it was needed to extend org.apache.wicket.RequestCycle.onRuntimeException(Page, RuntimeException).
Wicket 1.5 gives even better control, by overriding :

  • add your own org.apache.wicket.request.

...

  • cycle.

...

  • IRequestCycleListener (

...

  • AbstractRequestCycleListener) with org.apache.wicket.Application.getRequestCycleListeners().add() and implement its #onException(RequestCycle, Exception)
  • or override org.apache.wicket.Application.getExceptionMapperProvider() - the IExceptionMapper is used if none of the configured IRequestCycleListeners doesn't know how to handle the exception.
    For information on how the request cycle handles exceptions see RequestCycle in Wicket 1.5 for more information

ImageMap removed

ImageMap was deprecated in 1.4.11 and in 1.5 it was replaced with ClientSideImageMap component

...

Basically the caching strategy will decorate the package resource with a version-dependendant invariantfingerprint.

The default caching strategy in development and production mode is

...

  • resource caching strategy that adds a version for the
  • requested resource to the filename.
  •  
  • Wiki Markupversioned_filename := \ [basename\]\[version-prefix\]\[version\](.extension)
  •  

Wiki MarkupIn development mode the&nbsp;\mode the [version\] string is be last modified timestamp of the resource in UNIX milliseconds. If the resource resides in a jar the timestamp of the jar file will be taken instead.

Wiki MarkupIn production mode the MD5 hash of the file content will be calculated and taken as \ [version\]. The calculation will be done once and then be cached for the lifetime of the application. We decided against choosing the last modified timestamp in deployment mode since it seems to be inconsistent in some cluster setups.

Example:

basename

styles.css

last-modified

1303741587000

md5-checksum

F1336A3F160F1399ECF87B6196AB1C2A

decorated-filename-in-development-mode

styles-ver-1303741587000.css

decorated-filename-in-deployment-mode

styles-ver-F1336A3F160F1399ECF87B6196AB1C2A.css

...

Code Block
/**
 * Objects that can send events
 *
 * @author Igor Vaynberg (ivaynberg)
 */
public interface IEventSource
{
	/**
	 * Sends an event
	 *
	 * @param <T>
	 *            tyeptype of payload
	 *
	 * @param sink
	 *            object that will receive the event
	 * @param broadcast
	 *            if the object that receives the event needs to broadcast it to others, this is the
	 *            type of broadcast that should be used
	 * @param payload
	 *            event payload
	 */
	<T> void send(IEventSink sink, Broadcast broadcast, T payload);
}

...

In 1.5, you use

Code Block
     <dependency>
      	<groupId>org.wicketstuff</groupId>
      <artifactId>jslibraries</artifactId>
      	<artifactId>wicketstuff-jslibraries</artifactId>
	<version>1.5-RC5.1<8</version>
     </dependency>

And do something like this:

...

In case the markup file contains an xml decl such as <?xml version="1.0" encoding="utf-8" ?>, it'll only be used for properly reading the markup. It'll never be used for the response and it's presence or absence will no longer determine whether an xml decl gets added to the response or not.

The response encoding is determined via Application.getRequestSettings().getResponseRequestEncoding() and applies for all your pages.

WebPage.renderXmlDecl(response) and WebApplication.renderXmlDecl(response) have been introduced to control the xml decl contribution. The behavior can be changed per Page or for your whole application. It can generally be enabled, disabled or determined via a rule. The rule currently is simple: if the page mime-type is application/xhtml+xml and the HTTP_ACCEPT header allows for the same, then insert the xml decl.same, then insert the xml decl.

Redirect to non wicket or external page.

Now when you need to redirect to a non Wicket managed URL or external link you can use RedirectRequestHandler instead of

Old code

Code Block

  getRequestCycle().setRequestTarget(new RedirectRequestTarget("/usage.html"));

  // or
  page.getRequestCycle().setRequestTarget(new RedirectRequestTarget("http://www.facebook.com/"));

And post 1.5 version:

Code Block

  getRequestCycle().scheduleRequestHandlerAfterCurrent(new RedirectRequestHandler("/usage.html"));

  // or
  page.getRequestCycle().scheduleRequestHandlerAfterCurrent(new RedirectRequestHandler("http://www.facebook.com/"));

(RC5) Pluggable serialization

...

Following the renames in subclasses is easier if the @Override annotations are present. IDE-s, like Eclipse, can be used to add missing @Override annotations before moving to wicket 1.5.

1.4

1.5

org.apache.wicket.request.resource.ResourceReference

org.apache.wicket.request.resource.PackageResourceReference

org.apache.wicket.RedirectToUrlException

org.apache.wicket.request.flow.RedirectToUrlException

org.apache.wicket.Request

org.apache.wicket.request.Request

org.apache.wicket.RequestCycle

org.apache.wicket.request.cycle.RequestCycle

org.apache.wicket.RequestCycle.urlFor

org.apache.wicket.request.cycle.RequestCycle.renderUrlFor urlFor

org.apache.wicket.util.lang.Objects.cloneObject(Object)

org.apache.wicket.util.lang.WicketObjects.cloneObject(Object)

org.apache.wicket.protocol.http.WebRequest

org.apache.wicket.request.http.WebRequest

org.apache.wicket.protocol.http.WebResponse

org.apache.wicket.request.http.WebResponse

org.apache.wicket.request.target.basic.RedirectRequestTarget

RedirectRequestHandler

org.apache.wicket.request.target.coding.QueryStringUrlCodingStrategy

use PageParameters.getNamedParameter(String) with any IRequestHandler

org.apache.wicket.request.target.resource.ResourceStreamRequestTarget

import org.apache.wicket.request.handler.resource.ResourceStreamRequestHandler

org.apache.wicket.request.http.WebRequest.getHttpServletRequest()

org.apache.wicket.protocol.http.servlet.ServletWebRequest.getContainerRequest()

org.apache.wicket.protocol.http.WebApplication.newWebResponse(final HttpServletResponse)

(missing)

org.apache.wicket.Application.set(Application)

org.apache.wicket.ThreadContext.setApplication(Application)

org.apache.wicket.protocol.http.BufferedWebResponse.BufferedWebResponse(HttpServletResponse)

org.apache.wicket.protocol.http.BufferedWebResponse.BufferedWebResponse(WebResponse)

org.apache.wicket.PageParameters

org.apache.wicket.request.mapper.parameter.PageParameters

org.apache.wicket.PageParameters.put(String, String)

org.apache.wicket.request.mapper.parameter.PageParameters.set(String, Object)

org.apache.wicket.PageParameters.getInt(String)

org.apache.wicket.request.mapper.parameter.PageParameters.get(String).toInt()

org.apache.wicket.protocol.http.HttpSessionStore

org.apache.wicket.session.HttpSessionStore

org.apache.wicket.protocol.http.WebApplication.newSessionStore()

(missing, HttpSessionStore is the only supported)

org.apache.wicket.markup.html.resources.CompressedResourceReference org.apache.wicket.request.resource.CompressedResourceReference

Removed (see above)

org.apache.wicket.markup.html.resources.JavascriptResourceReference

org.apache.wicket.request.resource.JavascriptResourceReference

org.apache.wicket.markup.html.image.Image.Image(String)

(this constructor is protected in 1.5, as replacement can be used NonCachingImage(String))

org.apache.wicket.markup.html.image.resource.DynamicImageResource

org.apache.wicket.request.resource.DynamicImageResource

org.apache.wicket.util.convert.ConverterLocator

org.apache.wicket.ConverterLocator

org.apache.wicket.util.lang.Objects

org.apache.wicket.util.lang.WicketObjects

org.apache.wicket.protocol.http.WebApplication.sessionDestroyed(String)

org.apache.wicket.protocol.http.WebApplication.sessionUnbound.sessionUnbound(String)

org.apache.wicket.protocol.https.HttpsRequestCycleProcessor

org.apache.wicket.protocol.https.HttpsMapper

org.apache.wicket.protocol.http.WebRequestCycle.newBrowserInfoPage(String)

org.apache.wicket.protocol.http.WebSession.newBrowserInfoPage(String)

org.apache.wicket.protocol.http.httpsWebRequestCycle.HttpsRequestCycleProcessor getClientInfo()

org.apache.wicket.protocol.http.httpsWebSession.HttpsMapper getClientInfo()

org.apache.wicket.protocol.http.WebRequestCycleWebApplication.newBrowserInfoPagenewWebRequest(StringHttpServletRequest)

org.apache.wicket.protocol.http.WebSessionWebApplication.newBrowserInfoPagenewWebRequest(HttpServletRequest, String)

org.apache.wicket.protocol.http.WebApplication.newWebRequestnewWebResponse(HttpServletRequestHttpServletResponse)

org.apache.wicket.protocol.http.WebApplication.newWebRequestnewWebResponse(HttpServletRequest, StringHttpServletResponse)

org.apache.wicket.protocol.http.WebApplication.newWebResponsemount(HttpServletResponseString, Class)

org.apache.wicket.protocol.http.WebApplication.newWebResponsemountPage(HttpServletRequestString, HttpServletResponseClass)

org.apache.wicket.protocol.http.WebApplication.mountBookmarkablePage(String, Class)

org.apache.wicket.protocol.http.WebApplication.mountPage(String, Class)

org.apache.wicket.resource.loader.IStringResourceLoader.loadStringResource(Component, String)

org.apache.wicket.resource.loader.IStringResourceLoader.loadStringResource(Component, String, Locale, String, String)

org.apache.wicket.ajax.IAjaxCallDecorator.decorateScript(CharSequence)

org.apache.wicket.ajax.IAjaxCallDecorator.decorateScript(Component, CharSequence)

org.apache.wicket.IResponseFilter (and all default implementations)

org.apache.wicket.response.filter.IResponseFilter

org.apache.wicket.markup.html.form.Form.process()

org.apache.wicket.markup.html.form.Form.process(IFormSubmittingComponent)

org.apache.wicket.Application.addComponentInstantiationListener()

org.apache.wicket.Application.getComponentInstantiationListeners().add() org.apache.wicket.markup.html.DynamicWebResource

org.apache.wicket.request.resource.ByteArrayResource <ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d3cb78a4-ae45-4913-b65e-07e26cc296d3"><ac:plain-text-body><![CDATA[.apache.wicket.markup.html.DynamicWebResource

org.apache.wicket.request.resource.ByteArrayResource

org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable.DataTable(String, IColumn<T>[], IDataProvider<T>, int)

org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable.DataTable(String, List<IColumn<T>>, IDataProvider<T>, int) ]]></ac:plain-text-body></ac:structured-macro>

org.apache.wicket.validation.IValidatorAddListener

Validator.bind(Component)

org.apache.wicket.behavior.AbstractBehavior.renderHead(IHeaderResponse)

org.apache.wicket.behavior.Behavior.renderHead(Component, IHeaderResponse)

org.apache.wicket.protocol.http.request.CryptedUrlWebRequestCodingStrategy

org.apache.wicket.request.mapper.CryptoMapper

org.apache.wicket.util.template.PackagedTextTemplate

org.apache.wicket.util.template.PackageTextTemplate

org.apache.wicket.extensions.ajax.markup.html.repeater.data.sort.AjaxFallbackOrderByLink.onAjaxClick(AjaxRequestTarget)

org.apache.wicket.extensions.ajax.markup.html.repeater.data.sort.AjaxFallbackOrderByLink.onClick(AjaxRequestTarget)

org.apache.wicket.util.file.IFileUploadCleaner

org.apache.wicket.util.file.IFileCleaner

org.apache.wicket.markup.html.WebPage.configureResponse()

WebPage.configureResponse(WebResponse)

Page.onPageAttached()

IRequestCycleListener.onRequestTargetResolved -> if (handler instanceof IPageRequestHandler)