Class WicketMessageResolver

  extended by org.apache.wicket.markup.resolver.WicketMessageResolver
All Implemented Interfaces:
Serializable, IClusterable, IComponentResolver

public class WicketMessageResolver
extends Object
implements IComponentResolver

This is a tag resolver which handles <wicket:message key="myKey">Default Text</wicket:message>. The resolver will replace the whole tag with the message found in the properties file associated with the Page. If no message is found, the default body text will remain.

You can also nest child components inside a wicket:message and then reference them from the properties file. For example in the html

     <wicket:message key="myKey">
        This text will be replaced with text from the properties file.
        <span wicket:id="amount">[amount]</span>.
        <a wicket:id="link">
            <wicket:message key="linkText"/>
Then in the properties file have a variable with a name that matches the wicket:id for each child component. The variables can be in any order, they do NOT have to match the order in the HTML file.
     myKey=Your balance is ${amount}. Click ${link} to view the details.
And in the java
 add(new Label("amount", new Model<String>("$5.00")));
 add(new BookmarkablePageLink("link", DetailsPage.class));
This will output
 Your balance is $5.00. Click <a href="#">here</a> to view the details.
If variables are not found via child component, the search will continue with the parents container model object and if still not found with the parent container itself. It is possible to switch between logging a warning and throwing an exception if either the property key/value or any of the variables can not be found.

Juergen Donnerstag, John Ray
See Also:
Serialized Form

Constructor Summary
Method Summary
 boolean resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag)
          Try to resolve the tag, then create a component, add it to the container and render it.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public WicketMessageResolver()
Method Detail


public boolean resolve(MarkupContainer container,
                       MarkupStream markupStream,
                       ComponentTag tag)
Try to resolve the tag, then create a component, add it to the container and render it.

Specified by:
resolve in interface IComponentResolver
container - The container parsing its markup
markupStream - The current markupStream
tag - The current component tag while parsing the markup
true, if componentId was handle by the resolver. False, otherwise
See Also:
IComponentResolver.resolve(MarkupContainer, MarkupStream, ComponentTag)

Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.