com.taggercat.handlers
Class InsertRequestHandler

java.lang.Object
  extended by com.taggercat.handlers.AbstractRequestHandler
      extended by com.taggercat.handlers.InsertRequestHandler
All Implemented Interfaces:
com.taggercat.el.ELPropertyResolver, RequestHandler

public class InsertRequestHandler
extends AbstractRequestHandler

A request handler to insert a new tcEntity without first doing an insert action on the data source. This is not the handler used for regular insert actions.

The standard technique for inserts is to create a new tcEntity in the result set, and then present the form to collect the data for the new tcEntity.

If the user decides to not complete the insert, then they should also perform an undo action.

In web applications it is very easy for the user to simply leave the page, and not perform the undo action.

Using this request handler, the user is presented with a form to enter data for a new tcEntity before the new tcEntity is inserted. Then when the form is submitted, the new tcEntity is inserted, and the form data is applied to that newly inserted tcEntity. This is a much more common practice in web applications.

As with other request handlers, the destination data source is defined with a request parameter named dsName.
Row attribute values are specified using a dot delimited data source, field name.
Unlike other request handlers, the rowID is not applicable, because it is not known until the tcEntity is inserted. Therefore, you can use form elements such as:

<input type="text" name="supportContact.FIRST_NAME" value="<tc:out value='param.supportContact.FIRST_NAME' nulls='' />" >

The destination data source must exist for the tcEntity to be inserted into.

By default the tcEntity is not saved after the insert. To save the tcEntity after the insert, include a request parameter named saveInserted and set its value to true. You can include this parameter as a hidden form field

On your page, create input fields as described above, and add a link/button to the page to submit the form with the request name set to insertRow.

 

Constructor Summary
InsertRequestHandler()
           
 
Method Summary
 boolean insertNewRow(DataSource datasource)
          Updates data state for the data source referenced in request.
 
Methods inherited from class com.taggercat.handlers.AbstractRequestHandler
disableClientCache, getDataSourceName, getErrorException, getErrorPage, getErrorPageMethod, getErrorReason, getExplicitDataSourceName, getExplicitDSN, getMatchedPattern, getModel, getRequestController, getResponsePage, getResponsePageMethod, getSessionExpiredPage, getUserName4Log, init, isAjaxRequest, onChainCompleted, resolveProperty, serverTemporaryFile, serveTemporaryFile, service, setActionName, setErrorPage, setErrorPageMethod, setErrorPageMethodToRedirect, setExplicitDataSourceName, setExplicitDSN, setMatchedPattern, setResponsePage, setResponsePageMethod, setResponsePageMethodToRedirect, setSessionExpiredPage
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InsertRequestHandler

public InsertRequestHandler()
Method Detail

insertNewRow

public boolean insertNewRow(DataSource datasource)
                     throws java.lang.Exception
Updates data state for the data source referenced in request.

All IllegalArgumentException are caught, and delayed until all fields have been updated. Then all IllegalArgumentException messages are thrown as a single exception.

Throws:
java.lang.Exception
Parameters:
datasource - the data source instance to insert the new tcEntity
Returns:
true if successful, else false