org.apache.wicket.model
Class ResourceModel

java.lang.Object
  extended by org.apache.wicket.model.AbstractReadOnlyModel<String>
      extended by org.apache.wicket.model.ResourceModel
All Implemented Interfaces:
Serializable, IClusterable, IComponentAssignedModel<String>, IDetachable, IModel<String>

public class ResourceModel
extends AbstractReadOnlyModel<String>
implements IComponentAssignedModel<String>

A model that represents a localized resource string. This is a lightweight version of the StringResourceModel. It lacks parameter substitutions, but is generally easier to use.

If you don't use this model as primary component model (you don't specify it in component constructor and don't assign it to component using Component.setDefaultModel(IModel)), you will need to connect the model with a component using wrapOnAssignment(Component).

Author:
Igor Vaynberg (ivaynberg)
See Also:
Serialized Form

Constructor Summary
ResourceModel(String resourceKey)
          Constructor
ResourceModel(String resourceKey, String defaultValue)
          Constructor
 
Method Summary
 String getObject()
          Gets the model object.
 IWrapModel<String> wrapOnAssignment(Component component)
          This method is called when the component gets its model assigned.
 
Methods inherited from class org.apache.wicket.model.AbstractReadOnlyModel
detach, getObject, setObject, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.wicket.model.IModel
setObject
 
Methods inherited from interface org.apache.wicket.model.IDetachable
detach
 

Constructor Detail

ResourceModel

public ResourceModel(String resourceKey)
Constructor

Parameters:
resourceKey - key of the resource this model represents

ResourceModel

public ResourceModel(String resourceKey,
                     String defaultValue)
Constructor

Parameters:
resourceKey - key of the resource this model represents
defaultValue - value that will be returned if resource does not exist
Method Detail

getObject

public String getObject()
Description copied from interface: IModel
Gets the model object.

Specified by:
getObject in interface IModel<String>
Specified by:
getObject in class AbstractReadOnlyModel<String>
Returns:
The model object
See Also:
AbstractReadOnlyModel.getObject()

wrapOnAssignment

public IWrapModel<String> wrapOnAssignment(Component component)
Description copied from interface: IComponentAssignedModel
This method is called when the component gets its model assigned. WARNING: Because the model can be assigned in the constructor of component this method can also be called with a 'this' of a component that is not fully constructed yet.

Specified by:
wrapOnAssignment in interface IComponentAssignedModel<String>
Returns:
The WrapModel that wraps this model
See Also:
IComponentAssignedModel.wrapOnAssignment(org.apache.wicket.Component)


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