You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Davide Vecchi <dv...@amc.dk> on 2015/04/27 17:04:48 UTC

Customized display/edit blocks for components other than the grid

Hi everybody,

I would like to define a custom numeric datatype, f.ex. "monetary", for the purpose of annotating fields and accessor methods with something like
@DataType("monetary")
so that such fields would be rendered and edited according to a custom format.

I actually tried that by contributing customized blocks to the BeanBlockSource service, and it worked right away: my grid columns that I annotated with @DataType("monetary") did reflect my custom format as expected.

Now I'm wondering if there is some similar mechanism in Tapestry that can be used not only for grids but also for other components, f.ex. a normal TextField not inside a grid.
In other words I would like that f.ex. text fields outside any grid could display and edit like the grid cells of the columns that I have annotated with @DataType .

This doesn't necessarily need to be through the BeanBlockSource service; I mentioned it just to give an example of what I'm trying to achieve.

So I'm interested in any comment or suggestion on how to go about this.

Thanks :)

Re: Customized display/edit blocks for components other than the grid

Posted by Lance Java <la...@googlemail.com>.
Are you aware that BeanEditor, BeanEditForm and BeanDisplay all obey the
BeanBlockSource?

RE: Customized display/edit blocks for components other than the grid

Posted by Davide Vecchi <dv...@amc.dk>.
Very interesting, I will definitely explore this possibility.


-----Original Message-----
From: Thiago H de Paula Figueiredo [mailto:thiagohp@gmail.com] 
Sent: Thursday, April 30, 2015 15:23
To: Tapestry users
Subject: Re: Customized display/edit blocks for components other than the grid

On Thu, 30 Apr 2015 08:35:05 -0300, Davide Vecchi <dv...@amc.dk> wrote:

> Ok, thanks for the explanation. Right now we can't update to 5.4 but 
> when we do we will explore the possibility you mentioned. For now we 
> have just slightly changed our requirements and we can use the 
> Tapestry Translator to achieve what we need.

After I posted the answer, I remembered that you can use the PropertyEditor component, which is exactly the one used by BeanEditor to generate the appropriate form fields. You pass the object and the property name and that's it.  
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/PropertyEditor.html.  
BeanEditor's template is just a Loop with PropertyEditor inside.

> Thanks for the quick assistance as usual.

:)


-----Original Message-----
From: Lance Java [mailto:lance.java@googlemail.com] 
Sent: Thursday, April 30, 2015 15:20
To: Tapestry users
Subject: Re: Customized display/edit blocks for components other than the grid

Are you aware that BeanEditor, BeanEditForm and BeanDisplay all obey the BeanBlockSource?

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

Re: Customized display/edit blocks for components other than the grid

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 30 Apr 2015 08:35:05 -0300, Davide Vecchi <dv...@amc.dk> wrote:

> Ok, thanks for the explanation. Right now we can't update to 5.4 but  
> when we do we will explore the possibility you mentioned. For now we  
> have just slightly changed our requirements and we can use the Tapestry  
> Translator to achieve what we need.

After I posted the answer, I remembered that you can use the  
PropertyEditor component, which is exactly the one used by BeanEditor to  
generate the appropriate form fields. You pass the object and the property  
name and that's it.  
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/PropertyEditor.html.  
BeanEditor's template is just a Loop with PropertyEditor inside.

> Thanks for the quick assistance as usual.

:)

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


RE: Customized display/edit blocks for components other than the grid

Posted by Davide Vecchi <dv...@amc.dk>.
Ok, thanks for the explanation. Right now we can't update to 5.4 but when we do we will explore the possibility you mentioned. For now we have just slightly changed our requirements and we can use the Tapestry Translator to achieve what we need.

Thanks for the quick assistance as usual.

-----Original Message-----
From: Thiago H de Paula Figueiredo [mailto:thiagohp@gmail.com] 
Sent: Monday, April 27, 2015 21:30
To: Tapestry users
Subject: Re: Customized display/edit blocks for components other than the grid

On Mon, 27 Apr 2015 12:04:48 -0300, Davide Vecchi <dv...@amc.dk> wrote:

> Hi everybody,

Hi!

> Now I'm wondering if there is some similar mechanism in Tapestry that 
> can be used not only for grids but also for other components, f.ex. a 
> normal TextField not inside a grid.

Not out-of-the-box.

> In other words I would like that f.ex. text fields outside any grid 
> could display and edit like the grid cells of the columns that I have 
> annotated with @DataType .

You can try doing something with ComponentOverride, a service introduced in 5.4, which will replace every usage of a component with another one.  
It's not documented yet, but you contribute overrides to it:

public static void
contributeComponentOverride(MappedConfiguration<Class,Class> config) {
         config.add(TextField.class, YourTextField.class); }


If you want to see the history of it plus learn a bit more about Java (seriously, the Tapestry team actually did learn while implementing and discussing this feature), you can read this ticket:  
https://issues.apache.org/jira/browse/TAP5-1611.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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


Re: Customized display/edit blocks for components other than the grid

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 27 Apr 2015 12:04:48 -0300, Davide Vecchi <dv...@amc.dk> wrote:

> Hi everybody,

Hi!

> Now I'm wondering if there is some similar mechanism in Tapestry that  
> can be used not only for grids but also for other components, f.ex. a  
> normal TextField not inside a grid.

Not out-of-the-box.

> In other words I would like that f.ex. text fields outside any grid  
> could display and edit like the grid cells of the columns that I have  
> annotated with @DataType .

You can try doing something with ComponentOverride, a service introduced  
in 5.4, which will replace every usage of a component with another one.  
It's not documented yet, but you contribute overrides to it:

public static void  
contributeComponentOverride(MappedConfiguration<Class,Class> config) {
         config.add(TextField.class, YourTextField.class);
}


If you want to see the history of it plus learn a bit more about Java  
(seriously, the Tapestry team actually did learn while implementing and  
discussing this feature), you can read this ticket:  
https://issues.apache.org/jira/browse/TAP5-1611.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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