tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nclay...@apache.org
Subject cvs commit: jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/valid ValidatingTextField.jwc ValidatingTextField.java
Date Tue, 03 Jun 2003 22:13:19 GMT
nclayton    2003/06/03 15:13:18

  Modified:    contrib/src/org/apache/tapestry/contrib/valid
                        ValidatingTextField.jwc ValidatingTextField.java
  Log:
  Correctly implemented the text parameter so that it re-uses the value implementation of
the superclass.
  
  Revision  Changes    Path
  1.3       +1 -1      jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/valid/ValidatingTextField.jwc
  
  Index: ValidatingTextField.jwc
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/valid/ValidatingTextField.jwc,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ValidatingTextField.jwc	1 Jun 2003 05:05:02 -0000	1.2
  +++ ValidatingTextField.jwc	3 Jun 2003 22:13:18 -0000	1.3
  @@ -1 +1 @@
  -<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id$ -->
<!DOCTYPE component-specification
PUBLIC 
  "-//Apache Software Foundation//Tapestry Specification 3.0//EN" 
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
 
<component-specification class="org.apache.tapestry.contrib.valid.ValidatingTextField"
allow-body="no">

  <parameter name="disabled" type="boolean" direction="in"/>  
 <parameter name="hidden" type="boolean" direction="in"/>
  <parameter name="displayWidth"
type="int" direction="in"/>
  <parameter name="maximumLength" type="int" direction="in"/>

 <parameter name="text" type="java.lang.String" required="yes" direction="custom"/>
 <parameter name="displayName" type="java.lang.String" required="yes" direction="custom"
/>
  <parameter name="minimumLength" type="java.lang.Integer" direction="custom" />
 <parameter name="required" direction="custom" />
 
  <reserved-parameter name="type"/>
 <reserved-parameter name="value"/>

</component-specification>
  \ No newline at end of file
  +<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id$ -->
<!DOCTYPE component-specification
PUBLIC 
  "-//Apache Software Foundation//Tapestry Specification 3.0//EN" 
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
 
<component-specification class="org.apache.tapestry.contrib.valid.ValidatingTextField"
allow-body="no">

  <parameter name="disabled" type="boolean" direction="in"/>  
 <parameter name="hidden" type="boolean" direction="in"/>
  <parameter name="displayWidth"
type="int" direction="in"/>
  <parameter name="maximumLength" type="int" direction="in"/>

 <parameter name="text" type="java.lang.String" required="yes" direction="custom"/>
 <parameter name="displayName" type="java.lang.String" required="yes" direction="auto"
/>
  <parameter name="minimumLength" type="java.lang.Integer" direction="custom" />
 <parameter name="required" direction="custom" />
 
  <reserved-parameter name="type"/>
 <reserved-parameter name="value"/>
  
  <property-specification name="name" type="java.lang.String"/>
 <property-specification name="form" type="org.apache.tapestry.IForm"/>

</component-specification>
  \ No newline at end of file
  
  
  
  1.3       +93 -65    jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/valid/ValidatingTextField.java
  
  Index: ValidatingTextField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/contrib/src/org/apache/tapestry/contrib/valid/ValidatingTextField.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ValidatingTextField.java	14 Apr 2003 20:10:05 -0000	1.2
  +++ ValidatingTextField.java	3 Jun 2003 22:13:18 -0000	1.3
  @@ -132,70 +132,98 @@
   
   public abstract class ValidatingTextField extends ValidField
   {
  -	public abstract IBinding getValueBinding();
  -	public abstract void setValueBinding(IBinding valueBinding);
  -	
  -    private IBinding minimumLengthBinding;
  -    private IBinding requiredBinding;
  -
  -    /** Returns the valueBinding. **/
  -
  -    public IBinding getTextBinding()
  -    {
  -        return getValueBinding();
  -    }
  -
  -    /** Updates valueBinding. **/
  -
  -    public void setTextBinding(IBinding value)
  -    {
  -        setValueBinding(value);
  -    }
  -
  -    public IBinding getMinimumLengthBinding()
  -    {
  -        return minimumLengthBinding;
  -    }
  -
  -    public void setMinimumLengthBinding(IBinding value)
  -    {
  -        minimumLengthBinding = value;
  -    }
  -
  -    public IBinding getRequiredBinding()
  -    {
  -        return requiredBinding;
  -    }
  -
  -    public void setRequiredBinding(IBinding requiredBinding)
  -    {
  -        this.requiredBinding = requiredBinding;
  -    }
  -
  -    /**
  -     * Overrides {@link ValidField#getValidator()} to construct
  -     * a validator on the fly.
  -     * 
  -     **/
  -
  -    public IValidator getValidator()
  -    {
  -        StringValidator validator = new StringValidator();
  -
  -        if (requiredBinding != null)
  -        {
  -            boolean required = requiredBinding.getBoolean();
  -
  -            validator.setRequired(required);
  -        }
  -
  -        if (minimumLengthBinding != null)
  -        {
  -            int minimumLength = minimumLengthBinding.getInt();
  +	private IBinding minimumLengthBinding;
  +	private IBinding requiredBinding;
  +	private IBinding valueBinding;
  +
  +	/* (non-Javadoc)
  +	 * @see org.apache.tapestry.valid.ValidField#getValue()
  +	 */
  +	public Object getValue()
  +	{
  +		if (getTextBinding() != null)
  +		{
  +			return getTextBinding().getObject();
  +		}
  +		return null;
  +	}
  +
  +	/* (non-Javadoc)
  +	 * @see org.apache.tapestry.valid.ValidField#setValue(java.lang.Object)
  +	 */
  +	public void setValue(Object value)
  +	{
  +		if(getTextBinding() != null) {
  +			getTextBinding().setObject(value);
  +		}			
  +		// otherwise do nothing, we have nowhere to bind the value to
  +	}
  +
  +	public IBinding getValueBinding()
  +	{
  +		return valueBinding;
  +	}
  +
  +	public void setValueBinding(IBinding binding)
  +	{
  +		valueBinding = binding;
  +	}
  +
  +	/** Returns the valueBinding. **/
  +	public IBinding getTextBinding()
  +	{
  +		return getValueBinding();
  +	}
  +
  +	/** Updates valueBinding. **/
  +	public void setTextBinding(IBinding value)
  +	{
  +		setValueBinding(value);
  +	}
  +
  +	public IBinding getMinimumLengthBinding()
  +	{
  +		return minimumLengthBinding;
  +	}
  +
  +	public void setMinimumLengthBinding(IBinding value)
  +	{
  +		minimumLengthBinding = value;
  +	}
  +
  +	public IBinding getRequiredBinding()
  +	{
  +		return requiredBinding;
  +	}
  +
  +	public void setRequiredBinding(IBinding requiredBinding)
  +	{
  +		this.requiredBinding = requiredBinding;
  +	}
  +
  +	/**
  +	 * Overrides {@link ValidField#getValidator()} to construct
  +	 * a validator on the fly.
  +	 * 
  +	 **/
  +	public IValidator getValidator()
  +	{
  +		StringValidator validator = new StringValidator();
  +
  +		if (requiredBinding != null)
  +		{
  +			boolean required = requiredBinding.getBoolean();
  +
  +			validator.setRequired(required);
  +		}
  +
  +		if (minimumLengthBinding != null)
  +		{
  +			int minimumLength = minimumLengthBinding.getInt();
   
  -            validator.setMinimumLength(minimumLength);
  -        }
  +			validator.setMinimumLength(minimumLength);
  +		}
   
  -        return validator;
  -    }
  +		return validator;
  +	}
   }
  
  
  

Mime
View raw message