org.springframework.extensions.webscripts
Class ScriptModelObject

java.lang.Object
  extended by org.springframework.extensions.webscripts.ScriptBase
      extended by org.springframework.extensions.webscripts.ScriptModelObject
All Implemented Interfaces:
Serializable

public final class ScriptModelObject
extends ScriptBase

Provides a write-able model object wrapper to the script engine. The properties of this object are writeable which means that the developer has the option to use either the properties array or explicit methods. The following commands are equivalent: myObject.properties.title = "abc"; myObject.properties["title"] = "abc"; myObject.setProperty("title", "abc"); Note: The index on the properties array is not supported. Thus, a command such as this: myObject.properties[0] = "abc"; will no-op and do nothing. The following is available for working with resources: var resources = myObject.resources;

Author:
muzquiano
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.springframework.extensions.webscripts.ScriptBase
context, properties
 
Constructor Summary
ScriptModelObject(RequestContext context, ModelObject modelObject)
          Instantiates a new script model object.
 
Method Summary
protected  ScriptableMap buildProperties()
           
 ScriptModelObject clone()
          Creates a clone of this model object
 ScriptModelObject clone(String newObjectId)
          Creates a clone of this model object The provided is to set as the new id of the object
 void delete()
          Deletes the object
 boolean getBooleanProperty(String propertyName)
          Gets the boolean property.
 String getDescription()
          Gets the description.
 String getDescriptionId()
          Gets the description id.
 String getId()
          Gets the id.
 ModelObject getModelObject()
          Returns the model object
 String getPersisterId()
          Gets the persister id.
 String getProperty(String propertyName)
          Gets the property.
 ScriptResources getResources()
           
 String getStoragePath()
          Gets the storage path.
 long getTimestamp()
          Gets the timestamp.
 String getTitle()
          Gets the title.
 String getTitleId()
          Gets the title id.
 String getTypeId()
          Gets the type id for the underlying model object
 void remove()
          Removes the object
 void removeProperty(String propertyName)
          Removes the property.
 void save()
          Persist the object and all modified properties.
 void setDescription(Serializable value)
          Sets the description.
 void setDescriptionId(Serializable value)
          Sets the description id.
 void setId(String id)
          Sets the id.
 void setProperty(String propertyName, String propertyValue)
          Sets the property.
 void setTitle(Serializable value)
          Sets the title.
 void setTitleId(Serializable value)
          Sets the title id.
 void touch()
          Touches the object.
 String toXML()
          To xml.
 
Methods inherited from class org.springframework.extensions.webscripts.ScriptBase
getConfig, getModel, getObject, getProperties, getRequestContext, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScriptModelObject

public ScriptModelObject(RequestContext context,
                         ModelObject modelObject)
Instantiates a new script model object.

Parameters:
context - the request context
modelObject - the model object
Method Detail

buildProperties

protected ScriptableMap buildProperties()
Specified by:
buildProperties in class ScriptBase

getId

public String getId()
Gets the id.

Returns:
the id

setId

public void setId(String id)
Sets the id.

Parameters:
id - the new id

getTypeId

public String getTypeId()
Gets the type id for the underlying model object

Returns:
the type id

getTitle

public String getTitle()
Gets the title.

Returns:
the title

setTitle

public void setTitle(Serializable value)
Sets the title.

Parameters:
value - the new title

getTitleId

public String getTitleId()
Gets the title id.

Returns:
the title id

setTitleId

public void setTitleId(Serializable value)
Sets the title id.

Parameters:
value - the new title id

getDescription

public String getDescription()
Gets the description.

Returns:
the description

getDescriptionId

public String getDescriptionId()
Gets the description id.

Returns:
the description id

setDescriptionId

public void setDescriptionId(Serializable value)
Sets the description id.

Parameters:
value - the new description id

setDescription

public void setDescription(Serializable value)
Sets the description.

Parameters:
value - the new description

getTimestamp

public long getTimestamp()
Gets the timestamp.

Returns:
the timestamp

getPersisterId

public String getPersisterId()
Gets the persister id.

Returns:
the persister id

getStoragePath

public String getStoragePath()
Gets the storage path.

Returns:
the storage path

getResources

public ScriptResources getResources()

save

public void save()
Persist the object and all modified properties.


remove

public void remove()
Removes the object


delete

public void delete()
Deletes the object


toXML

public String toXML()
To xml.

Returns:
the string

touch

public void touch()
Touches the object. This set its timestamp to the current time.


getBooleanProperty

public boolean getBooleanProperty(String propertyName)
Gets the boolean property.

Parameters:
propertyName - the property name
Returns:
the boolean property

getProperty

public String getProperty(String propertyName)
Gets the property.

Parameters:
propertyName - the property name
Returns:
the property

setProperty

public void setProperty(String propertyName,
                        String propertyValue)
Sets the property.

Parameters:
propertyName - the property name
propertyValue - the property value

removeProperty

public void removeProperty(String propertyName)
Removes the property.

Parameters:
propertyName - the property name

getModelObject

public ModelObject getModelObject()
Returns the model object

Returns:

clone

public ScriptModelObject clone()
Creates a clone of this model object

Overrides:
clone in class Object

clone

public ScriptModelObject clone(String newObjectId)
Creates a clone of this model object The provided is to set as the new id of the object



Copyright © 2009 SpringSource, Inc. All Rights Reserved.