br.com.arsmachina.tapestrycrud.base
Class BaseListPage<T,K extends Serializable>

java.lang.Object
  extended by br.com.arsmachina.tapestrycrud.base.BasePage<T,K>
      extended by br.com.arsmachina.tapestrycrud.base.BaseListPage<T,K>
Type Parameters:
T - the entity class related to this encoder.
K - the type of the class' primary key property.
All Implemented Interfaces:
CrudPage<T,K>

public abstract class BaseListPage<T,K extends Serializable>
extends BasePage<T,K>

Base class for pages that list entity objects. The object property is meant to be used as the row parameter of the Grid component. One example of its use can be found in the Ars Machina Project Example Application (page class. template).

Author:
Thiago H. de Paula Figueiredo

Constructor Summary
BaseListPage()
          Single constructor of this class.
 
Method Summary
protected  boolean canRemove(T object)
          Tells if a given object can be removed in this context.
 BeanModel<T> getBeanModel()
          Adds an action property to the BeanModel.
 T getObject()
          Returns the value of the object property.
 Object getObjects()
          Method used as the source parameter of the Grid component.
protected
<X,Y extends Serializable>
PrimaryKeyEncoder<Y,X>
getPrimaryKeyEncoder(Class<X> clasz)
          Returns the configured PrimaryKeyEncoder for a given entity class.
protected  Object remove(EventContext context)
          This method listens to the Constants.REMOVE_OBJECT_ACTION event and removes the corresponding object.
protected  Object remove(T object)
          Removes or not a given object.
protected  Object returnFromDoRemove()
          Defines what #doRemove() will return.
 void setObject(T object)
          Changes the value of the object property.
protected  void setRemoveErrorNotAllowedMessage()
          Sets the remove not done because of lack of priviledge message in this page.
protected  void setRemoveErrorNotFoundMessage()
          Sets the remove not done because object not found in this page.
protected  void setRemoveSuccessMessage()
          Sets the remove success message in this page.
 
Methods inherited from class br.com.arsmachina.tapestrycrud.base.BasePage
filterReadOnlyComponentsInBeanModel, getActivationContextEncoder, getController, getEntityClass, getFormZone, getLabelEncoder, getMessage, getMessages, getPrimaryKeyClass, getSelectModelFactory, getValueEncoder, returnZoneOnXHR, setMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseListPage

public BaseListPage()
Single constructor of this class.

Method Detail

getObjects

@Cached
public Object getObjects()
Method used as the source parameter of the Grid component. This implementation returns new ControllerGridDataSource(getController()).

Returns:
an Object.

getObject

public T getObject()
Returns the value of the object property.

Returns:
a T.

setObject

public void setObject(T object)
Changes the value of the object property.

Parameters:
object - a T.

getBeanModel

public BeanModel<T> getBeanModel()
Adds an action property to the BeanModel.

See Also:
br.com.arsmachina.tapestrycrud.base.BasePage#getBeanModel()

remove

protected final Object remove(T object)
Removes or not a given object. This method only removes an object, using getController().delete(id), if canRemove(K) returns true.

Parameters:
object - a K.

returnFromDoRemove

protected Object returnFromDoRemove()
Defines what #doRemove() will return.

Returns:
an Object or null.

setRemoveSuccessMessage

protected void setRemoveSuccessMessage()
Sets the remove success message in this page.


setRemoveErrorNotAllowedMessage

protected void setRemoveErrorNotAllowedMessage()
Sets the remove not done because of lack of priviledge message in this page.


setRemoveErrorNotFoundMessage

protected void setRemoveErrorNotFoundMessage()
Sets the remove not done because object not found in this page.


canRemove

protected boolean canRemove(T object)
Tells if a given object can be removed in this context. It must be overriden if you have some rules about when an object can be removed. This implementation just returns true.

Parameters:
object - a #T.
Returns:
a boolean.

remove

@OnEvent(value="removeObject")
protected Object remove(EventContext context)
This method listens to the Constants.REMOVE_OBJECT_ACTION event and removes the corresponding object.

Parameters:
context - an EventContext.

getPrimaryKeyEncoder

protected <X,Y extends Serializable> PrimaryKeyEncoder<Y,X> getPrimaryKeyEncoder(Class<X> clasz)
Returns the configured PrimaryKeyEncoder for a given entity class.

Overrides:
getPrimaryKeyEncoder in class BasePage<T,K extends Serializable>
Type Parameters:
X - the type of the entity.
Y - the class' primary key field type.
Parameters:
clasz - a Class.
Returns:
a PrimaryKeyEncoder.
See Also:
PrimaryKeyEncoderSource.get(java.lang.Class)


Copyright © 2008-2009 Thiago H. de Paula Figueiredo. All Rights Reserved.