Package org.apache.wicket.model
Class ResourceModel
- java.lang.Object
-
- org.apache.wicket.model.ResourceModel
-
- All Implemented Interfaces:
Serializable
,IComponentAssignedModel<String>
,IDetachable
,IModel<String>
,IClusterable
public class ResourceModel extends Object implements IComponentAssignedModel<String>
A model that represents a localized resource string. This is a lightweight version of theStringResourceModel
. 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 usingwrapOnAssignment(Component)
.- Author:
- Igor Vaynberg (ivaynberg)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ResourceModel(String resourceKey)
ConstructorResourceModel(String resourceKey, String defaultValue)
ConstructorResourceModel(String resourceKey, IModel<String> defaultValue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getObject()
Gets the model object.void
setObject(String object)
Sets the model object.IWrapModel<String>
wrapOnAssignment(Component component)
This method is called when the component gets its model assigned.
-
-
-
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 representsdefaultValue
- value that will be returned if resource does not exist
-
ResourceModel
public ResourceModel(String resourceKey, IModel<String> defaultValue)
-
-
Method Detail
-
getObject
public String getObject()
Description copied from interface:IModel
Gets the model object.
-
setObject
public final void setObject(String object)
Description copied from interface:IModel
Sets the model object.
-
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 interfaceIComponentAssignedModel<String>
- Returns:
- The WrapModel that wraps this model
-
-