You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Harish Krishnaswamy <hk...@comcast.net> on 2003/09/14 20:04:47 UTC

Some thoughts on contrib components - DateField, NumericField etc

I think we need to keep the typed field components in contrib just so we 
can provide compile time type safety.

But, I think, the validators in these components should be externalized 
for the following reasons.

   1. Right now there is no way of sharing the validators across
      multiple instances of these components
   2. Removes code duplication / clutter from these components and there
      by eases maintenance
   3. IoC (!)

So, for example the DateField will now be as follows. Note that this is 
identical to the ValidField's spec except for the validator parts.

Specification:
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: Button.jwc,v 1.4 2003/08/06 14:28:48 hlship Exp $ -->
<!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.DateField"
    allow-body="no">

  <parameter name="value" type="java.lang.Object" required="yes" 
direction="auto"/>
 
  <parameter name="dateValidator" 
type="org.apache.tapestry.valid.DateValidator"
      required="yes" direction="in">
    <description>
        Converts value to a string and parses strings back into object 
values.
    </description>
  </parameter>
   
  <parameter name="displayName" type="java.lang.String" required="yes" 
direction="auto">
    <description>
        Name used by FieldLabel and when generating validation error 
messages.
    </description>
  </parameter>
 
  <parameter name="disabled" type="boolean" direction="in"/>
  <parameter name="hidden" type="boolean" direction="in"/>
   
  <reserved-parameter name="type"/>
  <reserved-parameter name="name"/>
  <reserved-parameter name="value"/>
 
  <property-specification name="name" type="java.lang.String"/>
  <property-specification name="form" type="org.apache.tapestry.IForm"/>
  <property-specification name="validator" 
type="org.apache.tapestry.valid.IValidator" />
 
</component-specification>


Component class:
public abstract class DateField extends ValidField
{
    public abstract void setValidator(IValidator validator);
   
    public void setDateValidator(DateValidator dateValidator)
    {
        setValidator(dateValidator);
    }
   
    public DateValidator getDateValidator()
    {
        return (DateValidator) getValidator();
    }
}

Any thoughts?

Regards,
Harish


Re: Some thoughts on contrib components - DateField, NumericField etc

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Please disregard the previous mail. The example is buggy, I don't know 
how that even worked.

Specification:
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: Button.jwc,v 1.4 2003/08/06 14:28:48 hlship Exp $ -->
<!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.DateField"
   allow-body="no">

 <parameter name="value" type="java.lang.Object" required="yes" 
direction="auto"/>

 <parameter name="dateValidator" 
type="org.apache.tapestry.valid.DateValidator"
     required="yes" direction="in">
   <description>
       Converts value to a string and parses strings back into object 
values.
   </description>
 </parameter>
   <parameter name="displayName" type="java.lang.String" required="yes" 
direction="auto">
   <description>
       Name used by FieldLabel and when generating validation error 
messages.
   </description>
 </parameter>

 <parameter name="disabled" type="boolean" direction="in"/>
 <parameter name="hidden" type="boolean" direction="in"/>
   <reserved-parameter name="type"/>
 <reserved-parameter name="name"/>
 <reserved-parameter name="value"/>

 <property-specification name="name" type="java.lang.String"/>
 <property-specification name="form" type="org.apache.tapestry.IForm"/>

</component-specification>

Component class:
public abstract class DateField extends ValidField
{
    public abstract DateValidator getDateValidator();
   
    public IValidator getValidator()
    {
        return getDateValidator();
    }
}

Regards,
Harish



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org