org.barracudamvc.core.forms
Class UIDFormMapper

java.lang.Object
  extended byorg.barracudamvc.core.forms.DefaultFormMapper
      extended byorg.barracudamvc.core.forms.UIDFormMapper
All Implemented Interfaces:
FormMapper

public class UIDFormMapper
extends DefaultFormMapper

A UIDFormMapFilter makes it possible to map similar form elements based on a UID. For instance, let's say you have a url which contains parameters something like this:

What we really have here is a list of data "rows" that have been flattened using a simple naming convention (key + "::" + uid = value). In other words, the data viewed hierarchically would really look something like this:

The naming convention has been used to flatten a hierarchical set of data into a flat set of data which can be submitted via a URL.

If we were dealing with a finite, known set of uids, then we could define every item as its own form element, but that would be very burdensome on the developer, plus there will be many cases where we don't know the uids. What we need then is a form map that is smart enough to handle such a UID naming scheme, and take it into account automatically. That's what this class does.

When mapping the form, this filter causes any element which conform to a basic pattern (key + uid token + uid) to be mapped using the previously defined element for key.

Since:
2.0
Author:
Christian Cryder [christianc@granitepeaks.com]

Field Summary
static String UID_TOKEN
           
protected  Set uids
           
protected  String uidToken
           
 
Fields inherited from class org.barracudamvc.core.forms.DefaultFormMapper
iterateOverParams, localLogger, mappedElements
 
Constructor Summary
UIDFormMapper()
          Create a default UID form amp filter.
UIDFormMapper(String iuidToken)
          Create a UID form map using a custom UID token
 
Method Summary
 FormElement getElementByUID(FormMap fm, String subKey, String uid)
           
protected  FormElement getElementForMapping(FormMap fm, String paramKey)
          This method is used by the mapping process to look up FormElements.
 Set getMappedUIDs()
           
protected  void preMap()
          Invoked before mapping begins
 
Methods inherited from class org.barracudamvc.core.forms.DefaultFormMapper
_mapElement, getElements, isNull, mapElement, mapForm, postMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UID_TOKEN

public static final String UID_TOKEN
See Also:
Constant Field Values

uids

protected Set uids

uidToken

protected String uidToken
Constructor Detail

UIDFormMapper

public UIDFormMapper()
Create a default UID form amp filter. UID token defaults to "::".


UIDFormMapper

public UIDFormMapper(String iuidToken)
Create a UID form map using a custom UID token

Method Detail

preMap

protected void preMap()
Description copied from class: DefaultFormMapper
Invoked before mapping begins

Overrides:
preMap in class DefaultFormMapper

getElementForMapping

protected FormElement getElementForMapping(FormMap fm,
                                           String paramKey)
Description copied from class: DefaultFormMapper
This method is used by the mapping process to look up FormElements. It basically provides a way for the filter to determine whether or not mapping should occur. You can override this method of control what gets mapped and what doesn't. Based on the target key, the mapper either passes back the appropriate FormElement to map the key to, or it returns null to indicate the element should not be mapped.

Overrides:
getElementForMapping in class DefaultFormMapper

getMappedUIDs

public Set getMappedUIDs()

getElementByUID

public FormElement getElementByUID(FormMap fm,
                                   String subKey,
                                   String uid)


Copyright © 2004 BarracudaMVC.org All Rights Reserved.