You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jim O'Callaghan <jc...@yahoo.co.uk> on 2009/12/10 12:01:05 UTC

Validators / Translators question

Hi,

I'm trying to simplify some pages using the Grid display for search results
and the BEF for input and want to find out if Validators / Translators are
intended to only operate on individual fields, or if the approach can be
used as a pattern to validate and display multiple fields within a single
translator - an example would be a Client entity that contains an Address
entity - I want to be able to throw the Client at a Grid or BEF and have
something render a multi-line address along with the other fields from the
Client - is it an incorrect approach to used Validators / Translators in
this scenario and if so can anyone advise on how to abstract and reuse an
embedded Address rendering approach?

Many thanks,
Jim.


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


Re: Validators / Translators question

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 10 Dec 2009 11:50:31 -0200, Jim O'Callaghan  
<jc...@yahoo.co.uk> escreveu:

> Thanks Thiago.  I'm using the example at the link you specified, but  
> found I needed to provide validators and translators to complete the  
> approach, esp. the translator being missing / not bound was causing a  
> NPE somewhere along the line.

The viewing block is just for viewing (Grid and BeanDisplay, no affecting  
how you edit the values.

If your address field is only used in one Grid, you could just override  
the viewing block for it using <p:addressCell> inside the Grid.

> I can update the block to display the fields (sub fields in ex. Address)  
> but was wondering more about how the value is translated from what is  
> posted back into an Address object - is that not what the Translator
> would do?  I'm probably missing something obvious here ...

I can see two approaches:

1) Create an edition block for Address that has one TextField for each of  
its parts.
2) Create an edition block for Address that isn't really used. It would be  
there just to make Tapestry not complain about the lack of an edition  
block.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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


RE: Validators / Translators question

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Thanks Thiago.  I'm using the example at the link you specified, but found I
needed to provide validators and translators to complete the approach, esp.
the translator being missing / not bound was causing a NPE somewhere along
the line.  I can update the block to display the fields (sub fields in ex.
Address) but was wondering more about how the value is translated from what
is posted back into an Address object - is that not what the Translator
would do?  I'm probably missing something obvious here ...

Regards,
Jim.

-----Original Message-----
From: Thiago H. de Paula Figueiredo [mailto:thiagohp@gmail.com]
Sent: 10 December 2009 11:31
To: Tapestry users
Subject: Re: Validators / Translators question


Em Thu, 10 Dec 2009 09:01:05 -0200, Jim O'Callaghan
<jc...@yahoo.co.uk> escreveu:

> Hi,

Hi!

> Client - is it an incorrect approach to used Validators / Translators in
> this scenario and if so can anyone advise on how to abstract and reuse an
> embedded Address rendering approach?

Validators and translators are meant to be used with form fields, not
rendering. They're not used by Grid nor BeanDisplay.
To do what you want, you need to provide a viewing block to your Address
class. The corresponding documentation is
http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html, section
"Adding New Property Editors".

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da
Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
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: Validators / Translators question

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 10 Dec 2009 09:01:05 -0200, Jim O'Callaghan  
<jc...@yahoo.co.uk> escreveu:

> Hi,

Hi!

> Client - is it an incorrect approach to used Validators / Translators in
> this scenario and if so can anyone advise on how to abstract and reuse an
> embedded Address rendering approach?

Validators and translators are meant to be used with form fields, not  
rendering. They're not used by Grid nor BeanDisplay.
To do what you want, you need to provide a viewing block to your Address  
class. The corresponding documentation is  
http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html, section  
"Adding New Property Editors".

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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