com.flexive.shared.value.mapper
Class InputMapper<BaseType extends FxValue,MappedType extends FxValue>

java.lang.Object
  extended by com.flexive.shared.value.mapper.InputMapper<BaseType,MappedType>
Type Parameters:
BaseType - the source value to be mapped (must extend FxValue).
MappedType - the target type of the mapping (must extend FxValue).
Direct Known Subclasses:
FxPkSelectOneInputMapper, IdentityInputMapper, NumberQueryInputMapper, SelectOneInputMapper, VoidInputMapper

public abstract class InputMapper<BaseType extends FxValue,MappedType extends FxValue>
extends java.lang.Object

InputMapper introduces another level of abstraction for the FxValue input components.

When rendering the input component, encode(FxValue) is called and may wrap the given value in another object. For example, an ordinal FxLargeNumber like the ACL ID may be mapped to a FxSelectOne value for input rendering.

When decoding the value submitted from the input form, decode(com.flexive.shared.value.FxValue) is called with an instance of the mapped type. In the example given above, the decode method would store the element ID of the FxSelectOne value in a FxLargeNumber instance.

Use getInstance(FxProperty) to retrieve a new InputMapper for the given structure property, which for example allows to select ACLs with a select list instead of a numeric input field.

You may also implement your own input mapper and supply it to the FxValueInput component or attach it to a search query node.

Version:
$Rev: 595 $
Author:
Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)

Constructor Summary
InputMapper()
           
 
Method Summary
protected  void buildAutocompleteHandler(java.lang.String jsonRpcQuery, java.lang.String... args)
          Build an autocomplete handler for the given JSON/RPC query call.
 BaseType decode(MappedType value)
          Decode the mapped type.
protected abstract  BaseType doDecode(MappedType value)
          Decode the mapped type.
protected abstract  MappedType doEncode(BaseType value)
          Map the given value to the destination FxValue type.
 MappedType encode(BaseType value)
          Map the given value to the destination FxValue type.
 java.lang.String getAutocompleteHandler()
          Return an (optional) autocomplete handler for the input component, for example:
new flexive.yui.AutoCompleteHandler().
 java.util.List<? extends ValueComparator> getAvailableValueComparators()
          Returns all available value comparators available in search queries.
static InputMapper getInstance(FxProperty property)
          Return a new input mapper instance for the given structure property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputMapper

public InputMapper()
Method Detail

encode

public final MappedType encode(BaseType value)
Map the given value to the destination FxValue type. The resulting object will be used for rendering the input element for the given value.

Parameters:
value - the value to be mapped
Returns:
the mapped type

decode

public final BaseType decode(MappedType value)
Decode the mapped type. Called after the mapped type has been updated in the user form.

Parameters:
value - the mapped value type, possibly modified by the user
Returns:
the corresponding base type

doEncode

protected abstract MappedType doEncode(BaseType value)
Map the given value to the destination FxValue type. The resulting object will be used for rendering the input element for the given value.

Parameters:
value - the value to be mapped
Returns:
the mapped type

doDecode

protected abstract BaseType doDecode(MappedType value)
Decode the mapped type. Called after the mapped type has been updated in the user form.

Parameters:
value - the mapped value type, possibly modified by the user
Returns:
the corresponding base type

getAutocompleteHandler

public java.lang.String getAutocompleteHandler()
Return an (optional) autocomplete handler for the input component, for example:
new flexive.yui.AutoCompleteHandler().

Returns:
an (optional) autocomplete handler for the input component.

getAvailableValueComparators

public java.util.List<? extends ValueComparator> getAvailableValueComparators()
Returns all available value comparators available in search queries. If the returned list is empty, it is ignored.

Returns:
all available value comparators available in search queries

getInstance

public static InputMapper getInstance(FxProperty property)
Return a new input mapper instance for the given structure property. For example, this allows to use a select list to choose an ACL, instead of a plain numeric input field.

Parameters:
property - the property for which values will be mapped
Returns:
an input mapper

buildAutocompleteHandler

protected final void buildAutocompleteHandler(java.lang.String jsonRpcQuery,
                                              java.lang.String... args)
Build an autocomplete handler for the given JSON/RPC query call.

Parameters:
jsonRpcQuery - the query method, for example:
AutoCompleteProvider.userQuery
args - additional parameters for the javascript function. The first parameter is always the query string.