System.Web.UI.WebControls
[ class tree: System.Web.UI.WebControls ] [ index: System.Web.UI.WebControls ] [ all elements ]

Class: TValidatorGroup

Source Location: /Web/UI/WebControls/TValidatorGroup.php

Class Overview

TComponent
   |
   --TControl
      |
      --TWebControl
         |
         --TValidator
            |
            --TValidatorGroup

TValidatorGroup class

Class Details

[line 79]
TValidatorGroup class

TValidatorGroup allows an arbituary set/group of validators to be active for a Web Control object event. For example, suppose you have two set of validators

Set A :

  • Validator with ID "Validator_A1"
  • Validator with ID "Validator_A2"
Set B :
  • Validator with ID "Validator_B1"
  • Validator with ID "Validator_B2"
In addition, you have two buttons with IDs "ButtonA" and "ButtonB". When "ButtonA" is clicked you want the validators in Set A to be validator, but not the validators in Set B. And similarly for "ButtonB" validators for Set B should be validated but not validators in Set A.

  1. <com:TTextbox ID="FirstName" />
  2. <com:TTextbox ID="Surname" />
  3.  
  4. <com:TRequiredFieldValidator ID="Validator_A1" ControlToValidate="FirstName" />
  5. <com:TRequiredFieldValidator ID="Validator_A2" ControlToValidate="Surname" />
  6.  
  7. <com:TTextbox ID="Phone" />
  8. <com:TTextbox ID="Fax" />
  9.  
  10. <com:TRequiredFieldValidator ID="Validator_B1" ControlToValidate="Phone" />
  11. <com:TRequiredFieldValidator ID="Validator_B2" ControlToValidate="Fax" />
  12.  
  13. <com:TValidatorGroup Members="Validator_A1, Validator_A2" Event="ButtonA:OnClick" />
  14. <com:TValidatorGroup Members="Validator_B1, Validator_B2" Event="ButtonB:OnClick" />
  15. <com:TButton ID="ButtonA" Text="Add Name" OnClick="addName" />
  16. <com:TButton ID="ButtonB" Text="Add Contact Details" OnClick="addContact" />

So when "ButtonA" is clicked, validators "Validator_A1" and "Validator_A2" will be validated, but NOT validators "Validator_B1" and "Validator_B2". After the validation, the event OnClick on ButtonA will be called, i.e. function "addName" will be called.

Properties

  • Members, string
    Gets or sets the validators for this group. The accepted value is in the form of validator IDs separated by commas. E.g. Members="Validator1, Validator2"
  • Event, string
    Gets or sets the Object and Event for activating this group of validators. The Event attribute must consist of a single web control object ID and a event on that object separated by a colon. e.g. Event="Button1:OnClick"




version:  $Revision: 1.11 $ $Date: 2005/09/02 07:46:39 $
author:  Xiang Wei Zhuo<weizhuo[at]gmail[dot]com>


[ Top ]

Methods


Inherited Variables

Inherited Methods

Class: TValidator

TValidator::enableClientScript()
Sets the value indicating whether client-side validation is enabled.
TValidator::escapeJS()
Escape javascript strings.
TValidator::evaluateIsValid()
This is the major method for validation.
TValidator::getAnchor()
Get the anchor href link for the error messages.
TValidator::getAnchoredMessage()
Returns the error message of which an link anchor and javascript focus call is added if the property Anchor is set.
TValidator::getControlCssClass()
Get the CssClass for the ControlToValidate when the validation failes. The CSS is appended to the control.
TValidator::getControlToValidate()
TValidator::getDisplay()
TValidator::getErrorMessage()
TValidator::getJsOptions()
Get a list of options for the client-side javascript validator
TValidator::getMessage()
Get the validation error message.
TValidator::getTargetControl()
TValidator::getText()
TValidator::isClientScriptEnabled()
TValidator::isEncodeText()
TValidator::isValid()
TValidator::onPreRender()
Overrides parent implementation by registering necessary Javascripts for validation.
TValidator::render()
Overrides parent implementation by rendering TValidator-specific presentation.
TValidator::renderJsOptions()
Render the array as javascript list.
TValidator::renderJsValidator()
Render the client-side javascript code.
TValidator::setAnchor()
Set the anchor ID for the error message link. If the value is "true" then the ID of the ControlToValidate will be used otherwise the given value will be used as the anchor.
TValidator::setControlCssClass()
Set the CssClass for the ControlToValidate component when the validation fails.
TValidator::setControlToValidate()
Sets the ID path of the input component to validate
TValidator::setDisplay()
Sets the display behavior (None, Static, Dynamic) of the error message in a validation component.
TValidator::setEnabled()
This method overrides parent's implementation by setting isValid to true if disabled.
TValidator::setEncodeText()
Sets the value indicating whether the text should be HTML encoded before rendering
TValidator::setErrorMessage()
Sets the text for the error message.
TValidator::setText()
Sets the text content of the validator.
TValidator::setValid()
Sets the value indicating whether the validation succeeds
TValidator::updateControlCssClass()
Update the ControlToValidate component's css class depending if the ControlCssClass property is set, and whether this is valid.
TValidator::validate()
Validates the specified component.

Class: TWebControl

TWebControl::appendJavascriptEvent()
Append a javascript statement to a particular attribute, e.g. "onclick".
TWebControl::getAccessKey()
TWebControl::getAttributesToRender()
This overrides the parent implementation by rendering more TWebControl-specific attributes.
TWebControl::getBackColor()
TWebControl::getBorderColor()
TWebControl::getBorderStyle()
TWebControl::getBorderWidth()
TWebControl::getCssClass()
TWebControl::getForeColor()
TWebControl::getHeight()
TWebControl::getJavascriptEvents()
Get the list of all the javascript statements.
TWebControl::getStyle()
TWebControl::getTabIndex()
TWebControl::getToolTip()
TWebControl::getWidth()
TWebControl::isEnabled()
TWebControl::parseStyle()
Parses a CSS style string into an array representation.
TWebControl::removeJavascriptEvent()
Remove all or a particular javascript statements.
TWebControl::setAccessKey()
Sets the access key of the control.
TWebControl::setBackColor()
Sets the background color of the control
TWebControl::setBorderColor()
Sets the border color of the control
TWebControl::setBorderStyle()
Sets the border style of the control
TWebControl::setBorderWidth()
Sets the border width of the control
TWebControl::setCssClass()
Sets the CSS class name of the control
TWebControl::setEnabled()
Enables or disables a control.
TWebControl::setForeColor()
Sets the foreground color of the control
TWebControl::setHeight()
Sets the height of the control
TWebControl::setStyle()
Sets the CSS style of the control.
TWebControl::setTabIndex()
Sets the tab index of the control.
TWebControl::setToolTip()
Sets the tooltip of the control.
TWebControl::setWidth()
Sets the width of the control

Class: TControl

TControl::__construct()
Constructor.
TControl::addBody()
Appends an object into the body collection of this control.
TControl::addParsedObject()
Adds the object parsed in template as a body of the component.
TControl::allowBody()
Determines whether the control can add the object as a body.
TControl::clearViewState()
Clears viewstate
TControl::findBodyControl()
TControl::getAttribute()
TControl::getAttributes()
Returns the attribute list object.
TControl::getAttributesToRender()
Returns attributes to be rendered.
TControl::getBodies()
TControl::getClientID()
Returns the client ID of the component.
TControl::getContainer()
Returns the container of this component.
TControl::getSkinName()
TControl::getTagName()
TControl::getViewState()
Returns a viewstate value.
TControl::initSkin()
Initializes a skin for the control. If a skin name is provided then that skin will be loaded.
TControl::isViewStateEnabled()
TControl::isVisible()
This method checks whether a control is visible.
TControl::loadViewState()
Loads viewstate into this component and its children.
TControl::onBubbleEvent()
This method responds to a bubbled event.
TControl::onInit()
This method is invoked when the control enters 'Init' stage.
TControl::onInitRecursive()
Calls onInit of this control and its children recursively.
TControl::onLoad()
This method is invoked when the control enters 'Load' stage.
TControl::onLoadRecursive()
Calls onLoad of this control and its children recursively.
TControl::onPreRender()
This method is invoked when the control enters 'PreRender' stage.
TControl::onPreRenderRecursive()
Calls onPreRender of this control and its children recursively.
TControl::onUnload()
This method is invoked when the control enters 'Unload' stage.
TControl::onUnloadRecursive()
Calls onUnload of this control and its children recursively.
TControl::raiseBubbleEvent()
Invokes the parent's onBubbleEvent method.
TControl::removeBodies()
Removes all body content.
TControl::render()
Renders this control.
TControl::renderAttributes()
Renders the attributes.
TControl::renderBody()
Renders the body content.
TControl::saveViewState()
Returns the viewstate of this component and its children.
TControl::setAttribute()
Sets an attribute.
TControl::setContainer()
Sets the container of this component
TControl::setEnableViewState()
TControl::setSkinName()
Sets the skin to use for this control
TControl::setTagName()
Sets the tag name.
TControl::setViewState()
Sets a viewstate value.
TControl::setVisible()
TControl::synchronizeControl()
This method should only be used by framework developer.

Class: TComponent

TComponent::__construct()
Constructor.
TComponent::addChild()
Adds a child component.
TComponent::addParsedObject()
Handles a component or string met in template.
TComponent::attachEventHandler()
Attaches a handler function to an event.
TComponent::bindProperty()
Sets up the binding between a property and an expression.
TComponent::canGetProperty()
Determines whether a property can be read.
TComponent::canSetProperty()
Determines whether a property can be written.
TComponent::createComponent()
Creates a child component.
TComponent::dataBind()
Performs the databinding for this component.
TComponent::evaluateExpression()
Evaluates a PHP expression.
TComponent::evaluateStatements()
Evaluates a list of PHP statements.
TComponent::findObject()
Finds an object by its ID path.
TComponent::getApplication()
TComponent::getChild()
TComponent::getChildren()
TComponent::getDefinition()
Returns or builds a component definition.
TComponent::getGlobalization()
Returns the Globalization instance for the application.
TComponent::getID()
TComponent::getModule()
Returns the module object that contains the component or the page containing the component.
TComponent::getPage()
TComponent::getParent()
TComponent::getPropertyInitValue()
Gets the initial value of a property.
TComponent::getPropertyType()
Returns the type of a property
TComponent::getRequest()
Returns the request object associated with application.
TComponent::getServiceManager()
Returns the service manager for this application.
TComponent::getSession()
Returns the session object associated with the application.
TComponent::getSessionState()
Returns a session variable.
TComponent::getUniqueID()
Returns the unique ID of the component.
TComponent::getUser()
Returns the user object associated with the application.
TComponent::hasChildren()
TComponent::hasEvent()
Determines whether an event is defined.
TComponent::hasProperty()
Determines whether a property is defined.
TComponent::initProperties()
Initializes the property values.
TComponent::instantiateTemplate()
Parses a template string and instantiates the content.
TComponent::onDataBinding()
This method is invoked when dataBind is invoked for the component.
TComponent::raiseEvent()
Invokes all attached event handler functions for a particular event.
TComponent::removeChild()
Removes a child component.
TComponent::removeChildren()
Removes all child components.
TComponent::setAttribute()
Sets an attribute.
TComponent::setDefinition()
Sets a component definition.
TComponent::setID()
Sets a component ID.
TComponent::setParent()
Sets the parent of this component.
TComponent::setPropertyInitValue()
Sets the initial value of a property.
TComponent::setRoot()
Sets the root component in the component hierarchy.
TComponent::setSessionState()
Sets a session variable.
TComponent::unbindProperty()
Breaks the binding between a property and an expression.
TComponent::__get()
Returns a property value by name or a child component by ID.
TComponent::__set()
Sets value of a component property.

Class Methods


method getEvent [line 160]

string getEvent( )



return:  the control and event name for which the validator is activated.
access:  public


[ Top ]

method getJsOptions [line 341]

array getJsOptions( )

Get a list of options for the client side javascript group validation.



return:  list of options.
access:  protected


Overrides TValidator::getJsOptions() (Get a list of options for the client-side javascript validator)

[ Top ]

method getMembers [line 136]

array getMembers( )



return:  validator group member IDs.
access:  public


[ Top ]

method isActive [line 119]

boolean isActive( )

Is the group currently active.



return:  true if group is active, false otherwise.
access:  public


[ Top ]

method isGroupValidation [line 128]

boolean isGroupValidation( )

Is group validation performed? True if any group is active.



return:  true if any group is active, false otherwise.
static:  
access:  public


[ Top ]

method loadValidatorStates [line 239]

void loadValidatorStates( )

Load/restore all the validator disabled/enabled states on this page.



access:  protected


[ Top ]

method onLoad [line 275]

void onLoad( TEventParameter $params)

This overrides the parent implementation by doing the group validation.



access:  protected
see:  TValidatorGroup::validateGroup() Parent::OnLoad($params) is called.


Overrides TControl::onLoad() (This method is invoked when the control enters 'Load' stage.)

Parameters:

TEventParameter   $params   event parameter to be passed to the event handlers

[ Top ]

method onPreRender [line 261]

void onPreRender( TEventParameter $param)

This overrides the parent implementation by restoring all the validator disabled/enabled states. Parent::OnPreRender($param) is called.



access:  public


Overrides TValidator::onPreRender() (Overrides parent implementation by registering necessary Javascripts for validation.)

Parameters:

TEventParameter   $param   event parameter to be passed to the event handlers

[ Top ]

method render [line 317]

string render( )

Overrides parent implementation by registering the validation group javascripts.



return:  the rendering result
access:  public


Overrides TValidator::render() (Overrides parent implementation by rendering TValidator-specific presentation.)

[ Top ]

method renderJsMembers [line 357]

string renderJsMembers( )

Render the list of validator IDs as javascript array.



return:  client-side validator IDs javascript array.
access:  protected


[ Top ]

method renderJsValidator [line 326]

void renderJsValidator( array $options)

Render the javascript for the client side group validation.



access:  protected


Overrides TValidator::renderJsValidator() (Render the client-side javascript code.)

Parameters:

array   $options   list of options for the group validator.

[ Top ]

method saveValidatorStates [line 224]

void saveValidatorStates( )

Save all the validator disabled/enabled states on this page.



access:  protected


[ Top ]

method setEvent [line 175]

void setEvent( string $control)

Set the control object and the event to which the validator group is activated.

The Event attribute must consist of a web control object ID and the event on that object separated by a colon. E.g. Suppose we have a button with ID "Button1", and we want the validators to be activated by this button when clicked, we set <em>Event="Button1:OnClick"</em>.




access:  public


Parameters:

string   $control   colon separated control object ID and its event.

[ Top ]

method setMembers [line 149]

void setMembers( string $members)

Sets the members for this validator group.

The Member attribute is a string in the form of validator IDs separated by commas. E.g. if there are validators with IDs "VPCheck1" and "VPCheck2", then we have <em>Members="VPCheck1, VPCheck2"</em>.




access:  public


Parameters:

string   $members   comma separated validator IDs

[ Top ]

method validateGroup [line 195]

void validateGroup( TControl $sender, TEventParameter $params)

Group validation event.

This event is activated on the OnLoad event of the TValidatorGroup component. The validation is processed as follows.

  • Get all the validators on the page.
  • Save all the validator enabled/disabled states.
  • Get the validators for this group.
  • Disable the validators NOT belonging to this group
  • Call page::validate();
The restoring of the validators completed in OnPreRender event.




access:  protected


Parameters:

TControl   $sender   sender of the event
TEventParameter   $params   event parameter

[ Top ]


© 2004-2005 PRADO Software Group. All Rights Reserved.