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 2004/01/15 06:42:29 UTC
Tracking of component errors recorded in the business tier
Hi,
For some of our domain objects, we have a couple different ways of capturing the data, Tapestry is
one of them. For this reason, I would like to move my validations to the business tier (even
otherwise this is probably the right place for business rules validations). This is not a problem
unless have a component inside a Foreach. Now, even if I register the component with the delegate,
there is no way of letting the delegate know exactly which occurrence of the component in the loop
had the problem. And the "error decoration" always appears for the last rendered component in the loop.
So I have played around and managed to make things work. Here's what I have done...
1. Added component occurrence counter to IdAllocator$NameGenerator. This will hold the actual count
of the times the component was rendered (doesn't count the "degenerate" case).
2. Added a property (counter) to AbstractFormComponent to hold the count of the rendered component.
This property + the component id will give a unique key for the FieldTrackings form map.
3. Added new method getElementCount() in Form to return the count of the component occurrence. This
will be used by the validation delegate to record a failed field in the trackings form map.
4. The validation delegate's findCurrentTrackings() uses the componentId + getElementCount() as the
key to register the component in the trackings form map.
5. The getComponentTrakings uses the componentId + getElementCount() to retrieve the tracking from
the trackings form map.
Now I can validate a list in the listener method and record the errors thus (not a realistic example):
IFormComponent component = (IFormComponent) getComponents().get("loopFld");
delegate.setFormComponent(component);
component.setIndex(0); // Extra new step to indentify the index
delegate.record("Invalid cust name.", null);
component.setIndex(2); // Extra new step to indentify the index
delegate.record("Invalid cust name.", null);
This doesn't break the current behavior and should be very transparent.
I don't see why all form components can't be validatable components. We can have a NullValidator
that can be used by default. Perhaps for 3.1 under a new ValidationService :)
So is this committable?
-Harish
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
Re: Tracking of component errors recorded in the business tier
Posted by Harish Krishnaswamy <hk...@comcast.net>.
I was hesitant myself to release this in 3.0. Ok I shall create a patch and put it in Bugzilla.
-Harish
Howard M. Lewis Ship wrote:
> Or just provide Harish's changes in a semi-official patch stored in Bugzilla?
>
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Tapestry: Java Web Components
> http://jakarta.apache.org/tapestry/
> http://javatapestry.blogspot.com
>
>
>>-----Original Message-----
>>From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
>>Sent: Thursday, January 15, 2004 8:24 AM
>>To: Tapestry development
>>Subject: Re: Tracking of component errors recorded in the
>>business tier
>>
>>
>>I agree with Howard. Let's get 3.0 released before any other changes.
>>
>>However, I'm about to start implementing validation on
>>@Foreach nested
>>custom components and probably will want the changes that Harish is
>>proposing. Perhaps we could branch CVS and let Harish work off a 3.1
>>(or HARISH_VALIDATION) branch?
>>
>> Erik
>>
>>
>>On Jan 15, 2004, at 7:39 AM, Howard M. Lewis Ship wrote:
>>
>>
>>>I know this is important, but I would rather do this first thing in
>>>release 3.1 than last thing in
>>>3.0. I'm very cautious.
>>>
>>>--
>>>Howard M. Lewis Ship
>>>Independent J2EE / Open-Source Java Consultant
>>>Creator, Tapestry: Java Web Components
>>>http://jakarta.apache.org/tapestry/
>>>http://javatapestry.blogspot.com
>>>
>>>
>>>>-----Original Message-----
>>>>From: Harish Krishnaswamy [mailto:hkrishnaswamy@comcast.net]
>>>>Sent: Thursday, January 15, 2004 12:42 AM
>>>>To: Tapestry development
>>>>Subject: Tracking of component errors recorded in the business tier
>>>>
>>>>
>>>>Hi,
>>>>
>>>>For some of our domain objects, we have a couple different
>>>>ways of capturing the data, Tapestry is
>>>>one of them. For this reason, I would like to move my
>>>>validations to the business tier (even
>>>>otherwise this is probably the right place for business rules
>>>>validations). This is not a problem
>>>>unless have a component inside a Foreach. Now, even if I
>>>>register the component with the delegate,
>>>>there is no way of letting the delegate know exactly which
>>>>occurrence of the component in the loop
>>>>had the problem. And the "error decoration" always appears
>>>>for the last rendered component in the loop.
>>>>
>>>>So I have played around and managed to make things work.
>>>>Here's what I have done...
>>>>
>>>>1. Added component occurrence counter to
>>>>IdAllocator$NameGenerator. This will hold the actual count
>>>>of the times the component was rendered (doesn't count the
>>>>"degenerate" case).
>>>>2. Added a property (counter) to AbstractFormComponent to
>>>>hold the count of the rendered component.
>>>>This property + the component id will give a unique key for
>>>>the FieldTrackings form map.
>>>>3. Added new method getElementCount() in Form to return the
>>>>count of the component occurrence. This
>>>>will be used by the validation delegate to record a failed
>>>>field in the trackings form map.
>>>>4. The validation delegate's findCurrentTrackings() uses the
>>>>componentId + getElementCount() as the
>>>>key to register the component in the trackings form map.
>>>>5. The getComponentTrakings uses the componentId +
>>>>getElementCount() to retrieve the tracking from
>>>>the trackings form map.
>>>>
>>>>Now I can validate a list in the listener method and record
>>>>the errors thus (not a realistic example):
>>>>
>>>> IFormComponent component = (IFormComponent)
>>>>getComponents().get("loopFld");
>>>> delegate.setFormComponent(component);
>>>>
>>>> component.setIndex(0); // Extra new step to
>>>>indentify the index
>>>> delegate.record("Invalid cust name.", null);
>>>>
>>>> component.setIndex(2); // Extra new step to
>>>>indentify the index
>>>> delegate.record("Invalid cust name.", null);
>>>>
>>>>This doesn't break the current behavior and should be very
>>>>transparent.
>>>>
>>>>I don't see why all form components can't be validatable
>>>>components. We can have a NullValidator
>>>>that can be used by default. Perhaps for 3.1 under a new
>>>>ValidationService :)
>>>>
>>>>So is this committable?
>>>>
>>>>-Harish
>>>>
>>>>
>>>>
>>>>
>>
>>---------------------------------------------------------------------
>>
>>>>To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail:
>>
>>tapestry-dev-help@jakarta.apache.org
>>
>>>
>>>
>>---------------------------------------------------------------------
>>
>>>To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail:
>>
>>tapestry-dev-help@jakarta.apache.org
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
RE: Tracking of component errors recorded in the business tier
Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
Or just provide Harish's changes in a semi-official patch stored in Bugzilla?
--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry/
http://javatapestry.blogspot.com
> -----Original Message-----
> From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
> Sent: Thursday, January 15, 2004 8:24 AM
> To: Tapestry development
> Subject: Re: Tracking of component errors recorded in the
> business tier
>
>
> I agree with Howard. Let's get 3.0 released before any other changes.
>
> However, I'm about to start implementing validation on
> @Foreach nested
> custom components and probably will want the changes that Harish is
> proposing. Perhaps we could branch CVS and let Harish work off a 3.1
> (or HARISH_VALIDATION) branch?
>
> Erik
>
>
> On Jan 15, 2004, at 7:39 AM, Howard M. Lewis Ship wrote:
>
> > I know this is important, but I would rather do this first thing in
> > release 3.1 than last thing in
> > 3.0. I'm very cautious.
> >
> > --
> > Howard M. Lewis Ship
> > Independent J2EE / Open-Source Java Consultant
> > Creator, Tapestry: Java Web Components
> > http://jakarta.apache.org/tapestry/
> > http://javatapestry.blogspot.com
> >
> >> -----Original Message-----
> >> From: Harish Krishnaswamy [mailto:hkrishnaswamy@comcast.net]
> >> Sent: Thursday, January 15, 2004 12:42 AM
> >> To: Tapestry development
> >> Subject: Tracking of component errors recorded in the business tier
> >>
> >>
> >> Hi,
> >>
> >> For some of our domain objects, we have a couple different
> >> ways of capturing the data, Tapestry is
> >> one of them. For this reason, I would like to move my
> >> validations to the business tier (even
> >> otherwise this is probably the right place for business rules
> >> validations). This is not a problem
> >> unless have a component inside a Foreach. Now, even if I
> >> register the component with the delegate,
> >> there is no way of letting the delegate know exactly which
> >> occurrence of the component in the loop
> >> had the problem. And the "error decoration" always appears
> >> for the last rendered component in the loop.
> >>
> >> So I have played around and managed to make things work.
> >> Here's what I have done...
> >>
> >> 1. Added component occurrence counter to
> >> IdAllocator$NameGenerator. This will hold the actual count
> >> of the times the component was rendered (doesn't count the
> >> "degenerate" case).
> >> 2. Added a property (counter) to AbstractFormComponent to
> >> hold the count of the rendered component.
> >> This property + the component id will give a unique key for
> >> the FieldTrackings form map.
> >> 3. Added new method getElementCount() in Form to return the
> >> count of the component occurrence. This
> >> will be used by the validation delegate to record a failed
> >> field in the trackings form map.
> >> 4. The validation delegate's findCurrentTrackings() uses the
> >> componentId + getElementCount() as the
> >> key to register the component in the trackings form map.
> >> 5. The getComponentTrakings uses the componentId +
> >> getElementCount() to retrieve the tracking from
> >> the trackings form map.
> >>
> >> Now I can validate a list in the listener method and record
> >> the errors thus (not a realistic example):
> >>
> >> IFormComponent component = (IFormComponent)
> >> getComponents().get("loopFld");
> >> delegate.setFormComponent(component);
> >>
> >> component.setIndex(0); // Extra new step to
> >> indentify the index
> >> delegate.record("Invalid cust name.", null);
> >>
> >> component.setIndex(2); // Extra new step to
> >> indentify the index
> >> delegate.record("Invalid cust name.", null);
> >>
> >> This doesn't break the current behavior and should be very
> >> transparent.
> >>
> >> I don't see why all form components can't be validatable
> >> components. We can have a NullValidator
> >> that can be used by default. Perhaps for 3.1 under a new
> >> ValidationService :)
> >>
> >> So is this committable?
> >>
> >> -Harish
> >>
> >>
> >>
> >>
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail:
> tapestry-dev-help@jakarta.apache.org
> >>
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> tapestry-dev-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
Re: Tracking of component errors recorded in the business tier
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
I agree with Howard. Let's get 3.0 released before any other changes.
However, I'm about to start implementing validation on @Foreach nested
custom components and probably will want the changes that Harish is
proposing. Perhaps we could branch CVS and let Harish work off a 3.1
(or HARISH_VALIDATION) branch?
Erik
On Jan 15, 2004, at 7:39 AM, Howard M. Lewis Ship wrote:
> I know this is important, but I would rather do this first thing in
> release 3.1 than last thing in
> 3.0. I'm very cautious.
>
> --
> Howard M. Lewis Ship
> Independent J2EE / Open-Source Java Consultant
> Creator, Tapestry: Java Web Components
> http://jakarta.apache.org/tapestry/
> http://javatapestry.blogspot.com
>
>> -----Original Message-----
>> From: Harish Krishnaswamy [mailto:hkrishnaswamy@comcast.net]
>> Sent: Thursday, January 15, 2004 12:42 AM
>> To: Tapestry development
>> Subject: Tracking of component errors recorded in the business tier
>>
>>
>> Hi,
>>
>> For some of our domain objects, we have a couple different
>> ways of capturing the data, Tapestry is
>> one of them. For this reason, I would like to move my
>> validations to the business tier (even
>> otherwise this is probably the right place for business rules
>> validations). This is not a problem
>> unless have a component inside a Foreach. Now, even if I
>> register the component with the delegate,
>> there is no way of letting the delegate know exactly which
>> occurrence of the component in the loop
>> had the problem. And the "error decoration" always appears
>> for the last rendered component in the loop.
>>
>> So I have played around and managed to make things work.
>> Here's what I have done...
>>
>> 1. Added component occurrence counter to
>> IdAllocator$NameGenerator. This will hold the actual count
>> of the times the component was rendered (doesn't count the
>> "degenerate" case).
>> 2. Added a property (counter) to AbstractFormComponent to
>> hold the count of the rendered component.
>> This property + the component id will give a unique key for
>> the FieldTrackings form map.
>> 3. Added new method getElementCount() in Form to return the
>> count of the component occurrence. This
>> will be used by the validation delegate to record a failed
>> field in the trackings form map.
>> 4. The validation delegate's findCurrentTrackings() uses the
>> componentId + getElementCount() as the
>> key to register the component in the trackings form map.
>> 5. The getComponentTrakings uses the componentId +
>> getElementCount() to retrieve the tracking from
>> the trackings form map.
>>
>> Now I can validate a list in the listener method and record
>> the errors thus (not a realistic example):
>>
>> IFormComponent component = (IFormComponent)
>> getComponents().get("loopFld");
>> delegate.setFormComponent(component);
>>
>> component.setIndex(0); // Extra new step to
>> indentify the index
>> delegate.record("Invalid cust name.", null);
>>
>> component.setIndex(2); // Extra new step to
>> indentify the index
>> delegate.record("Invalid cust name.", null);
>>
>> This doesn't break the current behavior and should be very
>> transparent.
>>
>> I don't see why all form components can't be validatable
>> components. We can have a NullValidator
>> that can be used by default. Perhaps for 3.1 under a new
>> ValidationService :)
>>
>> So is this committable?
>>
>> -Harish
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
RE: Tracking of component errors recorded in the business tier
Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
I know this is important, but I would rather do this first thing in release 3.1 than last thing in
3.0. I'm very cautious.
--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry/
http://javatapestry.blogspot.com
> -----Original Message-----
> From: Harish Krishnaswamy [mailto:hkrishnaswamy@comcast.net]
> Sent: Thursday, January 15, 2004 12:42 AM
> To: Tapestry development
> Subject: Tracking of component errors recorded in the business tier
>
>
> Hi,
>
> For some of our domain objects, we have a couple different
> ways of capturing the data, Tapestry is
> one of them. For this reason, I would like to move my
> validations to the business tier (even
> otherwise this is probably the right place for business rules
> validations). This is not a problem
> unless have a component inside a Foreach. Now, even if I
> register the component with the delegate,
> there is no way of letting the delegate know exactly which
> occurrence of the component in the loop
> had the problem. And the "error decoration" always appears
> for the last rendered component in the loop.
>
> So I have played around and managed to make things work.
> Here's what I have done...
>
> 1. Added component occurrence counter to
> IdAllocator$NameGenerator. This will hold the actual count
> of the times the component was rendered (doesn't count the
> "degenerate" case).
> 2. Added a property (counter) to AbstractFormComponent to
> hold the count of the rendered component.
> This property + the component id will give a unique key for
> the FieldTrackings form map.
> 3. Added new method getElementCount() in Form to return the
> count of the component occurrence. This
> will be used by the validation delegate to record a failed
> field in the trackings form map.
> 4. The validation delegate's findCurrentTrackings() uses the
> componentId + getElementCount() as the
> key to register the component in the trackings form map.
> 5. The getComponentTrakings uses the componentId +
> getElementCount() to retrieve the tracking from
> the trackings form map.
>
> Now I can validate a list in the listener method and record
> the errors thus (not a realistic example):
>
> IFormComponent component = (IFormComponent)
> getComponents().get("loopFld");
> delegate.setFormComponent(component);
>
> component.setIndex(0); // Extra new step to
> indentify the index
> delegate.record("Invalid cust name.", null);
>
> component.setIndex(2); // Extra new step to
> indentify the index
> delegate.record("Invalid cust name.", null);
>
> This doesn't break the current behavior and should be very
> transparent.
>
> I don't see why all form components can't be validatable
> components. We can have a NullValidator
> that can be used by default. Perhaps for 3.1 under a new
> ValidationService :)
>
> So is this committable?
>
> -Harish
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org