org.olat.user.propertyhandlers
Class URLPropertyHandler

java.lang.Object
  extended by org.olat.user.AbstractUserPropertyHandler
      extended by org.olat.user.propertyhandlers.Generic127CharTextPropertyHandler
          extended by org.olat.user.propertyhandlers.URLPropertyHandler
All Implemented Interfaces:
ItemValidatorProvider, UserPropertyHandler

public class URLPropertyHandler
extends Generic127CharTextPropertyHandler

Description:

The url field provides a user property that contains a valid URL.

Initial Date: 27.07.2007

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

Constructor Summary
URLPropertyHandler()
           
 
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 getUserPropertyAsHTML(User user, java.util.Locale locale)
           
 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.
 
Methods inherited from class org.olat.user.propertyhandlers.Generic127CharTextPropertyHandler
getStringValue, getStringValue, getStringValue, updateFormElementFromUser, updateUserFromFormElement, updateUserFromFormItem
 
Methods inherited from class org.olat.user.AbstractUserPropertyHandler
getColumnDescriptor, getGroup, getName, getUserProperty, 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

URLPropertyHandler

public URLPropertyHandler()
Method Detail

getUserPropertyAsHTML

public java.lang.String getUserPropertyAsHTML(User user,
                                              java.util.Locale locale)
Specified by:
getUserPropertyAsHTML in interface UserPropertyHandler
Overrides:
getUserPropertyAsHTML in class AbstractUserPropertyHandler
Parameters:
user - the user for which we want to get the value
locale - the current users locale or NULL if default locale should be used.
Returns:
The value formatted in HTML or an empty String if no value exists
See Also:
AbstractUserPropertyHandler.getUserPropertyAsHTML(org.olat.core.id.User, 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.

Specified by:
getFormElement in interface UserPropertyHandler
Overrides:
getFormElement in class Generic127CharTextPropertyHandler
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:
Generic127CharTextPropertyHandler.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.

Specified by:
addFormItem in interface UserPropertyHandler
Overrides:
addFormItem in class Generic127CharTextPropertyHandler
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)

isValid

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

Specified by:
isValid in interface UserPropertyHandler
Overrides:
isValid in class Generic127CharTextPropertyHandler
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.Generic127CharTextPropertyHandler#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.

Specified by:
isValid in interface UserPropertyHandler
Overrides:
isValid in class Generic127CharTextPropertyHandler
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.

Specified by:
isValidValue in interface ItemValidatorProvider
Specified by:
isValidValue in interface UserPropertyHandler
Overrides:
isValidValue in class Generic127CharTextPropertyHandler
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)