com.ptc.core.components.forms
Class CreateObjectFormProcessor

java.lang.Object
  extended by com.ptc.core.components.forms.DefaultObjectFormProcessor
      extended by com.ptc.core.components.forms.CreateObjectFormProcessor
All Implemented Interfaces:
ObjectFormProcessor
Direct Known Subclasses:
CreateChangeItemFormProcessor

public class CreateObjectFormProcessor
extends com.ptc.core.components.forms.DefaultObjectFormProcessor

A form processor that generically creates one or more Persistables from the form data submitted in an HTML wizard and stores them in the database.

Supported API: true

Extendable: true


Method Summary
protected  Object createItemInstance(NmCommandBean clientData, ObjectBean objBean, FormResult result)
          Creates an instance of the object represented by the form data in the given ObjectBean and validates the attribute values submitted for it.
 FormResult doOperation(NmCommandBean clientData, List<ObjectBean> objectBeans)
          Stores the object(s) contained in the "object" attribute(s) of the given ObjectBeans in the database.
 FormResult preProcess(NmCommandBean clientData, List<ObjectBean> objectBeans)
          Creates one object instance for each given ObjectBean and sets their attributes.
 FormResult setResultNextAction(FormResult result, NmCommandBean clientData, List<ObjectBean> objectBeans)
          Sets the "nextAction" attribute on the given FormResult based on the processing status.
 
Methods inherited from class com.ptc.core.components.forms.DefaultObjectFormProcessor
continueProcessing, getDelegates, mergeIntermediateResult, postProcess, postTransactionProcess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

doOperation

public FormResult doOperation(NmCommandBean clientData,
                              List<ObjectBean> objectBeans)
                       throws WTException
Stores the object(s) contained in the "object" attribute(s) of the given ObjectBeans in the database. On entry, the attributes of these object instances will reflect the values entered in the wizard form.

This method is called by the DefaultFormProcessorController after it calls the preProcess() method.

Before storing the object(s), this method calls the doOperation() method of all ObjectFormProcessorDelegates for the wizard. These are called in no particular order.

Supported API: true

Specified by:
doOperation in interface ObjectFormProcessor
Overrides:
doOperation in class com.ptc.core.components.forms.DefaultObjectFormProcessor
Parameters:
clientData - - Contains all of the request form data and other wizard context information. Input.
objectBeans - - The "object" attribute of these beans contain the object instances to be stored. One bean per object. Input.
Returns:
FormResult - the result of this method
Throws:
WTException

preProcess

public FormResult preProcess(NmCommandBean clientData,
                             List<ObjectBean> objectBeans)
                      throws WTException
Creates one object instance for each given ObjectBean and sets their attributes. After creating the instance calls the preProcess() method of all ObjectFormProcessorDelegates for the wizard, in no particular order. This method is called by the DefaultFormProcessorController and is the first wizard processing phase.

For wizards that have Define Object and Set Attributes steps, this method is also called after the user completes each of these steps to validate the user-entered attribute values. Therefore, this method should not perform any tasks that modify the database.

Supported API: true

Specified by:
preProcess in interface ObjectFormProcessor
Overrides:
preProcess in class com.ptc.core.components.forms.DefaultObjectFormProcessor
Parameters:
clientData - Contains request form data and other context information. Input. Required.
objectBeans - Contain the form data for each object to be created. One bean per object. On exit, the "object" attribute of each ObjectBean is set to the object instance created from the form data. Input and output. Required.
Returns:
FormResult - the result of this operation.
Throws:
WTException

createItemInstance

protected Object createItemInstance(NmCommandBean clientData,
                                    ObjectBean objBean,
                                    FormResult result)
                             throws WTException
Creates an instance of the object represented by the form data in the given ObjectBean and validates the attribute values submitted for it. Returns the object instance and sets it as the "object" attribute in the ObjectBean.

Supported API: true

Parameters:
clientData - Contains form data and other context information. Input.
objBean - - Contains the form data for one object to be created. On exit, the "object" attribute of the bean will be set to the created object instance. Input and output.
result - The return status of the method. Output, but must be instantiated on entry.
Returns:
Object - the object instance created
Throws:
WTException

setResultNextAction

public FormResult setResultNextAction(FormResult result,
                                      NmCommandBean clientData,
                                      List<ObjectBean> objectBeans)
                               throws WTException
Sets the "nextAction" attribute on the given FormResult based on the processing status.

If the status is SUCCESS or NON_FATAL_ERROR, the nextAction is set to REFRESH_OPENER and a success feedback message is added to the FormResult. If the launching window was a folder browser, information needed to dynamically refresh the parent window also will be returned.

If the status is FAILURE, the nextAction is set to NONE.

This method may be overridden by subclasses desiring different behavior.

Supported API: true

Specified by:
setResultNextAction in interface ObjectFormProcessor
Overrides:
setResultNextAction in class com.ptc.core.components.forms.DefaultObjectFormProcessor
Parameters:
result - - The FormResult to which the action info should be added. Input and output. Required.
clientData - - Contains all the form data and other wizard context information. Input. Required.
objectBeans - - Contain the object(s) that were created (if successful). One bean per object. Input. Required.
Returns:
FormResult - the nextAction attribute is set; the refreshInfo attribute may also be set and a success feedback message added.
Throws:
WTException