org.olat.user.propertyhandlers
Class Generic127CharTextPropertyHandler

java.lang.Object
  extended by org.olat.user.AbstractUserPropertyHandler
      extended by org.olat.user.propertyhandlers.Generic127CharTextPropertyHandler
All Implemented Interfaces:
ItemValidatorProvider, UserPropertyHandler
Direct Known Subclasses:
EmailProperty, ICQPropertyHandler, MSNPropertyHandler, PhonePropertyHandler, SkypePropertyHandler, URLPropertyHandler, XingPropertyHandler

public class Generic127CharTextPropertyHandler
extends AbstractUserPropertyHandler

Description:

This generic text property provides a userfield that has a maximum of 127 characters length. It can contain any string, the only validity check that is performed is the not empty check if the property is declared as mandatory.

Create subclass of this class if you allow only a certain range of entered data. See EmailProperty as an example.

Initial Date: 27.07.2007

Author:
Florian Gnaegi, frentix GmbH, http://www.frentix.com

Constructor Summary
Generic127CharTextPropertyHandler()
           
 
Method Summary
 FormItem addFormItem(java.util.Locale locale, User user, java.lang.String usageIdentifyer, boolean isAdministrativeUser, FormItemContainer formItemContainer)
          Adds a flexi-form Item for this UserPropertyHandler.
 FormElement getFormElement(java.util.Locale locale, User user, java.lang.String usageIdentifyer, boolean isAdministrativeUser)
          Create a (non-flexi) form element for this UserPropertyHandler.
 java.lang.String getStringValue(FormElement ui)
          Get the value from this form element formatted as string.
 java.lang.String getStringValue(FormItem formItem)
          Get the value from this form item formatted as string.
 java.lang.String getStringValue(java.lang.String displayValue, java.util.Locale locale)
          Get the value from this GUI formatted string The returned value is formatted in a way it can be stored in the database, thus it might not be the right value to display to a user.
 boolean isValid(FormElement ui, java.util.Map formContext)
          Check if this form is valid
 boolean isValid(FormItem formItem, java.util.Map formContext)
          Checks if a form item for a property has a valid value and sets the appropriate error key if necessary.
 boolean isValidValue(java.lang.String value, ValidationError validationError, java.util.Locale locale)
          Checks if the given value is a valid value for this property (e.g.
 void updateFormElementFromUser(FormElement ui, User user)
          Put the current value from this UserPropertyHandler into the given form element
 void updateUserFromFormElement(User user, FormElement ui)
          Reads the value of the given form element and updates the user
 void updateUserFromFormItem(User user, FormItem formItem)
          Reads the value of the given form item and updates the user
 
Methods inherited from class org.olat.user.AbstractUserPropertyHandler
getColumnDescriptor, getGroup, getName, getUserProperty, getUserPropertyAsHTML, i18nColumnDescriptorLabelKey, i18nFormElementGroupKey, i18nFormElementLabelKey, isDeletable, setDeletable, setGroup, setName, setUserProperty, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Generic127CharTextPropertyHandler

public Generic127CharTextPropertyHandler()
Method Detail

updateUserFromFormElement

public void updateUserFromFormElement(User user,
                                      FormElement ui)
Description copied from interface: UserPropertyHandler
Reads the value of the given form element and updates the user

Parameters:
user - The user to be updated
ui - The form element previously created with the getFormElement method
See Also:
UserPropertyHandler.updateUserFromFormElement(org.olat.core.id.User, org.olat.core.gui.formelements.FormElement)

updateUserFromFormItem

public void updateUserFromFormItem(User user,
                                   FormItem formItem)
Description copied from interface: UserPropertyHandler
Reads the value of the given form item and updates the user

Parameters:
user - The user to be updated
formItem - The form item previously created with the addFormItem method
See Also:
UserPropertyHandler.updateUserFromFormItem(org.olat.core.id.User, org.olat.core.gui.components.form.flexible.FormItem)

getStringValue

public java.lang.String getStringValue(FormElement ui)
Description copied from interface: UserPropertyHandler
Get the value from this form element formatted as string. The returned value is formatted in a way it can be stored in the database, thus it might not be the right value to display to a user.

Returns:
See Also:
UserPropertyHandler.getStringValue(org.olat.core.gui.formelements.FormElement)

getStringValue

public java.lang.String getStringValue(FormItem formItem)
Description copied from interface: UserPropertyHandler
Get the value from this form item formatted as string. The returned value is formatted in a way it can be stored in the database, thus it might not be the right value to display to a user.

Returns:
See Also:
UserPropertyHandler.getStringValue(org.olat.core.gui.formelements.FormElement)

getStringValue

public java.lang.String getStringValue(java.lang.String displayValue,
                                       java.util.Locale locale)
Description copied from interface: UserPropertyHandler
Get the value from this GUI formatted string The returned value is formatted in a way it can be stored in the database, thus it might not be the right value to display to a user.

locale - The locale to be used to parse the display value
Returns:
See Also:
UserPropertyHandler.getStringValue(java.lang.String, java.util.Locale)

getFormElement

public FormElement getFormElement(java.util.Locale locale,
                                  User user,
                                  java.lang.String usageIdentifyer,
                                  boolean isAdministrativeUser)
Description copied from interface: UserPropertyHandler
Create a (non-flexi) form element for this UserPropertyHandler. The usageIdentifyer indicates in which form the element is to be used.

Parameters:
locale - The current users locale
user - The user containing data to be prefilled or NULL if it should be left empty
usageIdentifyer - The identifyer of the form where this form element is used
isAdministrativeUser - true: Form element will be set to administrative mode. false: the element is set to user mode. In some cases the field is then read-only
Returns:
The form element or NULL if in this context the element is not displayed
See Also:
UserPropertyHandler.getFormElement(java.util.Locale, org.olat.core.id.User, java.lang.String, boolean)

addFormItem

public FormItem addFormItem(java.util.Locale locale,
                            User user,
                            java.lang.String usageIdentifyer,
                            boolean isAdministrativeUser,
                            FormItemContainer formItemContainer)
Description copied from interface: UserPropertyHandler
Adds a flexi-form Item for this UserPropertyHandler. The usageIdentifyer indicates in which form the element is to be used.

Parameters:
locale - The current users locale
user - The user containing data to be prefilled or NULL if it should be left empty
usageIdentifyer - The identifyer of the form where this form element is used
isAdministrativeUser - true: Form element will be set to administrative mode. false: the element is set to user mode. In some cases the field is then read-only
formItemContainer - Container to which Form Item has to be added
Returns:
The formItem will be added to formItemContainer
See Also:
UserPropertyHandler.addFormItem(java.util.Locale, org.olat.core.id.User, java.lang.String, boolean, org.olat.core.gui.components.form.flexible.FormItemContainer)

updateFormElementFromUser

public void updateFormElementFromUser(FormElement ui,
                                      User user)
Description copied from interface: UserPropertyHandler
Put the current value from this UserPropertyHandler into the given form element

Parameters:
ui - The form element previously created with the getFormElement method
user - The user that contains the data
See Also:
UserPropertyHandler.updateFormElementFromUser(org.olat.core.gui.formelements.FormElement, org.olat.core.id.User)

isValid

public boolean isValid(FormElement ui,
                       java.util.Map formContext)
Description copied from interface: UserPropertyHandler
Check if this form is valid

Parameters:
ui - The form element previously created with the getFormElement method
formContext - Map containing some variables used in this form context, e.g. for cross form value checks. NULL to not use any form context variables
Returns:
true: the entered value is ok; false: the entered value is not accepted (Validation error)
See Also:
org.olat.user.propertyhandlers.UserPropertyHandler#isValid(org.olat.core.gui.formelements.FormElement)

isValid

public boolean isValid(FormItem formItem,
                       java.util.Map formContext)
Description copied from interface: UserPropertyHandler
Checks if a form item for a property has a valid value and sets the appropriate error key if necessary. This is different from UserPropertyHandler.isValidValue(String, ValidationError, Locale) since it takes the value of the form item associated with this user property into account. Do all validations which depend on a form item here.

Parameters:
formItem - The flexi form item previously created with the addFormItem method
formContext - Map containing some variables used in this form context, e.g. for cross form value checks. NULL to not use any form context variables
Returns:
true: the entered value is ok; false: the entered value is not accepted (Validation error)
See Also:
UserPropertyHandler.isValid(org.olat.core.gui.components.form.flexible.FormItem, java.util.Map)

isValidValue

public boolean isValidValue(java.lang.String value,
                            ValidationError validationError,
                            java.util.Locale locale)
Description copied from interface: UserPropertyHandler
Checks if the given value is a valid value for this property (e.g. syntax checking). This is not connected to any form item, in contrast to UserPropertyHandler.isValid(FormItem, Map), so all validations which do not depend on a form item can be done here.

Parameters:
value - The value to be checked
validationError - Callback to get the error key in case of validation=false
Returns:
true: value is valid, false: value is invalid. Check validationError to get the error message
See Also:
UserPropertyHandler.isValidValue(java.lang.String, org.olat.core.gui.components.form.ValidationError, java.util.Locale)