You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Campbell <cc...@quaris.com> on 2007/12/09 21:57:40 UTC
T5 - BeanEditForm server side validation question
Simple question from a noob: Following form example, mostly works
well. Now I want to do some cross validation server side, and can do
that, however I cannot figure out how to set the error message on
the form.
My class has:
@Inject
private BeanModelSource _beanModelSource;
@Inject
private ComponentResources _resources;
@Retain
private BeanModel _model;
etc..
but no form object.
The template has
<t:beaneditform object="bean" model="model">
It seems to me that I need to get the form object and use
recordError(String err), is that right? How do I access the form if
it is not in my class?
Thanks in advance, really impressed with T5 so far.
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5 - BeanEditForm server side validation question
Posted by Chris Campbell <cc...@quaris.com>.
Very good. For completeness for anyone else reading this, I did the
following:
Added to the java class
@Component
private BeanEditForm _form;
public BeanEditForm getForm()
{
return _form;
}
and changed template to ( notice the <t:beaneditform to <:form )
<t:form id="form" object="bean" model="model"/>
Thanks!
Filip S. Adamsen wrote:
> Hi Chris,
>
> Simply inject the BeanEditForm into your page class and use that to
> record the errors. You'll need to give the BeanEditForm an id in your
> template and then use the @Component annotation to inject it.
>
> Details are here:
> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/annotations/Component.html
>
>
> -Filip
>
> Chris Campbell skrev:
>> Simple question from a noob: Following form example, mostly works
>> well. Now I want to do some cross validation server side, and can do
>> that, however I cannot figure out how to set the error message on
>> the form.
>>
>> My class has:
>>
>> @Inject
>> private BeanModelSource _beanModelSource;
>>
>> @Inject
>> private ComponentResources _resources;
>>
>> @Retain
>> private BeanModel _model;
>>
>> etc..
>>
>> but no form object.
>>
>> The template has
>>
>> <t:beaneditform object="bean" model="model">
>>
>> It seems to me that I need to get the form object and use
>> recordError(String err), is that right? How do I access the form if
>> it is not in my class?
>>
>> Thanks in advance, really impressed with T5 so far.
>>
>> Chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5 - BeanEditForm server side validation question
Posted by "Filip S. Adamsen" <fs...@fsadev.com>.
Hi Chris,
Simply inject the BeanEditForm into your page class and use that to
record the errors. You'll need to give the BeanEditForm an id in your
template and then use the @Component annotation to inject it.
Details are here:
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/annotations/Component.html
-Filip
Chris Campbell skrev:
> Simple question from a noob: Following form example, mostly works
> well. Now I want to do some cross validation server side, and can do
> that, however I cannot figure out how to set the error message on
> the form.
>
> My class has:
>
> @Inject
> private BeanModelSource _beanModelSource;
>
> @Inject
> private ComponentResources _resources;
>
> @Retain
> private BeanModel _model;
>
> etc..
>
> but no form object.
>
> The template has
>
> <t:beaneditform object="bean" model="model">
>
> It seems to me that I need to get the form object and use
> recordError(String err), is that right? How do I access the form if
> it is not in my class?
>
> Thanks in advance, really impressed with T5 so far.
>
> Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org