You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Engelhart <mo...@gmail.com> on 2005/04/13 19:22:33 UTC
accessing a record()'d error from ValidationDelegate
Hi -
How does one access an error set on a component like this:
protected void recordError(IValidationDelegate delegate, String
componentId, String message, ValidationConstraint constraint) {
IFormComponent component = (IFormComponent) getComponent(componentId);
delegate.setFormComponent(component);
delegate.record(message, constraint);
}
When i call this method from a page like this:
recordError(delegate, "ExpirationDateField", "You must set a valid
expiration date", null);
i can't seem to find anywhere in the validation framework where I can
access a component's error message in the writeSuffix() method of my
class that extends ValidationDelegate.
Thanks
Mike
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: accessing a record()'d error from ValidationDelegate
Posted by Kent Tong <ke...@cpttm.org.mo>.
Michael Engelhart <moosebrookfarm <at> gmail.com> writes:
> So in my writeSuffix() I simply do this:
> if (isInError()) {
> RenderString errorString = (RenderString)
> findCurrentTracking().getErrorRenderer();
> writer.print(errorString.getString());
> }
Any reason why the following wouldn't work for you:
if (isInError()) {
findCurrentTracking().getErrorRenderer().render(writer, cycle);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: accessing a record()'d error from ValidationDelegate
Posted by Michael Engelhart <mo...@gmail.com>.
Hi -
not sure why I wasn't able to find any of this by googling but the
fact that the Tapestry javadoc shows that the getErrorRenderer()
returns an IRender interface led me astray. After some logging I
noticed it was returning a RenderString which has a getString()
method. So in my writeSuffix() I simply do this:
if (isInError()) {
RenderString errorString = (RenderString)
findCurrentTracking().getErrorRenderer();
writer.print(errorString.getString());
}
works perfectly.
On 4/13/05, Michael Engelhart <mo...@gmail.com> wrote:
> Hi -
>
> How does one access an error set on a component like this:
> protected void recordError(IValidationDelegate delegate, String
> componentId, String message, ValidationConstraint constraint) {
> IFormComponent component = (IFormComponent) getComponent(componentId);
> delegate.setFormComponent(component);
> delegate.record(message, constraint);
> }
>
> When i call this method from a page like this:
> recordError(delegate, "ExpirationDateField", "You must set a valid
> expiration date", null);
>
> i can't seem to find anywhere in the validation framework where I can
> access a component's error message in the writeSuffix() method of my
> class that extends ValidationDelegate.
>
> Thanks
> Mike
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org