info.informatica.ui.html
Class HTTPDataEntryForm

java.lang.Object
  extended by info.informatica.ui.DataView
      extended by info.informatica.ui.html.HTTPDataEntryForm
All Implemented Interfaces:
Valueset

public class HTTPDataEntryForm
extends DataView

Encapsulation of HTML data entry form.

SYNOPSIS / EXAMPLE:

    // initialize
    Properties p = ...
    DataDict dict = new PropertyDataDict(p);
    HTMLViewDatabase viewDb = ...
    MetaData md = dict.getMetaData(datasrc_name);
    DataViewConfig vc = viewDb.getDataViewConfig(form_name);
    ViewSecurity vsec = ... [optional]
    DataView form = new HTTPDataEntryForm(form_name);
    // Set the metadata
    form.setMetaData(md);
    try {
       // feed the form with data view configuration
       form.setDataViewConfig(vc);
       // Set the security constraints
       form.setSecurity(vsec);
       // initialize
       form.init();
    } catch(DataException e){
       ...
    }
    form.setValues(req);
    // Validate the form
    try {
       form.validate();
    } catch(DataFieldException e){
       ...
    }
    // Do something with values
    DataControl control = form.getValue("field1");
    String value = (String)control.getValue();
    ...
    form.close();
 

Author:
amengual at informatica dot info

Constructor Summary
HTTPDataEntryForm(String id)
          Builds a form with name id
 
Method Summary
static HTTPDataEntryForm createForm(DataDict dict, String metadata_name, String ui_spec_filename)
          Creates a sample HTML form from a data dictionary and, optionally, an user interface specification file.
 DataViewMap createViewMap(HTTPDataEntryForm form, LocalLabels labels)
          Generates a sample view map starting from a form (that does not have a DataViewConfig).
static void defaultMetaData(MetaData md, javax.servlet.http.HttpServletRequest req)
          Adds default metadata to a metadata object.
static DataViewMap formToViewMap(info.informatica.html.HTMLFragment html, String form_id, DataDict dict, MetaData md)
          Deprecated.  
 String getAction()
          Gets the form action
 String getEncType()
          Gets the form encoding
 String getMethod()
          Gets the HTTP method
 void load(javax.servlet.http.HttpServletRequest req)
          Convenience method to load config from request
static void main(String[] args)
          Testdrive method used to read a data dictionary from a properties file, and print the corresponding form.
 void setAction(String action)
          Sets the Action of the form
 void setAction(URL action)
          Sets the Action of the form
 void setMethod(String method)
          Sets the HTTP form method
 void setValues(javax.servlet.http.HttpServletRequest req)
          Sets the values of the fields from request
 void setValues(javax.servlet.http.HttpServletRequest req, Map<String,? extends Object> environment)
          Sets the values of the fields from request
 String toString()
           
 
Methods inherited from class info.informatica.ui.DataView
close, createDataControl, dataToUI, dataToUI, equals, fieldCount, getAllowedRoles, getDataControl, getDataControls, getDataViewConfig, getId, getMetaData, getSecurity, getValue, hashCode, init, setDataViewConfig, setMetaData, setSecurity, validate, validate, validate
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HTTPDataEntryForm

public HTTPDataEntryForm(String id)
Builds a form with name id

Method Detail

load

public final void load(javax.servlet.http.HttpServletRequest req)
                throws DataViewException
Convenience method to load config from request

Throws:
DataViewException

setMethod

public final void setMethod(String method)
Sets the HTTP form method

Parameters:
method - metodo

setAction

public final void setAction(String action)
Sets the Action of the form

Parameters:
action - form's action

setAction

public final void setAction(URL action)
Sets the Action of the form

Parameters:
action - form's action URL

setValues

public void setValues(javax.servlet.http.HttpServletRequest req)
               throws DataFieldException
Sets the values of the fields from request

Parameters:
req - the HTTP request
Throws:
DataFieldException - if an error occurs setting the values.

setValues

public void setValues(javax.servlet.http.HttpServletRequest req,
                      Map<String,? extends Object> environment)
               throws DataFieldException
Sets the values of the fields from request

Parameters:
req - the HTTP request
Throws:
DataFieldException - if an error occurs setting the values.

getMethod

public final String getMethod()
Gets the HTTP method

Returns:
String con el método

getAction

public final String getAction()
Gets the form action

Returns:
String con la Accion

getEncType

public String getEncType()
Gets the form encoding

Returns:
Encode Type

defaultMetaData

public static void defaultMetaData(MetaData md,
                                   javax.servlet.http.HttpServletRequest req)
Adds default metadata to a metadata object.

Parameters:
md - the initial metadata object, which can be empty
req - the Servlet Request used to fill the MetaData

toString

public String toString()
Overrides:
toString in class DataView

createForm

public static HTTPDataEntryForm createForm(DataDict dict,
                                           String metadata_name,
                                           String ui_spec_filename)
                                    throws DataException,
                                           DataViewException,
                                           IOException
Creates a sample HTML form from a data dictionary and, optionally, an user interface specification file.

This "Documentation method" shows the use of a data dictionary and, optionally, a User Interface specification (ViewConfig) to produce a sample HTML form.

Parameters:
dict - the data dictionary
metadata_name - the name of the form data as recognized by data dictionary.
ui_spec_filename - Filename of a ViewMap user interface specification. May be null.
Throws:
DataException
DataViewException
IOException

createViewMap

public DataViewMap createViewMap(HTTPDataEntryForm form,
                                 LocalLabels labels)
Generates a sample view map starting from a form (that does not have a DataViewConfig).

For cases where we do not have a ViewConfig.


formToViewMap

public static DataViewMap formToViewMap(info.informatica.html.HTMLFragment html,
                                        String form_id,
                                        DataDict dict,
                                        MetaData md)
                                 throws info.informatica.html.HTMLDocumentException,
                                        DataException
Deprecated. 

Parameters:
html -
form_id -
dict -
md -
Returns:
the extracted DataViewMap
Throws:
info.informatica.html.HTMLDocumentException
DataException
See Also:
HTMLViewDatabase#parseView(String, String)

main

public static void main(String[] args)
Testdrive method used to read a data dictionary from a properties file, and print the corresponding form.