com.waveset.ui.util
Class FormConverter

java.lang.Object
  extended bycom.waveset.ui.util.FormConverter

public class FormConverter
extends java.lang.Object

An object responsbile for the conversion from an Form and GenericObject into an HtmlPage object.


Field Summary
static java.lang.String code_id
           
static java.lang.String LOC_BUTTON
          Value of the "location" property we recognize in fields placed within an HtmlPage object to place it the button row we maintain.
static java.lang.String PARM_ASSIMILATE_FILTER
          A special HttpServletRequest parameter we look at to find post data filters.
protected static Trace trace
           
 
Constructor Summary
FormConverter(RequestState state, Form form, GenericObject geo, com.waveset.ui.util.html.HtmlPage page)
          Build a converter, obtaining the HtmlPage class for the form.
 
Method Summary
 void assimilatePostData(RequestState state)
          Given a HttpServletRequest containing parameters posted from an HTML form, iterate over the fields defined in the Form object, locate the posted field data, and store the value back into a GenericObject.
 boolean checkConfirmations(javax.servlet.http.HttpServletRequest req)
          Check posted form data to ensure that it contains proper confirmation values for fields that need them.
 com.waveset.ui.util.html.HtmlPage convertForm()
          Convert the Form definition into a Component implementation.
 com.waveset.ui.util.html.Component createComponent(FieldDisplay def)
          Create a component from a FieldDisplay object.
 Form getForm()
           
static void println(java.lang.Object o)
           
 void refresh(Form form, GenericObject geo)
          Called after the view has been refreshed.
 void setIgnoreDisableExpressions(boolean b)
           
 void setTrace(boolean b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

trace

protected static final Trace trace

PARM_ASSIMILATE_FILTER

public static final java.lang.String PARM_ASSIMILATE_FILTER
A special HttpServletRequest parameter we look at to find post data filters. This is expected to be a csv string containing the names of the parameters to pay attention to.

See Also:
Constant Field Values

LOC_BUTTON

public static final java.lang.String LOC_BUTTON
Value of the "location" property we recognize in fields placed within an HtmlPage object to place it the button row we maintain.

See Also:
Constant Field Values
Constructor Detail

FormConverter

public FormConverter(RequestState state,
                     Form form,
                     GenericObject geo,
                     com.waveset.ui.util.html.HtmlPage page)
              throws WavesetException
Build a converter, obtaining the HtmlPage class for the form.

Method Detail

setTrace

public void setTrace(boolean b)

setIgnoreDisableExpressions

public void setIgnoreDisableExpressions(boolean b)

refresh

public void refresh(Form form,
                    GenericObject geo)
             throws WavesetException
Called after the view has been refreshed. If any substantive changes were made to the view or form, we'll have to recalculate our internal form state. Since this may be expensive, we should try to be smarter about detecting changes that are important here, like changes to the includes list.

In theory, this could specify a new container class, we'll assume for now that can't happen. But now that we maintain a fixed HtmlPage wrapper, we can easily replace _rootComponent.

Throws:
WavesetException

getForm

public Form getForm()

println

public static void println(java.lang.Object o)

convertForm

public com.waveset.ui.util.html.HtmlPage convertForm()
                                              throws WavesetException
Convert the Form definition into a Component implementation.

We also calculat the "memento" list and leave it behind on the view. This will be used later to drive post data assimilation.

Throws:
WavesetException

createComponent

public com.waveset.ui.util.html.Component createComponent(FieldDisplay def)
                                                   throws WavesetException
Create a component from a FieldDisplay object. Similar logic in FieldDisplay.create, but I moved it over here to have more control over the class names. It seems to make better sense here anyway.

Throws:
WavesetException

assimilatePostData

public void assimilatePostData(RequestState state)
                        throws WavesetException
Given a HttpServletRequest containing parameters posted from an HTML form, iterate over the fields defined in the Form object, locate the posted field data, and store the value back into a GenericObject. This can involve some data transformation which is now encapsulated in the Component classes. Since the Component gets to decide how to assimilate the data, we have to instantiate them. Systems built upon GenericEditForm will have a set of "memento" objects in the view that contain information about the components used to generate the last form. The mementos are similar to FieldDisplay objects, except they contain just minimum amount of information necessary to build a Component that can assimilate its post data. For systems that are not built on GenericEditForm, we can't rely on mementos and instead rebuild the full component from the FieldDisplay definition. The concept of a component memento was introduced to solve two problems. 1) when post data is assimilated, we're not absolutely guaranteed that the same fields will be visible in the iteration, causing post data to be lost. (this isn't usually a problem) 2) since the components get to decide what the post data will look like, it feels better to let them decide how to parse it to return a value POST DATA OVERRIDE Some "cascaded editing" forms post back to themselves twidding a "page" value to determine what is to be displayed. These forms may want a Cancel button that takes them to a different page, but ignores the post data. The problem is the normal Cancel command assimilates no data but will throw away the view so that can't be used. The Recalculate command will assimilate all the post data. We need a way to assimilate just some data, enough to get a new "page" value, but ignore the rest. The simplest way to do this seems to be to look for a special parameter, which if set is assumed to contain the name(s) of the other parameters that we're supposed to assimilate, the rest will be ignored.

Throws:
WavesetException

checkConfirmations

public boolean checkConfirmations(javax.servlet.http.HttpServletRequest req)
                           throws WavesetException
Check posted form data to ensure that it contains proper confirmation values for fields that need them. UPDATE: We formerly checked confirmations from the post data, but we need to be checking from the view. One reason is that if the form is refreshed once, the mismatched fields will be stored in the view, but if they were secret text fields, the refreshed form will contain the "fake" secret text which always matches. We could send the entered passwords back out, but its not really necessary to subject the passwords to any more exposure. We will have assimilated the post data into the view by now. We don't need the ServletRequest any more. // Originally returned an error list that GenericEditForm managed, // now we put the errors into the view so the convertForm method // can position them. Return true if everything was ok.

Throws:
WavesetException