FileDocCategorySizeDatePackage
AbstractCRUDAction.javaAPI DocApache Struts 2.0.9 Apps3258Mon Jul 23 13:43:26 BST 2007org.apache.struts2.showcase.action

AbstractCRUDAction

public abstract class AbstractCRUDAction extends com.opensymphony.xwork2.ActionSupport
AbstractCRUDAction.

Fields Summary
private static final Logger
log
private Collection
availableItems
private String[]
toDelete
Constructors Summary
Methods Summary
public java.lang.Stringdelete()

        if (toDelete != null) {
            int count=0;
            for (int i = 0, j=toDelete.length; i < j; i++) {
                count = count + getDao().delete(toDelete[i]);
            }
            if (log.isDebugEnabled()) {
                log.debug("AbstractCRUDAction - [delete]: " + count + " items deleted.");
            }
        }
        return SUCCESS;
    
protected org.apache.struts2.showcase.model.IdEntityfetch(java.io.Serializable tryId, org.apache.struts2.showcase.model.IdEntity tryObject)
Utility method for fetching already persistent object from storage for usage in params-prepare-params cycle.

param
tryId The id to try to get persistent object for
param
tryObject The object, induced by first params invocation, possibly containing id to try to get persistent object for
return
The persistent object, if found. null otherwise.

        IdEntity result = null;
        if (tryId != null) {
            result = getDao().get(tryId);
        } else if (tryObject != null) {
            result = getDao().get(tryObject.getId());
        }
        return result;
    
public java.util.CollectiongetAvailableItems()


       


       
        return availableItems;
    
protected abstract org.apache.struts2.showcase.dao.DaogetDao()

public java.lang.String[]getToDelete()

        return toDelete;
    
public java.lang.Stringlist()

        this.availableItems = getDao().findAll();
        if (log.isDebugEnabled()) {
            log.debug("AbstractCRUDAction - [list]: " + (availableItems !=null?""+availableItems.size():"no") + " items found");
        }
        return execute();
    
public voidsetToDelete(java.lang.String[] toDelete)

        this.toDelete = toDelete;