You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Peter Butler <pe...@141.com> on 2004/01/15 21:56:45 UTC

Component name changing between rewind/render cycles?

Hi All

Ok, I'm stumped.  I have a subclass of TextArea called ValidTextArea.
It's similar to ValidField in that it has properties for validator and
displayName, and it uses the validator to record errors like this:

ValidTextArea.java:
	protected void renderComponent(IMarkupWriter writer,
IRequestCycle cycle) {
		....
		if (!rendering && !isDisabled()) {
			String value =
cycle.getRequestContext().getParameter(name);
			updateValue(value);
		}
		....
	}

	protected void updateValue(String value) {
		Object objectValue = null;
		IValidationDelegate delegate = getForm().getDelegate();

		delegate.recordFieldInputValue(value);

		try {
			objectValue = getValidator().toObject(this,
value);
		} catch (ValidatorException ex) {
			delegate.record(ex);
			return;
		}

		setValue((String)objectValue);
	}	

I have an instance of this component on a form like this:

<input jwcid="address@ValidTextArea" value="ognl:address"
validator="ognl:beans.basicValidator" displayName="Address"/>

So in the rewind cycle, the component name is "address", and the error
is recorded in the delegate under this name.  But in the subsequent
render cycle, the component name is "address$0".  This means that the
ValidationDelegate.isInError() returns false (because there is no
FieldTracking stored under the name "address$0").  So the error is
recorded but my SimpleValidationDelegate.writeAttributes does not
generate the correct error attribute.

I can't figure out why the component name is changing on the rewind and
render cycles.  Has anyone come across this before?

Cheers

Peter


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


RE: Component name changing between rewind/render cycles?

Posted by Peter Butler <pe...@141.com>.
Well, once I'm finished these I'll put them up so you can use them (or
at least have a look).

Peter

www.clever.co.nz

-----Original Message-----
From: Martin DeMello [mailto:martindemello@yahoo.com] 
Sent: Friday, 16 January 2004 1:03 p.m.
To: Tapestry users
Subject: RE: Component name changing between rewind/render cycles?


--- Peter Butler <pe...@141.com> wrote:
> 
> By the way, is there any existing implementation of the standard 
> Tapestry components as "Valid" components (i.e. ValidRadio, 
> ValidPropertySelection, etc).  I've already implemented ValidTextArea 
> and ValidDatePicker but I'd hate to be duplicating effort.

It'd be nice to have a 'trivial components' repository for this sort of
thing - easy to do, but almost invariably involving a few hours' worth
of debugging (at least for me - maybe less once I'm a bit more
experienced w/ tapestry and java)

martin

__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

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



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


RE: Component name changing between rewind/render cycles?

Posted by Martin DeMello <ma...@yahoo.com>.
--- Peter Butler <pe...@141.com> wrote:
> 
> By the way, is there any existing implementation of the standard
> Tapestry components as "Valid" components (i.e. ValidRadio,
> ValidPropertySelection, etc).  I've already implemented ValidTextArea
> and ValidDatePicker but I'd hate to be duplicating effort.

It'd be nice to have a 'trivial components' repository for this sort of thing -
easy to do, but almost invariably involving a few hours' worth of debugging (at
least for me - maybe less once I'm a bit more experienced w/ tapestry and java)

martin

__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus

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


RE: Component name changing between rewind/render cycles?

Posted by Peter Butler <pe...@141.com>.
Thanks for the tip, it means I can avoid a lot more debugging!

By the way, is there any existing implementation of the standard
Tapestry components as "Valid" components (i.e. ValidRadio,
ValidPropertySelection, etc).  I've already implemented ValidTextArea
and ValidDatePicker but I'd hate to be duplicating effort.

Cheers

Peter

www.clever.co.nz

-----Original Message-----
From: Harish Krishnaswamy [mailto:hkrishnaswamy@comcast.net] 
Sent: Friday, 16 January 2004 11:05 a.m.
To: Tapestry users
Subject: Re: Component name changing between rewind/render cycles?


If you were using getElementId before you might probably want to use
getName() instead of getId(). 
The id will be the same for multiple occurrences of the component.

-Harish

Peter Butler wrote:

> Yes, I am - once in TextArea.renderComponent() and once in 
> ValidTextArea.renderComponent().  I've replaced the call in 
> ValidTextArea with this.getId() and it seems to be working fine.  
> Thanks very much for your help, I've been debugging this for hours!
> 
> Cheers
> 
> Peter
> 
> -----Original Message-----
> From: Harish Krishnaswamy [mailto:hkrishnaswamy@comcast.net]
> Sent: Friday, 16 January 2004 10:04 a.m.
> To: Tapestry users
> Subject: Re: Component name changing between rewind/render cycles?
> 
> 
> Are you calling Form.getElementId() multiple times in the 
> renderComponent method? That will cause this to happen.
> 
> -Harish
> 
> Peter Butler wrote:
> 
>>Hi All
>>
>>Ok, I'm stumped.  I have a subclass of TextArea called ValidTextArea.
>>It's similar to ValidField in that it has properties for validator and
> 
> 
>>displayName, and it uses the validator to record errors like this:
>>
>>ValidTextArea.java:
>>	protected void renderComponent(IMarkupWriter writer,
> 
> IRequestCycle
> 
>>cycle) {
>>		....
>>		if (!rendering && !isDisabled()) {
>>			String value =
> 
> cycle.getRequestContext().getParameter(name);
> 
>>			updateValue(value);
>>		}
>>		....
>>	}
>>
>>	protected void updateValue(String value) {
>>		Object objectValue = null;
>>		IValidationDelegate delegate = getForm().getDelegate();
>>
>>		delegate.recordFieldInputValue(value);
>>
>>		try {
>>			objectValue = getValidator().toObject(this,
>>value);
>>		} catch (ValidatorException ex) {
>>			delegate.record(ex);
>>			return;
>>		}
>>
>>		setValue((String)objectValue);
>>	}	
>>
>>I have an instance of this component on a form like this:
>>
>><input jwcid="address@ValidTextArea" value="ognl:address"
>>validator="ognl:beans.basicValidator" displayName="Address"/>
>>
>>So in the rewind cycle, the component name is "address", and the error
> 
> 
>>is recorded in the delegate under this name.  But in the subsequent
>>render cycle, the component name is "address$0".  This means that the
>>ValidationDelegate.isInError() returns false (because there is no 
>>FieldTracking stored under the name "address$0").  So the error is 
>>recorded but my SimpleValidationDelegate.writeAttributes does not 
>>generate the correct error attribute.
>>
>>I can't figure out why the component name is changing on the rewind
>>and render cycles.  Has anyone come across this before?
>>
>>Cheers
>>
>>Peter
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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



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


Re: Component name changing between rewind/render cycles?

Posted by Harish Krishnaswamy <hk...@comcast.net>.
If you were using getElementId before you might probably want to use getName() instead of getId(). 
The id will be the same for multiple occurrences of the component.

-Harish

Peter Butler wrote:

> Yes, I am - once in TextArea.renderComponent() and once in
> ValidTextArea.renderComponent().  I've replaced the call in
> ValidTextArea with this.getId() and it seems to be working fine.  Thanks
> very much for your help, I've been debugging this for hours!
> 
> Cheers
> 
> Peter
> 
> -----Original Message-----
> From: Harish Krishnaswamy [mailto:hkrishnaswamy@comcast.net] 
> Sent: Friday, 16 January 2004 10:04 a.m.
> To: Tapestry users
> Subject: Re: Component name changing between rewind/render cycles?
> 
> 
> Are you calling Form.getElementId() multiple times in the
> renderComponent method? That will cause 
> this to happen.
> 
> -Harish
> 
> Peter Butler wrote:
> 
>>Hi All
>>
>>Ok, I'm stumped.  I have a subclass of TextArea called ValidTextArea. 
>>It's similar to ValidField in that it has properties for validator and
> 
> 
>>displayName, and it uses the validator to record errors like this:
>>
>>ValidTextArea.java:
>>	protected void renderComponent(IMarkupWriter writer,
> 
> IRequestCycle 
> 
>>cycle) {
>>		....
>>		if (!rendering && !isDisabled()) {
>>			String value =
> 
> cycle.getRequestContext().getParameter(name);
> 
>>			updateValue(value);
>>		}
>>		....
>>	}
>>
>>	protected void updateValue(String value) {
>>		Object objectValue = null;
>>		IValidationDelegate delegate = getForm().getDelegate();
>>
>>		delegate.recordFieldInputValue(value);
>>
>>		try {
>>			objectValue = getValidator().toObject(this,
>>value);
>>		} catch (ValidatorException ex) {
>>			delegate.record(ex);
>>			return;
>>		}
>>
>>		setValue((String)objectValue);
>>	}	
>>
>>I have an instance of this component on a form like this:
>>
>><input jwcid="address@ValidTextArea" value="ognl:address" 
>>validator="ognl:beans.basicValidator" displayName="Address"/>
>>
>>So in the rewind cycle, the component name is "address", and the error
> 
> 
>>is recorded in the delegate under this name.  But in the subsequent 
>>render cycle, the component name is "address$0".  This means that the
>>ValidationDelegate.isInError() returns false (because there is no 
>>FieldTracking stored under the name "address$0").  So the error is 
>>recorded but my SimpleValidationDelegate.writeAttributes does not 
>>generate the correct error attribute.
>>
>>I can't figure out why the component name is changing on the rewind 
>>and render cycles.  Has anyone come across this before?
>>
>>Cheers
>>
>>Peter
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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


RE: Component name changing between rewind/render cycles?

Posted by Peter Butler <pe...@141.com>.
Yes, I am - once in TextArea.renderComponent() and once in
ValidTextArea.renderComponent().  I've replaced the call in
ValidTextArea with this.getId() and it seems to be working fine.  Thanks
very much for your help, I've been debugging this for hours!

Cheers

Peter

-----Original Message-----
From: Harish Krishnaswamy [mailto:hkrishnaswamy@comcast.net] 
Sent: Friday, 16 January 2004 10:04 a.m.
To: Tapestry users
Subject: Re: Component name changing between rewind/render cycles?


Are you calling Form.getElementId() multiple times in the
renderComponent method? That will cause 
this to happen.

-Harish

Peter Butler wrote:
> Hi All
> 
> Ok, I'm stumped.  I have a subclass of TextArea called ValidTextArea. 
> It's similar to ValidField in that it has properties for validator and

> displayName, and it uses the validator to record errors like this:
> 
> ValidTextArea.java:
> 	protected void renderComponent(IMarkupWriter writer,
IRequestCycle 
> cycle) {
> 		....
> 		if (!rendering && !isDisabled()) {
> 			String value =
cycle.getRequestContext().getParameter(name);
> 			updateValue(value);
> 		}
> 		....
> 	}
> 
> 	protected void updateValue(String value) {
> 		Object objectValue = null;
> 		IValidationDelegate delegate = getForm().getDelegate();
> 
> 		delegate.recordFieldInputValue(value);
> 
> 		try {
> 			objectValue = getValidator().toObject(this,
> value);
> 		} catch (ValidatorException ex) {
> 			delegate.record(ex);
> 			return;
> 		}
> 
> 		setValue((String)objectValue);
> 	}	
> 
> I have an instance of this component on a form like this:
> 
> <input jwcid="address@ValidTextArea" value="ognl:address" 
> validator="ognl:beans.basicValidator" displayName="Address"/>
> 
> So in the rewind cycle, the component name is "address", and the error

> is recorded in the delegate under this name.  But in the subsequent 
> render cycle, the component name is "address$0".  This means that the
> ValidationDelegate.isInError() returns false (because there is no 
> FieldTracking stored under the name "address$0").  So the error is 
> recorded but my SimpleValidationDelegate.writeAttributes does not 
> generate the correct error attribute.
> 
> I can't figure out why the component name is changing on the rewind 
> and render cycles.  Has anyone come across this before?
> 
> Cheers
> 
> Peter
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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



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


Re: Component name changing between rewind/render cycles?

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Are you calling Form.getElementId() multiple times in the renderComponent method? That will cause 
this to happen.

-Harish

Peter Butler wrote:
> Hi All
> 
> Ok, I'm stumped.  I have a subclass of TextArea called ValidTextArea.
> It's similar to ValidField in that it has properties for validator and
> displayName, and it uses the validator to record errors like this:
> 
> ValidTextArea.java:
> 	protected void renderComponent(IMarkupWriter writer,
> IRequestCycle cycle) {
> 		....
> 		if (!rendering && !isDisabled()) {
> 			String value =
> cycle.getRequestContext().getParameter(name);
> 			updateValue(value);
> 		}
> 		....
> 	}
> 
> 	protected void updateValue(String value) {
> 		Object objectValue = null;
> 		IValidationDelegate delegate = getForm().getDelegate();
> 
> 		delegate.recordFieldInputValue(value);
> 
> 		try {
> 			objectValue = getValidator().toObject(this,
> value);
> 		} catch (ValidatorException ex) {
> 			delegate.record(ex);
> 			return;
> 		}
> 
> 		setValue((String)objectValue);
> 	}	
> 
> I have an instance of this component on a form like this:
> 
> <input jwcid="address@ValidTextArea" value="ognl:address"
> validator="ognl:beans.basicValidator" displayName="Address"/>
> 
> So in the rewind cycle, the component name is "address", and the error
> is recorded in the delegate under this name.  But in the subsequent
> render cycle, the component name is "address$0".  This means that the
> ValidationDelegate.isInError() returns false (because there is no
> FieldTracking stored under the name "address$0").  So the error is
> recorded but my SimpleValidationDelegate.writeAttributes does not
> generate the correct error attribute.
> 
> I can't figure out why the component name is changing on the rewind and
> render cycles.  Has anyone come across this before?
> 
> Cheers
> 
> Peter
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


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