com.scooterframework.web.util
Class F

java.lang.Object
  extended by com.scooterframework.web.util.F

public class F
extends java.lang.Object

F (FormHelper) class has helper methods for http form.

In order to display validation messages for a form element, formForOpen, formForClose and label methods must be used together. If there is error for a field, the field's label element will be highlighted.

formProperties is used to specify properties for form tag, including AJAX properties.

Ajax Examples:

 //add a post and then refresh the posts list
 formForOpen("posts", null, "data-ajax:true; data-target:#posts_list; data-handler:html")
 result: 
//edit a post with id 45 and then refresh the posts list formForOpen("posts", post, "data-ajax:true; data-target:#posts_list; data-handler:html") result:


Constructor Summary
F()
           
 
Method Summary
static java.lang.String formForClose(java.lang.String resourceName)
          Returns form-end element for a resource.
static java.lang.String formForOpen(java.lang.String[] parentResourceNames, java.lang.Object[] parentRestfuls, java.lang.String resourceName, ActiveRecord object)
          Returns form-open element <form>for a nested resource.
static java.lang.String formForOpen(java.lang.String[] parentResourceNames, java.lang.Object[] parentRestfuls, java.lang.String resourceName, ActiveRecord object, java.lang.String formProperties)
          Returns form-open element <form>for a nested resource.
static java.lang.String formForOpen(java.lang.String[] parentResourceNames, java.lang.Object[] parentRestfuls, java.lang.String resourceName, java.lang.String objectKey)
          Returns form-open element <form>for a nested resource.
static java.lang.String formForOpen(java.lang.String[] parentResourceNames, java.lang.Object[] parentRestfuls, java.lang.String resourceName, java.lang.String objectKey, java.lang.String formProperties)
          Returns form-open element <form>for a nested resource.
static java.lang.String formForOpen(java.lang.String resourceName, ActiveRecord object)
          Returns form-open element <form>for a resource.
static java.lang.String formForOpen(java.lang.String resourceName, ActiveRecord object, java.lang.String formProperties)
          Returns form-open element <form>for a resource.
static java.lang.String formForOpen(java.lang.String parentResourceName, RESTified parentObject, java.lang.String resourceName, ActiveRecord object)
          Returns form-open element <form>for a nested resource.
static java.lang.String formForOpen(java.lang.String parentResourceName, RESTified parentObject, java.lang.String resourceName, ActiveRecord object, java.lang.String formProperties)
          Returns form-open element <form>for a nested resource.
static java.lang.String formForOpen(java.lang.String parentResourceName, RESTified parentObject, java.lang.String resourceName, java.lang.String objectKey)
          Returns form-open element <form>for a nested resource.
static java.lang.String formForOpen(java.lang.String parentResourceName, RESTified parentObject, java.lang.String resourceName, java.lang.String objectKey, java.lang.String formProperties)
          Returns form-open element <form>for a nested resource.
static java.lang.String formForOpen(java.lang.String resourceName, java.lang.String objectKey)
          Returns form-open element <form>for a resource.
static java.lang.String formForOpen(java.lang.String resourceName, java.lang.String objectKey, java.lang.String formProperties)
          Returns form-open element <form>for a resource.
static java.lang.String formForOpen(java.lang.String parentResourceName, java.lang.String parentObjectKey, java.lang.String resourceName, ActiveRecord object)
          Returns form-open element <form>for a nested resource.
static java.lang.String formForOpen(java.lang.String parentResourceName, java.lang.String parentObjectKey, java.lang.String resourceName, ActiveRecord object, java.lang.String formProperties)
          Returns form-open element <form>for a nested resource.
static java.lang.String formForOpen(java.lang.String parentResourceName, java.lang.String parentObjectKey, java.lang.String resourceName, java.lang.String objectKey)
          Returns form-open element <form>for a nested resource.
static java.lang.String formForOpen(java.lang.String parentResourceName, java.lang.String parentObjectKey, java.lang.String resourceName, java.lang.String objectKey, java.lang.String formProperties)
          Returns form-open element <form>for a nested resource.
static java.lang.String label(java.lang.String field)
          Returns label string for a field of the underlying object.
static java.lang.String label(java.lang.String field, java.util.Map<java.lang.String,java.lang.String> options)
          Returns label string for a field of the underlying object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

F

public F()
Method Detail

formForOpen

public static java.lang.String formForOpen(java.lang.String resourceName,
                                           java.lang.String objectKey)

Returns form-open element <form>for a resource. The objectKey is used to retrieve the corresponding object for the resource. The object must be of RESTified type. If there is no object mapped to the key, or the object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

Parameters:
resourceName - name of the resource
objectKey - key pointing to the object
Returns:
form-open element for a resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String resourceName,
                                           java.lang.String objectKey,
                                           java.lang.String formProperties)

Returns form-open element <form>for a resource. The objectKey is used to retrieve the corresponding object for the resource. The object must be of RESTified type. If there is no object mapped to the key, or the object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

formProperties refers to properties for <form>. See top of this class for examples.

Parameters:
resourceName - name of the resource
objectKey - key pointing to the object
formProperties - string of form related properties
Returns:
form-open element for a resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String resourceName,
                                           ActiveRecord object)

Returns form-open element <form>for a resource. If the object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

Parameters:
resourceName - name of the resource
object - an ActiveRecord object
Returns:
form-open element for a resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String resourceName,
                                           ActiveRecord object,
                                           java.lang.String formProperties)

Returns form-open element <form>for a resource. If the object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

formProperties refers to properties for <form>. See top of this class for examples.

Parameters:
resourceName - name of the resource
object - an ActiveRecord object
formProperties - string of form related properties
Returns:
form-open element for a resource object

formForClose

public static java.lang.String formForClose(java.lang.String resourceName)
Returns form-end element for a resource.

Parameters:
resourceName - name of the resource
Returns:
form-end element for a resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String parentResourceName,
                                           java.lang.String parentObjectKey,
                                           java.lang.String resourceName,
                                           java.lang.String objectKey)

Returns form-open element <form>for a nested resource.

The parentObjectKey is used to retrieve the corresponding object for the parent resource. The parent object must be of RESTified type.

The objectKey is used to retrieve the corresponding object for the nested resource. The object must be of RESTified type.

If there is no object mapped to the key, or the object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

Parameters:
parentResourceName - name of the parent resource
parentObjectKey - key pointing to the parent object
resourceName - name of the nested resource
objectKey - key pointing to the object
Returns:
form-open element for a nested resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String parentResourceName,
                                           java.lang.String parentObjectKey,
                                           java.lang.String resourceName,
                                           java.lang.String objectKey,
                                           java.lang.String formProperties)

Returns form-open element <form>for a nested resource.

The parentObjectKey is used to retrieve the corresponding object for the parent resource. The parent object must be of RESTified type.

The objectKey is used to retrieve the corresponding object for the nested resource. The object must be of RESTified type.

If there is no object mapped to the key, or the object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

formProperties refers to properties for <form>. See top of this class for examples.

Parameters:
parentResourceName - name of the parent resource
parentObjectKey - key pointing to the parent object
resourceName - name of the nested resource
objectKey - key pointing to the object
formProperties - string of form related properties
Returns:
form-open element for a nested resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String parentResourceName,
                                           java.lang.String parentObjectKey,
                                           java.lang.String resourceName,
                                           ActiveRecord object)

Returns form-open element <form>for a nested resource.

The parentObjectKey is used to retrieve the corresponding object for the parent resource. The parent object must be of RESTified type.

If ActiveRecord object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

Parameters:
parentResourceName - name of the parent resource
parentObjectKey - key pointing to the parent object
resourceName - name of the nested resource
object - an ActiveRecord object
Returns:
form-open element for a nested resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String parentResourceName,
                                           java.lang.String parentObjectKey,
                                           java.lang.String resourceName,
                                           ActiveRecord object,
                                           java.lang.String formProperties)

Returns form-open element <form>for a nested resource.

The parentObjectKey is used to retrieve the corresponding object for the parent resource. The parent object must be of RESTified type.

If ActiveRecord object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

formProperties refers to properties for <form>. See top of this class for examples.

Parameters:
parentResourceName - name of the parent resource
parentObjectKey - key pointing to the parent object
resourceName - name of the nested resource
object - an ActiveRecord object
formProperties - string of form related properties
Returns:
form-open element for a nested resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String parentResourceName,
                                           RESTified parentObject,
                                           java.lang.String resourceName,
                                           java.lang.String objectKey)

Returns form-open element <form>for a nested resource.

The objectKey is used to retrieve the corresponding object for the nested resource. The object must be of RESTified type.

If there is no object mapped to the key, or the object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

Parameters:
parentResourceName - name of the parent resource
parentObject - the parent object
resourceName - name of the nested resource
objectKey - key pointing to the object
Returns:
form-open element for a nested resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String parentResourceName,
                                           RESTified parentObject,
                                           java.lang.String resourceName,
                                           java.lang.String objectKey,
                                           java.lang.String formProperties)

Returns form-open element <form>for a nested resource.

The objectKey is used to retrieve the corresponding object for the nested resource. The object must be of RESTified type.

If there is no object mapped to the key, or the object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

formProperties refers to properties for <form>. See top of this class for examples.

Parameters:
parentResourceName - name of the parent resource
parentObject - the parent object
resourceName - name of the nested resource
objectKey - key pointing to the object
formProperties - string of form related properties
Returns:
form-open element for a nested resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String parentResourceName,
                                           RESTified parentObject,
                                           java.lang.String resourceName,
                                           ActiveRecord object)

Returns form-open element <form>for a nested resource.

If ActiveRecord object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

Parameters:
parentResourceName - name of the parent resource
parentObject - the parent object
resourceName - name of the nested resource
object - an ActiveRecord object
Returns:
form-open element for a nested resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String parentResourceName,
                                           RESTified parentObject,
                                           java.lang.String resourceName,
                                           ActiveRecord object,
                                           java.lang.String formProperties)

Returns form-open element <form>for a nested resource.

If ActiveRecord object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

formProperties refers to properties for <form>. See top of this class for examples.

Parameters:
parentResourceName - name of the parent resource
parentObject - the parent object
resourceName - name of the nested resource
object - an ActiveRecord object
formProperties - string of form related properties
Returns:
form-open element for a nested resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String[] parentResourceNames,
                                           java.lang.Object[] parentRestfuls,
                                           java.lang.String resourceName,
                                           java.lang.String objectKey)

Returns form-open element <form>for a nested resource.

parentResourceNames is an array of ancestors. The oldest is at the beginning of the array. parentRestfuls is an array of either restful id strings or RESTified records of ancestors.

The objectKey is used to retrieve the corresponding object for the nested resource. The object must be of RESTified type.

If there is no object mapped to the key, or the object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

Parameters:
parentResourceNames - names of the parent resources
parentRestfuls - the parent restful ids or RESTified objects
resourceName - name of the nested resource
objectKey - key pointing to the object
Returns:
form-open element for a nested resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String[] parentResourceNames,
                                           java.lang.Object[] parentRestfuls,
                                           java.lang.String resourceName,
                                           java.lang.String objectKey,
                                           java.lang.String formProperties)

Returns form-open element <form>for a nested resource.

parentResourceNames is an array of ancestors. The oldest is at the beginning of the array. parentRestfuls is an array of either restful id strings or RESTified records of ancestors.

The objectKey is used to retrieve the corresponding object for the nested resource. The object must be of RESTified type.

If there is no object mapped to the key, or the object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

formProperties refers to properties for <form>. See top of this class for examples.

Parameters:
parentResourceNames - names of the parent resources
parentRestfuls - the parent restful ids or RESTified objects
resourceName - name of the nested resource
objectKey - key pointing to the object
formProperties - string of form related properties
Returns:
form-open element for a nested resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String[] parentResourceNames,
                                           java.lang.Object[] parentRestfuls,
                                           java.lang.String resourceName,
                                           ActiveRecord object)

Returns form-open element <form>for a nested resource.

parentResourceNames is an array of ancestors. The oldest is at the beginning of the array. parentRestfuls is an array of either restful id strings or RESTified records of ancestors.

If ActiveRecord object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

Parameters:
parentResourceNames - names of the parent resources
parentRestfuls - the parent restful ids or RESTified objects
resourceName - name of the nested resource
object - an ActiveRecord object
Returns:
form-open element for a nested resource object

formForOpen

public static java.lang.String formForOpen(java.lang.String[] parentResourceNames,
                                           java.lang.Object[] parentRestfuls,
                                           java.lang.String resourceName,
                                           ActiveRecord object,
                                           java.lang.String formProperties)

Returns form-open element <form>for a nested resource.

parentResourceNames is an array of ancestors. The oldest is at the beginning of the array. parentRestfuls is an array of either restful id strings or RESTified records of ancestors.

If ActiveRecord object's restful id is null, the form is for adding a new object. Otherwise it is for editing the object.

formProperties refers to properties for <form>. See top of this class for examples.

Parameters:
parentResourceNames - names of the parent resources
parentRestfuls - the parent restful ids or RESTified objects
resourceName - name of the nested resource
object - an ActiveRecord object
formProperties - string of form related properties
Returns:
form-open element for a nested resource object

label

public static java.lang.String label(java.lang.String field)
Returns label string for a field of the underlying object. This method should not be used without using formFor method first.
  Examples:
      
      

Parameters:
field - field name
Returns:
error-aware label tag string

label

public static java.lang.String label(java.lang.String field,
                                     java.util.Map<java.lang.String,java.lang.String> options)
Returns label string for a field of the underlying object. This method should not be used without using formFor method first.
  Examples:
      
      

Parameters:
field - field name
options - options for the label tag
Returns:
error-aware label tag string