Standard BeanModel for my own classes

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Standard BeanModel for my own classes

Poggenpohl, Daniel
Hi,

I've created some classes that are used rather prominently in my Tapestry 5.3.8 application.

The classes have some attributes that are themselves simple string wrappers.

So, for example, I have:

SomeClass.java
------------------
UidString someUid;
[...]

And UidString is basically a String wrapper with some additional validation:

UidString.java
----------------
String uidString;
public String toString() {return uidString;}
public String get() {return uidString;}
[...]

Anyway, when I use the SomeClass in a grid, the UidString isnt' recognized, so that I either have to add the column by myself every time or create a custom bean model for the class.
I chose the latter. Now I have a method creating the bean model for me and use it every time with t:model="mySomeClassBeanModel" every time I have a grid containing SomeClass.

Can I register the bean model in Tapestry so I don't have to set the model myself?

Are there other ways to recognize/configure the String wrappers?

Regards,
Daniel P.
Reply | Threaded
Open this post in threaded view
|

Re: Standard BeanModel for my own classes

Chris Poulsen
Take a look at data type analyzers and their corresponding property
display/edit blocks to get this working.

Jumpstart has an example:
http://jumpstart.doublenegative.com.au/jumpstart/examples/lang/propertyeditors

--
Chris

On Mon, Oct 12, 2015 at 11:32 AM, Poggenpohl, Daniel <
[hidden email]> wrote:

> Hi,
>
> I've created some classes that are used rather prominently in my Tapestry
> 5.3.8 application.
>
> The classes have some attributes that are themselves simple string
> wrappers.
>
> So, for example, I have:
>
> SomeClass.java
> ------------------
> UidString someUid;
> [...]
>
> And UidString is basically a String wrapper with some additional
> validation:
>
> UidString.java
> ----------------
> String uidString;
> public String toString() {return uidString;}
> public String get() {return uidString;}
> [...]
>
> Anyway, when I use the SomeClass in a grid, the UidString isnt'
> recognized, so that I either have to add the column by myself every time or
> create a custom bean model for the class.
> I chose the latter. Now I have a method creating the bean model for me and
> use it every time with t:model="mySomeClassBeanModel" every time I have a
> grid containing SomeClass.
>
> Can I register the bean model in Tapestry so I don't have to set the model
> myself?
>
> Are there other ways to recognize/configure the String wrappers?
>
> Regards,
> Daniel P.
>
Reply | Threaded
Open this post in threaded view
|

Re: Standard BeanModel for my own classes

Thiago H de Paula Figueiredo
In reply to this post by Poggenpohl, Daniel
On Mon, 12 Oct 2015 06:32:01 -0300, Poggenpohl, Daniel  
<[hidden email]> wrote:

> Hi,

Hi!

> Can I register the bean model in Tapestry so I don't have to set the  
> model myself?

Short answer: no. Long answer: no, but Chris' suggestions of contributing  
your own edition blocks will help you apply the same components and their  
parameters for similar scenarios, which will have the same end results of  
what you wanted, even if not doing what you want. You'll probably want to  
contribute viewing blocks too.

> Are there other ways to recognize/configure the String wrappers?

Same solution described above and suggested by Chris: create your own  
edition and viewing blocks. That's exactly what Tapestry itself does.

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]