Class AbstractSaveListActionSupport<M extends Serializable,K extends Serializable,T extends Serializable,F extends AbstractForm>

java.lang.Object
org.apache.struts2.ActionSupport
com.opensymphony.xwork2.ActionSupport
All Implemented Interfaces:
com.opensymphony.xwork2.Action, com.opensymphony.xwork2.interceptor.ValidationAware, com.opensymphony.xwork2.LocaleProvider, com.opensymphony.xwork2.ModelDriven<F>, com.opensymphony.xwork2.TextProvider, com.opensymphony.xwork2.Validateable, Serializable, BrowserTabAware, BrowserTabAware2, FormDriven<F>, org.apache.struts2.action.Action, org.apache.struts2.action.ServletRequestAware, org.apache.struts2.interceptor.ValidationAware, org.apache.struts2.ModelDriven<F>, org.apache.struts2.Validateable

public abstract class AbstractSaveListActionSupport<M extends Serializable,K extends Serializable,T extends Serializable,F extends AbstractForm> extends AbstractFormDrivenActionSupport<F>

Template class for changing business data related to the currently, selected item.

Concrete subclasses must implement getSaveListConfig(), which defines the the AbstractCompositeCache being used. Subclasses must override doSave(M, T).

The URL parameters, whose names can be changed by config, that can be used are:-

select
Index of item in list cache to update (which starts at 0).
M
Record type of master list cache if loading a slave list or Object otherwise.
K
Primary key type of list cache.
T
Record type of list cache.
F
Type of Struts action form used by this action or NullForm if Struts forms aren't used.
See Also:
  • Field Details

  • Constructor Details

    • AbstractSaveListActionSupport

      public AbstractSaveListActionSupport()
  • Method Details

    • execute

      public String execute() throws Exception
      Specified by:
      execute in interface org.apache.struts2.action.Action
      Overrides:
      execute in class org.apache.struts2.ActionSupport
      Throws:
      Exception
    • doSave

      protected abstract AbstractSaveListActionSupport.SaveResponse<T> doSave(M selectedMaster, T selectedItem) throws Exception
      Written by subclasses to try to save form data to business model. The form data applies to the currently selected item displayed on the viewer page. Returns response configuration, which includes whether the save succeeded and, if available, the updated item.
      Parameters:
      selectedItem - Currently selected item in cache that will be changed, or null if none, generally for adding.
      Returns:
      Response Configuration including success flag and any updated item.
      Throws:
      Exception
    • getAlternateIndex

      protected Integer getAlternateIndex(ListCache<M,K,T> listCache)
      Optionally written by subclasses to return index of record to select, typically by a request parameter, or null for no change of selection. If any action or field errors are written, the action ends and the input result is used.
    • getListCache

      protected abstract ListCache<M,K,T> getListCache()
      Written by subclasses to return list cache that is being updated.
    • getMasterListCache

      protected abstract ListCache<?,?,M> getMasterListCache()
      Written by subclasses to return master list cache or null if the list cache is the master list.
    • getSaveListConfig

      protected abstract AbstractSaveListActionSupport.SaveListConfig getSaveListConfig()
      Written by subclasses to configure behaviour of view action.