Re: Standard BeanModel for my own classes
On Mon, 12 Oct 2015 06:32:01 -0300, Poggenpohl, Daniel 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: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Standard BeanModel for my own classes
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 < daniel.poggenp...@isst.fraunhofer.de> 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. >
Standard BeanModel for my own classes
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.
Re: Grid data source, BeanModel and nested properties
Actually the solution was @Formula Hibernate fields. For example: @XmlTransient @Formula("(select sum(invoices.amountdue) from invoices where invoices.event_id = event_id and invoices.participant_id = participant_id)") private Double amountInvoiced; PostgreSQL is able to optimize it pretty well, when you have necessary indexes (the whole query with sub-selects takes about 10-14 ms). When I'm saying about the solution that is 'far from elegant', I mean the size of Criteria creation code (about 30 lines) and its lack of reusability (because every component have slightly different conditions of using it). But overall performance is very, very fast as soon as you eliminate "N+1" Hibernate problem. On Tue, Jan 6, 2015 at 5:30 PM, Jonathan Barker wrote: > Ilya, > > I haven't faced that situation… yet. I guess the complication is in > specifying the grouping conditions. > > My stats listings are restricted in size, so I don't worry about a > paged grid source for those, and I get the results from stored > procedures. Some of the *counts* in that list are large. I need > someone to be able to click on 86000 and go to a listing that doesn't > bring down the application. > > Let me know if you find an adequate solution. I see your other post > about code that looks far from elegant - if that is it, I would be > curious to know how you handled the projections. > > Regards, > Jonathan > > > > On Sat, Jan 3, 2015 at 3:21 AM, Ilya Obshadko > wrote: > > Johnathan, > > > > How do you handle situations when several of the properties you need to > > display are aggregates? > > For example: select ..., sum(amount_invoiced), sum(amount_paid) from > orders > > group by order_id. > > > > This won't work nice with Projections.rowCount() (unless you use > > sub-select, which might be sub-optimal, and I'm not sure if even possible > > using Criteria API). > > > > > > On Sat, Jan 3, 2015 at 5:57 AM, Jonathan Barker < > jonathan.theit...@gmail.com > >> wrote: > > > >> Ilya, > >> > >> Our strategy is to use a class specifically to hold the query results, > >> so the sort criteria are simple properties. The Criteria query and > >> Projection are supplied separately to our GridDataSource. The > >> Projection maps any child properties onto aliases (useful for the > >> sorting), and an optional ResultTransformer as well. If none is > >> provided, the Transformers.aliasToBean is used. The count is achieved > >> by using the Projections.rowCount(). > >> > >> On Fri, Jan 2, 2015 at 3:45 AM, Ilya Obshadko > >> wrote: > >> > I'm trying to implement a Grid data source optimized for database > >> > retrievals (with paging support). Basically it's derived from > >> > HibernateGridDataSource from Tapestry distribution, and provides > support > >> > for complex Criteria queries: > >> > https://gist.github.com/xfyre/ecb36a9173aed6a37f14 > >> > > >> > However, there is a problem with sorting. > >> > > >> > Provided BeanModel implementation doesn't support nested properties; > that > >> > is, I cannot use properties of child Hibernate entities: >> > include="property1, child1.property1, child2.property2" .../> results > in > >> > error. Initially I had a workaround of having helper getter methods in > >> > parent entity class, so it looked like . It worked, but when I'm > trying > >> to > >> > use database-backed Grid data source, there's an error with sorting > >> > (because sorting is performed on database level and obviously root > entity > >> > of the query doesn't contain database properties specified in Grid. > >> > > >> > Is there any reasonable solution for that, besides manually providing > all > >> > required mappings between Grid property names and database property > >> names? > >> > > >> > -- > >> > Ilya Obshadko > >> > >> > >> > >> -- > >> Jonathan Barker > >> ITStrategic > >> > >> - > >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > >> For additional commands, e-mail: users-h...@tapestry.apache.org > >> > >> > > > > > > -- > > Ilya Obshadko > > > > -- > Jonathan Barker > ITStrategic > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- Ilya Obshadko
Re: Grid data source, BeanModel and nested properties
Ilya, I haven't faced that situation… yet. I guess the complication is in specifying the grouping conditions. My stats listings are restricted in size, so I don't worry about a paged grid source for those, and I get the results from stored procedures. Some of the *counts* in that list are large. I need someone to be able to click on 86000 and go to a listing that doesn't bring down the application. Let me know if you find an adequate solution. I see your other post about code that looks far from elegant - if that is it, I would be curious to know how you handled the projections. Regards, Jonathan On Sat, Jan 3, 2015 at 3:21 AM, Ilya Obshadko wrote: > Johnathan, > > How do you handle situations when several of the properties you need to > display are aggregates? > For example: select ..., sum(amount_invoiced), sum(amount_paid) from orders > group by order_id. > > This won't work nice with Projections.rowCount() (unless you use > sub-select, which might be sub-optimal, and I'm not sure if even possible > using Criteria API). > > > On Sat, Jan 3, 2015 at 5:57 AM, Jonathan Barker > wrote: > >> Ilya, >> >> Our strategy is to use a class specifically to hold the query results, >> so the sort criteria are simple properties. The Criteria query and >> Projection are supplied separately to our GridDataSource. The >> Projection maps any child properties onto aliases (useful for the >> sorting), and an optional ResultTransformer as well. If none is >> provided, the Transformers.aliasToBean is used. The count is achieved >> by using the Projections.rowCount(). >> >> On Fri, Jan 2, 2015 at 3:45 AM, Ilya Obshadko >> wrote: >> > I'm trying to implement a Grid data source optimized for database >> > retrievals (with paging support). Basically it's derived from >> > HibernateGridDataSource from Tapestry distribution, and provides support >> > for complex Criteria queries: >> > https://gist.github.com/xfyre/ecb36a9173aed6a37f14 >> > >> > However, there is a problem with sorting. >> > >> > Provided BeanModel implementation doesn't support nested properties; that >> > is, I cannot use properties of child Hibernate entities: > > include="property1, child1.property1, child2.property2" .../> results in >> > error. Initially I had a workaround of having helper getter methods in >> > parent entity class, so it looked like . It worked, but when I'm trying >> to >> > use database-backed Grid data source, there's an error with sorting >> > (because sorting is performed on database level and obviously root entity >> > of the query doesn't contain database properties specified in Grid. >> > >> > Is there any reasonable solution for that, besides manually providing all >> > required mappings between Grid property names and database property >> names? >> > >> > -- >> > Ilya Obshadko >> >> >> >> -- >> Jonathan Barker >> ITStrategic >> >> - >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > > > -- > Ilya Obshadko -- Jonathan Barker ITStrategic - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Grid data source, BeanModel and nested properties
I have ended up with custom DTO classes and Hibernate projections. Although the resulting code looks far from elegant, it's extremely fast, compared to 'normal' retrieval using lists, without paging (especially for lists with hundreds of records of course). On Mon, Jan 5, 2015 at 1:39 PM, Thiago H de Paula Figueiredo < thiag...@gmail.com> wrote: > On Fri, 02 Jan 2015 06:45:30 -0200, Ilya Obshadko > wrote: > > I'm trying to implement a Grid data source optimized for database >> retrievals (with paging support). Basically it's derived from >> HibernateGridDataSource from Tapestry distribution, and provides support >> for complex Criteria queries: >> https://gist.github.com/xfyre/ecb36a9173aed6a37f14 >> >> However, there is a problem with sorting. >> >> Provided BeanModel implementation doesn't support nested properties; that >> is, I cannot use properties of child Hibernate entities: > include="property1, child1.property1, child2.property2" .../>results in >> error. >> > > Remember you're passing a Class instance for BeanModelSource, so the > properties which are actually recognized as the ones provided by the class > you passed, not subclass ones. That's how Java and strongly-typed languages > work: if you have a class C and a subclass S, if you ask Java reflection > classes or BeanModelSource to provide a list of properties of C, only > properties from C will appear. > > Initially I had a workaround of having helper getter methods in >> parent entity class, so it looked like . It worked, but when I'm trying >> to use database-backed Grid data source, there's an error with sorting >> (because sorting is performed on database level and obviously root entity >> of the query doesn't contain database properties specified in Grid. >> > > You receive the name of these properties, so it's up to your code to > handle this kind of situation (synthetic BeanModel properties). > > I agree with Chris, whose opinion matches what Howard has been saying for > a long time in the Tapestry mailing list: the BeanModel classes and > components are meant to be used as a starting point, as scaffolding, as > tools to have something working quickly, but they're not supposed to handle > all scenarios by themselves. > > -- > Thiago H. de Paula Figueiredo > Tapestry, Java and Hibernate consultant and developer > http://machina.com.br > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- Ilya Obshadko
Re: Grid data source, BeanModel and nested properties
On Fri, 02 Jan 2015 06:45:30 -0200, Ilya Obshadko wrote: I'm trying to implement a Grid data source optimized for database retrievals (with paging support). Basically it's derived from HibernateGridDataSource from Tapestry distribution, and provides support for complex Criteria queries: https://gist.github.com/xfyre/ecb36a9173aed6a37f14 However, there is a problem with sorting. Provided BeanModel implementation doesn't support nested properties; that is, I cannot use properties of child Hibernate entities: include="property1, child1.property1, child2.property2" .../>results in error. Remember you're passing a Class instance for BeanModelSource, so the properties which are actually recognized as the ones provided by the class you passed, not subclass ones. That's how Java and strongly-typed languages work: if you have a class C and a subclass S, if you ask Java reflection classes or BeanModelSource to provide a list of properties of C, only properties from C will appear. Initially I had a workaround of having helper getter methods in parent entity class, so it looked like . It worked, but when I'm trying to use database-backed Grid data source, there's an error with sorting (because sorting is performed on database level and obviously root entity of the query doesn't contain database properties specified in Grid. You receive the name of these properties, so it's up to your code to handle this kind of situation (synthetic BeanModel properties). I agree with Chris, whose opinion matches what Howard has been saying for a long time in the Tapestry mailing list: the BeanModel classes and components are meant to be used as a starting point, as scaffolding, as tools to have something working quickly, but they're not supposed to handle all scenarios by themselves. -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Grid data source, BeanModel and nested properties
Johnathan, How do you handle situations when several of the properties you need to display are aggregates? For example: select ..., sum(amount_invoiced), sum(amount_paid) from orders group by order_id. This won't work nice with Projections.rowCount() (unless you use sub-select, which might be sub-optimal, and I'm not sure if even possible using Criteria API). On Sat, Jan 3, 2015 at 5:57 AM, Jonathan Barker wrote: > Ilya, > > Our strategy is to use a class specifically to hold the query results, > so the sort criteria are simple properties. The Criteria query and > Projection are supplied separately to our GridDataSource. The > Projection maps any child properties onto aliases (useful for the > sorting), and an optional ResultTransformer as well. If none is > provided, the Transformers.aliasToBean is used. The count is achieved > by using the Projections.rowCount(). > > On Fri, Jan 2, 2015 at 3:45 AM, Ilya Obshadko > wrote: > > I'm trying to implement a Grid data source optimized for database > > retrievals (with paging support). Basically it's derived from > > HibernateGridDataSource from Tapestry distribution, and provides support > > for complex Criteria queries: > > https://gist.github.com/xfyre/ecb36a9173aed6a37f14 > > > > However, there is a problem with sorting. > > > > Provided BeanModel implementation doesn't support nested properties; that > > is, I cannot use properties of child Hibernate entities: > include="property1, child1.property1, child2.property2" .../> results in > > error. Initially I had a workaround of having helper getter methods in > > parent entity class, so it looked like . It worked, but when I'm trying > to > > use database-backed Grid data source, there's an error with sorting > > (because sorting is performed on database level and obviously root entity > > of the query doesn't contain database properties specified in Grid. > > > > Is there any reasonable solution for that, besides manually providing all > > required mappings between Grid property names and database property > names? > > > > -- > > Ilya Obshadko > > > > -- > Jonathan Barker > ITStrategic > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- Ilya Obshadko
Re: Grid data source, BeanModel and nested properties
Ilya, Our strategy is to use a class specifically to hold the query results, so the sort criteria are simple properties. The Criteria query and Projection are supplied separately to our GridDataSource. The Projection maps any child properties onto aliases (useful for the sorting), and an optional ResultTransformer as well. If none is provided, the Transformers.aliasToBean is used. The count is achieved by using the Projections.rowCount(). On Fri, Jan 2, 2015 at 3:45 AM, Ilya Obshadko wrote: > I'm trying to implement a Grid data source optimized for database > retrievals (with paging support). Basically it's derived from > HibernateGridDataSource from Tapestry distribution, and provides support > for complex Criteria queries: > https://gist.github.com/xfyre/ecb36a9173aed6a37f14 > > However, there is a problem with sorting. > > Provided BeanModel implementation doesn't support nested properties; that > is, I cannot use properties of child Hibernate entities: include="property1, child1.property1, child2.property2" .../> results in > error. Initially I had a workaround of having helper getter methods in > parent entity class, so it looked like . It worked, but when I'm trying to > use database-backed Grid data source, there's an error with sorting > (because sorting is performed on database level and obviously root entity > of the query doesn't contain database properties specified in Grid. > > Is there any reasonable solution for that, besides manually providing all > required mappings between Grid property names and database property names? > > -- > Ilya Obshadko -- Jonathan Barker ITStrategic - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Grid data source, BeanModel and nested properties
The automatic creation of bean models can only do so much - I always find that the automatic model creation is great for getting started, but at some point it is always necessary to provide explicit bean models. The pattern we end up with is something like this: model = beanModelSource.createDisplayModel model.include( ) model.add* (to get the properties that the introspector cannot find/properties that need extra arguments) ... the "include" part is important to avoid extra columns showing up when the data model is changed. So I guess that you do need to specify most of it manually - alternatively you could probably teach tapestry about the complex property types, but I prefer the manual way. -- Chris On Fri, Jan 2, 2015 at 9:45 AM, Ilya Obshadko wrote: > I'm trying to implement a Grid data source optimized for database > retrievals (with paging support). Basically it's derived from > HibernateGridDataSource from Tapestry distribution, and provides support > for complex Criteria queries: > https://gist.github.com/xfyre/ecb36a9173aed6a37f14 > > However, there is a problem with sorting. > > Provided BeanModel implementation doesn't support nested properties; that > is, I cannot use properties of child Hibernate entities: include="property1, child1.property1, child2.property2" .../> results in > error. Initially I had a workaround of having helper getter methods in > parent entity class, so it looked like . It worked, but when I'm trying to > use database-backed Grid data source, there's an error with sorting > (because sorting is performed on database level and obviously root entity > of the query doesn't contain database properties specified in Grid. > > Is there any reasonable solution for that, besides manually providing all > required mappings between Grid property names and database property names? > > -- > Ilya Obshadko >
Grid data source, BeanModel and nested properties
I'm trying to implement a Grid data source optimized for database retrievals (with paging support). Basically it's derived from HibernateGridDataSource from Tapestry distribution, and provides support for complex Criteria queries: https://gist.github.com/xfyre/ecb36a9173aed6a37f14 However, there is a problem with sorting. Provided BeanModel implementation doesn't support nested properties; that is, I cannot use properties of child Hibernate entities: results in error. Initially I had a workaround of having helper getter methods in parent entity class, so it looked like . It worked, but when I'm trying to use database-backed Grid data source, there's an error with sorting (because sorting is performed on database level and obviously root entity of the query doesn't contain database properties specified in Grid. Is there any reasonable solution for that, besides manually providing all required mappings between Grid property names and database property names? -- Ilya Obshadko
Re: beanmodel ques
On Tue, 28 May 2013 10:45:06 -0300, Ken in Nashua wrote: Hi Folks, Hi! I want to include both player info and player stats in the same bean model. Check the mailing list archives for that. You'll probably need to implement a PropertyConduit and use it in beanModel.add("stats, new YourPlayStatsPropertyConduit()); Or just use beanModel.add("stats", null) and use in the template to define how this will be rendered. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: beanmodel ques
Sorry folks... if I got this @Entity @ClassDescriptor(hasCyclicRelationships = true) @BeanModels( { @BeanModel(pageType = PageType.LIST, include = "player, gp, g, a, pts", exclude="") }) public class PlayerStats implements Cloneable, Serializable { private static final Log log = LogFactory.getLog(PlayerStats.class); private Integer id = null; private Player player = null; private Year year = null; can I do this ? myModel = beanModelSource.createDisplayModel(PlayerStats.class, messages); myModel.add("action", null); myModel.include("player.number", "player.lastName", "player.lastName", "gp", "g", "a", "pts"); myModel.get("player.firstName").sortable(false); myModel.get("player.lastName").label("Surname");
RE: beanmodel ques
Maybe I should be doing the bean model on PlayerStats public class PlayerStats implements Cloneable, Serializable { private static final Log log = LogFactory.getLog(PlayerStats.class); private Integer id = null; private Player player = null; ...can I refer to the player from there ? player.playerNumber ?
RE: beanmodel ques
Players and stats are keyed by Season.class so there could be at any given time one Player instance and one PlayerStats instance to deal with. Its not immediately apparent to me how to combine properties from both classes into the grid bveanmodel
beanmodel ques
Hi Folks, I have a Player.class public class Player extends Person implements Cloneable, Serializable { private Set playerStats = new HashSet(); He has a collection of stats. goals, assists, points etc... I am rendering league leaders... so I have a bean model I am working on myModel = beanModelSource.createDisplayModel(Player.class, messages); myModel.add("action", null); myModel.include("id", "number", "photo", "lastName", "firstName"); myModel.get("firstName").sortable(false); myModel.get("lastName").label("Surname"); How do I get the stats into the bean model? They are of a different class PlayerStat.class I want to include both player info and player stats in the same bean model. Any tips are appreciated. Ken
Re: BeanModel Exception
On Thu, 20 Dec 2012 10:26:14 -0200, mateen wrote: the message object is just an Injected Object. But i get a render queue exception. What am i doing wrong. When an exception occurs and you want help, please post the exception, otherwise we can only guess what's happening. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
BeanModel Exception
I have a Grid that i wish to show and hide some columns. Here is my Grid Process Teller In the onSubmit from button that renders my Grid i include the following source code. quoteViewModel = beanModelSource.createDisplayModel(QuoteView.class, messages); quoteViewModel.exclude( "recipientPhoneNumber,pickupQuoteID,transactionID" ); return request.isXHR( ) ? searchTransactionZone.getBody( ) : null; the message object is just an Injected Object. But i get a render queue exception. What am i doing wrong. -- View this message in context: http://tapestry.1045711.n5.nabble.com/BeanModel-Exception-tp5718873.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: BeanModel - how to add results from a method?
On Thu, 01 Nov 2012 11:13:19 -0200, membersound wrote: Why not? That would be perfectly good, even recommended, object-oriented Because it was just an example here, I want to apply some calculations for some rows, which should not clutter my entities. And of course itself rely again on other entities, so the calculation is more a process for a service than being directly placed in the entity object itself. For me, if some calculation or process can be done just by using the fields of a given entity class, the method that does it should be in the entity class. That's OOP. That's not clutter. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: BeanModel - how to add results from a method?
OK got it, thank you very much! > Why not? That would be perfectly good, even recommended, object-oriented Because it was just an example here, I want to apply some calculations for some rows, which should not clutter my entities. And of course itself rely again on other entities, so the calculation is more a process for a service than being directly placed in the entity object itself. -- View this message in context: http://tapestry.1045711.n5.nabble.com/BeanModel-how-to-add-results-from-a-method-tp5717499p5717520.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: BeanModel - how to add results from a method?
On Thu, 01 Nov 2012 10:06:34 -0200, membersound wrote: Sorry, I think I didn't get it. Nope, you didn't. :P setupRender() { model.add("result", pcSource.create("Product.class", "price")); Does this even compile? I guess it should be model.add("result", pcSource.create(Product.class), "price"));. Anyway, you're not following what I suggested at all. Have you even read it? :P In addition, you can't add more than one property with the same name. You should implement your own PropertyConduit, not using one provided by PropertyConduitSource. Something like this (not tested). class MultiplyPropertyConduit implements PropertyConduit { // that's where the logic goes public Object get(Object instance) { Product product = (Product) instance; return product.getPrice() * product.getQuantity(); } public void set(Object instance, Object value) {} public Class getPropertyType() { return BigDecimal.class; } public T getAnnotation(Class annotationClass) { return null: } } ... beanModel.add("multiply", new MultiplyPropertyConduitSource()); I do NOT want to introduce a getMultiply() method within my product entity (which would solve the problem as I could just add a "multiply" conduit). I want it to be computed either in the productService or directly in the product backing page class. Why not? That would be perfectly good, even recommended, object-oriented modelling and programming. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: BeanModel - how to add results from a method?
Sorry, I think I didn't get it. Lets make an example here: http://tapestry.1045711.n5.nabble.com/BeanModel-how-to-add-results-from-a-method-tp5717499p5717512.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: BeanModel - how to add results from a method?
On Thu, 01 Nov 2012 09:03:06 -0200, membersound wrote: Hi, Hi! When I create a BeanModel, how can I add results eg from a method that is not contained in the Entity-Object with which the BeanModel has been created? You can't pass the result itself, but you can implement a PropertyConduit that receives the object being shown and computes the BeanModel property value for it using any logic you want. The key here is implementing PropertyConduit yourself (it's easy, and if you're just showing the object you can provide an empty implementation to its set() method) and passing it to the BeanModel.add() method. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
BeanModel - how to add results from a method?
Hi, when I create a BeanModel, how can I add results eg from a method that is not contained in the Entity-Object with which the BeanModel has been created? Like: Here I create a beanmodel for the class UserProfile. And I want to add a field that gets its content from a method that is placed NOT in the userProfile, eg in the same page class where the model is created, or in some other service that is been injected. BeanModel.createDisplayModel(UserProfile.class, messages); model.add(...); model.add("customProp", PropertyConduitSource.create(someService.getSomeMethodResult())); @Inject SomeService someService; How can I do this? -- View this message in context: http://tapestry.1045711.n5.nabble.com/BeanModel-how-to-add-results-from-a-method-tp5717499.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Retain BeanModel when sorting columns?
Ok I will stick to this. Anyhow, concerning my latest question: how could I display the size of a list contained in my user object? Because I cannot just add the property to the bean model like "list.size"... -- View this message in context: http://tapestry.1045711.n5.nabble.com/Retain-BeanModel-when-sorting-columns-tp5717374p5717382.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Retain BeanModel when sorting columns?
On 29.10.2012 12:51, membersound wrote: OK I see. I'm doing it with BeanModelSource based on this example: http://jumpstart.doublenegative.com.au/jumpstart/examples/tables/gridmodel1 Would you recommend me switching to a GridDataSource in my page class for providing the data instead of a list and a BeanModel? Especially regarding to the following example case: So the List is the GridDataSource in your case. This is a fine example of tapestry "magic". Tapestry coerces the List to a GridDataSource. Read about Type Coercion here http://tapestry.apache.org/type-coercion.html. See full list of coercions tapestry provides here http://tapestry.apache.org/typecoercer-service.html. the coercion I mentioned is documented in the page like this java.util.Collection --> org.apache.tapestry5.grid.GridDataSource If you want to persist you data just use @Persist on the list and don't recreate the list each time the grid is rendered (for example in setupRender). Image a User object with a list. I later want to display the user, and the size of the list. I tried the following, which does not work obviously but you get the idea: BeanModel model; model.add("products count", PropertyConduitSource.create(User.class, "products.size()")); class User { List products; } -- View this message in context: http://tapestry.1045711.n5.nabble.com/Retain-BeanModel-when-sorting-columns-tp5717374p5717379.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Retain BeanModel when sorting columns?
OK I see. I'm doing it with BeanModelSource based on this example: http://jumpstart.doublenegative.com.au/jumpstart/examples/tables/gridmodel1 Would you recommend me switching to a GridDataSource in my page class for providing the data instead of a list and a BeanModel? Especially regarding to the following example case: Image a User object with a list. I later want to display the user, and the size of the list. I tried the following, which does not work obviously but you get the idea: BeanModel model; model.add("products count", PropertyConduitSource.create(User.class, "products.size()")); class User { List products; } -- View this message in context: http://tapestry.1045711.n5.nabble.com/Retain-BeanModel-when-sorting-columns-tp5717374p5717379.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Retain BeanModel when sorting columns?
On Mon, 29 Oct 2012 08:35:51 -0200, membersound wrote: @Property @Persist private BeanModel model; void setupRender() { this.model = beanModelSource.createDisplayModel(User.class, messages); this.model.add("...).sortable(true); } Result: everytime I sort, the db-fetch is triggered. How can I persist the beanmodel data and just sort without refetching data? It seems to me you're thinking there's a single issue in your message, but there are two. BeanModel doesn't know anything about data. Data is GridDataSource's resposibility. BeanModel is just about properties and what is shown or edited in BeanEditor, BeanEditModel, BeanDisplay and Grid. Your @Persist in BeanModel doesn't make sense in the code above, as you're recreating the model every render and as it doesn't hold data. If you want to sort without refetching data, you should implement that in a GridDataSource implementation or fetch all the data into a list, use it as the source parameter and @Persist it. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Retain BeanModel when sorting columns?
Can we have the full code? You are probably talking about a grid. The grid data is in the GridDataSource not in the BeanModel. Anyway. If you have a Hibernate like GridDataSource I wouldn't recommend persisting it because the sort should be done using SQL "order by" so persisting would imply you should fetch the entire data set etc. On 29.10.2012 11:35, membersound wrote: @Property @Persist private BeanModel model; void setupRender() { this.model = beanModelSource.createDisplayModel(User.class, messages); this.model.add("...).sortable(true); } Result: everytime I sort, the db-fetch is triggered. How can I persist the beanmodel data and just sort without refetching data? -- View this message in context: http://tapestry.1045711.n5.nabble.com/Retain-BeanModel-when-sorting-columns-tp5717374.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Retain BeanModel when sorting columns?
@Property @Persist private BeanModel model; void setupRender() { this.model = beanModelSource.createDisplayModel(User.class, messages); this.model.add("...).sortable(true); } Result: everytime I sort, the db-fetch is triggered. How can I persist the beanmodel data and just sort without refetching data? -- View this message in context: http://tapestry.1045711.n5.nabble.com/Retain-BeanModel-when-sorting-columns-tp5717374.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Trouble related with beaneditform, beanmodel and propertyconduit
Hi everybody. I'm trying to edit an entity via a beaneditform which has some other entities inside. I'll write down a simple case so that it's easy to understand the issue. The tml file has the following line: This object member is an EntityB object: public class EntityB{ private String sb; public String getSb() {return sb;} public void setSb(String sb) {this.sb = sb;} private EntityA ea; public EntityA getEa() {return ea;} public void setEa(EntityA ea) {this.ea = ea;} } EntityA is a simple class: public class EntityA{ private String s1; public String getS1() {return s1;} public void setS1(String s1) {this.s1 = s1;} private int i1; public int getI1() {return i1;} public void setI1(int i1) {this.i1 = i1;} } Finally, the page class has the following code: @Property private EntityB member; @Inject private BeanModelSource beanModelSource; @Inject private ComponentResources resources; public BeanModel getModel(){ BeanModel result = beanModelSource.createEditModel(EntityB.class, resources.getMessages()); result.add("string1",new EntityBPropertyConduit1()); return result; } And the EntityBPropertyConduit1 class is as follows: public class EntityBPropertyConduit1 implements PropertyConduit { @Override public Object get(Object instance) { EntityB myObject = (EntityB) instance; if(myObject.getEa()==null){ return new String(); } return myObject.getEa().getS1(); } @Override public void set(Object instance, Object value) { EntityB myObject = (EntityB) instance; String myValue = (String) value; if(myObject.getEa()==null){ myObject.setEa(new EntityA()); } myObject.getEa().setS1(myValue); } @Override public Class getPropertyType() { return String.class; } @Override public T getAnnotation(Class arg0) { // TODO Auto-generated method stub return null; } } With all of this, I get the error The data type for property 'string1' of project.example.entities.EntityB@21ec03 is null. What am I missing?. I though once you give the beanmodel the propertyconduit, it knows how to deal with the property... -- View this message in context: http://tapestry.1045711.n5.nabble.com/Trouble-related-with-beaneditform-beanmodel-and-propertyconduit-tp5699891.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: setSortAscending on BeanModel in Grid
thanks. It certainly works. Just seems like a hack for something so simple. On Oct 20, 2010, at 9:38 AM, Josh Canfield wrote: > If you want to you can provide a custom sort model, it's a pretty > simple interface. > > Alternatively, if all you want to do is start with sort descending > then you could just do this: > > _grid.getSortModel().updateSort("entered"); // sorts ascending > _grid.getSortModel().updateSort("entered"); // now sorts descending > > ugly, but effective. > > On Wed, Oct 20, 2010 at 5:41 AM, Darren Williams wrote: >> Hi, we have been trying to work out a way to set the default sort order on >> our BeanModel to descending by default, since this is what out SQL query >> does but it appears as though the grid does not expose this method as shown >> below. >> >> Is there another way we can do this? All the examples I have seen before 5.2 >> use this technique, but 5.2 has made this method private. >> >> >> public BeanModel getBeanModel() { >> //setup the model for this user >>if (beanModel == null) { >> >> beanModel=beanModelSource.createDisplayModel(License.class, messages); >>beanModel.include("entered","endDate"); >> >>//sorting >>if >> (_grid.getSortModel().getSortConstraints().isEmpty() ) { >>_grid.getSortModel().updateSort("entered"); >> //this is still not exposed in tapestry 5.2 >> so you can't change order >>//_grid.setSortAscending(false); >>} >>} >>return beanModel; >>} >> >> regards, Darren >> >> > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > _ Darren Williams LiveTime Software Inc. http://www.livetime.com (949) 777 5800 - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: setSortAscending on BeanModel in Grid
If you want to you can provide a custom sort model, it's a pretty simple interface. Alternatively, if all you want to do is start with sort descending then you could just do this: _grid.getSortModel().updateSort("entered"); // sorts ascending _grid.getSortModel().updateSort("entered"); // now sorts descending ugly, but effective. On Wed, Oct 20, 2010 at 5:41 AM, Darren Williams wrote: > Hi, we have been trying to work out a way to set the default sort order on > our BeanModel to descending by default, since this is what out SQL query does > but it appears as though the grid does not expose this method as shown below. > > Is there another way we can do this? All the examples I have seen before 5.2 > use this technique, but 5.2 has made this method private. > > > public BeanModel getBeanModel() { > //setup the model for this user > if (beanModel == null) { > > beanModel=beanModelSource.createDisplayModel(License.class, messages); > beanModel.include("entered","endDate"); > > //sorting > if > (_grid.getSortModel().getSortConstraints().isEmpty() ) { > _grid.getSortModel().updateSort("entered"); > //this is still not exposed in tapestry 5.2 so > you can't change order > //_grid.setSortAscending(false); > } > } > return beanModel; > } > > regards, Darren > > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: setSortAscending on BeanModel in Grid
Hi, I don't use 5.2, but it seems based on your code this should work (I do this in 5.1.0.5): ColumnSort colSort = _grid.getSortModel().getColumnSort("txnId"); while(!colSort.equals(ColumnSort.DESCENDING)){ _grid.getSortModel().updateSort("txnId"); //Should invert the sort colSort = _grid.getSortModel().getColumnSort("txnId"); debug("\n\nColumnSort for txnId after one call to updateSort is: " + colSort + "\n"); } -Rich On 10/20/2010 08:41 AM, Darren Williams wrote: Hi, we have been trying to work out a way to set the default sort order on our BeanModel to descending by default, since this is what out SQL query does but it appears as though the grid does not expose this method as shown below. Is there another way we can do this? All the examples I have seen before 5.2 use this technique, but 5.2 has made this method private. public BeanModel getBeanModel() { //setup the model for this user if (beanModel == null) { beanModel=beanModelSource.createDisplayModel(License.class, messages); beanModel.include("entered","endDate"); //sorting if (_grid.getSortModel().getSortConstraints().isEmpty() ) { _grid.getSortModel().updateSort("entered"); //this is still not exposed in tapestry 5.2 so you can't change order //_grid.setSortAscending(false); } } return beanModel; } regards, Darren - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
setSortAscending on BeanModel in Grid
Hi, we have been trying to work out a way to set the default sort order on our BeanModel to descending by default, since this is what out SQL query does but it appears as though the grid does not expose this method as shown below. Is there another way we can do this? All the examples I have seen before 5.2 use this technique, but 5.2 has made this method private. public BeanModel getBeanModel() { //setup the model for this user if (beanModel == null) { beanModel=beanModelSource.createDisplayModel(License.class, messages); beanModel.include("entered","endDate"); //sorting if (_grid.getSortModel().getSortConstraints().isEmpty() ) { _grid.getSortModel().updateSort("entered"); //this is still not exposed in tapestry 5.2 so you can't change order //_grid.setSortAscending(false); } } return beanModel; } regards, Darren
Re: T5.1 Question regarding BeanModel and BeanModelSource
Yes, what you've described, in general, would work. Although you wouldn't necessarily need to contribute to DefaultDataTypeAnalyzer. If you're already adding the "@DisplayForEdit"-annotated properties in the decorator, you could easily define the datatype for them explicitly, as well. See: http://tapestry.apache.org/tapestry5.1/apidocs/org/apache/tapestry5/beaneditor/PropertyModel.html#dataType(java.lang.String) Aside from that, yes, I think the strategy detailed below would work. Robert On Jun 9, 2009, at 6/94:55 AM , Michael Gerzabek wrote: Ok, thank you Robert! Let me rephrase/ summarize that using the @DisplayForEdit approach you kindly offered. Step 1: Create a custom annotation @DisplayForEdit for properties without setter that should be displayed when editing is used in BeanEdit/Form. Step 2: Then a decorator would implement the logic for detecting this annotation and adding the corresponding property to the BeanModel. This would be done with something like model.add( "display" ); in my former example. The decorator would be configured like explained in the ioc cookbook [1]. Now my call to modelSource.createEditModel(..) includes all read- only properties annotated with DisplayForEdit, as well as the editable properties. "But you'd have to be careful with an approach like that because unless you define a custom block for displaying the property, tapestry will, by default, try to create an editor for the property (if you're using BeanEditor or BeanEditForm), and it'll complain that there's no setter for your property." Ok. I use BeanEditor/Form, so this is something I've to get clear about. I found that the @DataType annotation makes it explicit what property editor to use for a specific property. So when I enhance the @DisplayForEdit annotation to further act like the @DataType annotation I could contribute a new property editor like pointed out in the BeanEditFormGuide [2]. So let's continue with Step 3: I would public static void contributeDefaultDataTypeAnalyzer(MappedConfiguration configuration) { configuration.add( Object.class, "display" ); } add a property block to my AppPropertyEditBlocks and contribute this to the BeanBlockSource. The PropertyEditBlocks would simply return a NOPValidator and a NOPTranslator. My block would look like ${display} where I've something like @Component(..) private Object display; in my PropertyEditBlocks. Is this what you suggested - what would work? Thanks, Michael [1] http://tapestry.apache.org/tapestry5.1/tapestry-ioc/cookbook/override.html [2] http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html Robert Zeigler schrieb: Hm, I'm not sure I fully understand your use-case. For instance, in the example you provide, using createDisplayModel would already pick up the read-only "description" property. In any event, there are lots of ways you could go imagine handling this. For example, you could write a custom annotation: @DisplayForEdit And then you could provide a service override (or a service decorator) of BeanModelSource that checks for properties with DisplayForEdit and adds them to the model. Then your call to: modelSource.createEditModel would include all read-only properties annotated with DisplayForEdit, as well as the editable properties. But you'd have to be careful with an approach like that because unless you define a custom block for displaying the property, tapestry will, by default, try to create an editor for the property (if you're using BeanEditor or BeanEditForm), and it'll complain that there's no setter for your property. Additionally, the BeanDisplay, BeanEditor, BeanEditForm, and Grid components all accept "include", "exclude", "add", and "reorder" parameters, so you can decide what belongs in your model in a declarative fashion: Robert On Jun 8, 2009, at 6/811:39 PM , Michael Gerzabek wrote: Thank you Robert! To give you a way of looking at my problem. Bean Customizing has some usual properties that are read only, like symbol, isDeclared, etc. but only one property that is writeable, the value. The read only properties provide meaning to the person fostering the Customizing instance. Now there is the usual approach that I prepare a distinct page (which in fact I did) to collect the value for the Customizing instance. This page displays the rest of the bean in a verbose mode to the user. Straight forward, no problem. Anyway, I'm just curious: Since I can imagine many occasions where a bean not only would hold data but also some semantics on the data that would be useful to be displayed to a person editing this bean. Is there a standard way to get this job done by BeanEditor/ BeanModel? To pick up
Re: T5.1 Question regarding BeanModel and BeanModelSource
Ok, thank you Robert! Let me rephrase/ summarize that using the @DisplayForEdit approach you kindly offered. Step 1: Create a custom annotation @DisplayForEdit for properties without setter that should be displayed when editing is used in BeanEdit/Form. Step 2: Then a decorator would implement the logic for detecting this annotation and adding the corresponding property to the BeanModel. This would be done with something like model.add( "display" ); in my former example. The decorator would be configured like explained in the ioc cookbook [1]. Now my call to modelSource.createEditModel(..) includes all read-only properties annotated with DisplayForEdit, as well as the editable properties. "But you'd have to be careful with an approach like that because unless you define a custom block for displaying the property, tapestry will, by default, try to create an editor for the property (if you're using BeanEditor or BeanEditForm), and it'll complain that there's no setter for your property." Ok. I use BeanEditor/Form, so this is something I've to get clear about. I found that the @DataType annotation makes it explicit what property editor to use for a specific property. So when I enhance the @DisplayForEdit annotation to further act like the @DataType annotation I could contribute a new property editor like pointed out in the BeanEditFormGuide [2]. So let's continue with Step 3: I would public static void contributeDefaultDataTypeAnalyzer(MappedConfiguration configuration) { configuration.add( Object.class, "display" ); } add a property block to my AppPropertyEditBlocks and contribute this to the BeanBlockSource. The PropertyEditBlocks would simply return a NOPValidator and a NOPTranslator. My block would look like ${display} where I've something like @Component(..) private Object display; in my PropertyEditBlocks. Is this what you suggested - what would work? Thanks, Michael [1] http://tapestry.apache.org/tapestry5.1/tapestry-ioc/cookbook/override.html [2] http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html Robert Zeigler schrieb: Hm, I'm not sure I fully understand your use-case. For instance, in the example you provide, using createDisplayModel would already pick up the read-only "description" property. In any event, there are lots of ways you could go imagine handling this. For example, you could write a custom annotation: @DisplayForEdit And then you could provide a service override (or a service decorator) of BeanModelSource that checks for properties with DisplayForEdit and adds them to the model. Then your call to: modelSource.createEditModel would include all read-only properties annotated with DisplayForEdit, as well as the editable properties. But you'd have to be careful with an approach like that because unless you define a custom block for displaying the property, tapestry will, by default, try to create an editor for the property (if you're using BeanEditor or BeanEditForm), and it'll complain that there's no setter for your property. Additionally, the BeanDisplay, BeanEditor, BeanEditForm, and Grid components all accept "include", "exclude", "add", and "reorder" parameters, so you can decide what belongs in your model in a declarative fashion: Robert On Jun 8, 2009, at 6/811:39 PM , Michael Gerzabek wrote: Thank you Robert! To give you a way of looking at my problem. Bean Customizing has some usual properties that are read only, like symbol, isDeclared, etc. but only one property that is writeable, the value. The read only properties provide meaning to the person fostering the Customizing instance. Now there is the usual approach that I prepare a distinct page (which in fact I did) to collect the value for the Customizing instance. This page displays the rest of the bean in a verbose mode to the user. Straight forward, no problem. Anyway, I'm just curious: Since I can imagine many occasions where a bean not only would hold data but also some semantics on the data that would be useful to be displayed to a person editing this bean. Is there a standard way to get this job done by BeanEditor/ BeanModel? To pick up your snippet: On my concrete BeanModel for bean Customizing I would need something like BeanModel getModel() { BeanModel model = beanModelSource.createDisplayModel( Customizing.class, messages ); // property description is read only but contains information on how the // fostering of this Customizing instance will influence the behaviour of // the application model.display( "description" ); return model; } Is there a way to get this done? Would be nice somehow. Michael Zeigler schrieb: So: 1) createDisplayModel() acts the same as createModel(...,false,...); and createEditModel is like createModel(...,true,..
Re: T5.1 Question regarding BeanModel and BeanModelSource
Hm, I'm not sure I fully understand your use-case. For instance, in the example you provide, using createDisplayModel would already pick up the read-only "description" property. In any event, there are lots of ways you could go imagine handling this. For example, you could write a custom annotation: @DisplayForEdit And then you could provide a service override (or a service decorator) of BeanModelSource that checks for properties with DisplayForEdit and adds them to the model. Then your call to: modelSource.createEditModel would include all read-only properties annotated with DisplayForEdit, as well as the editable properties. But you'd have to be careful with an approach like that because unless you define a custom block for displaying the property, tapestry will, by default, try to create an editor for the property (if you're using BeanEditor or BeanEditForm), and it'll complain that there's no setter for your property. Additionally, the BeanDisplay, BeanEditor, BeanEditForm, and Grid components all accept "include", "exclude", "add", and "reorder" parameters, so you can decide what belongs in your model in a declarative fashion: Robert On Jun 8, 2009, at 6/811:39 PM , Michael Gerzabek wrote: Thank you Robert! To give you a way of looking at my problem. Bean Customizing has some usual properties that are read only, like symbol, isDeclared, etc. but only one property that is writeable, the value. The read only properties provide meaning to the person fostering the Customizing instance. Now there is the usual approach that I prepare a distinct page (which in fact I did) to collect the value for the Customizing instance. This page displays the rest of the bean in a verbose mode to the user. Straight forward, no problem. Anyway, I'm just curious: Since I can imagine many occasions where a bean not only would hold data but also some semantics on the data that would be useful to be displayed to a person editing this bean. Is there a standard way to get this job done by BeanEditor/ BeanModel? To pick up your snippet: On my concrete BeanModel for bean Customizing I would need something like BeanModel getModel() { BeanModel model = beanModelSource.createDisplayModel( Customizing.class, messages ); // property description is read only but contains information on how the // fostering of this Customizing instance will influence the behaviour of // the application model.display( "description" ); return model; } Is there a way to get this done? Would be nice somehow. Michael Zeigler schrieb: So: 1) createDisplayModel() acts the same as createModel(...,false,...); and createEditModel is like createModel(...,true,...) So if you have your bean, the @NonVisual properties won't show up for editing or display. Using createDisplayModel will add all properties with a getter that aren't otherwise marked as @NonVisual, and using createEditModel will only add the properties will getters and setters. But once you have the model, you can manipulate it anyway you want. For example: BeanModel getModel() { BeanModel model = beanModelSource.createDisplayModel(MyBean.class,messages); model.exclude("someProp"); return model; } Robert On Jun 8, 2009, at 6/810:38 AM , Michael Gerzabek wrote: Hi, BeanModelSource now has deprecated create(..) in favor of createDisplayModel(..) and createEditModel(..). This is a nice feature leaving me with one question: I want to edit a bean that has some properties that should not be displayed at all (@NonVisual), some properties that should be displayed but not enabled for editing. Those properties can have setters but some also don't have setters at all. And then there are some properties that should be editable. How would I achive this? Thanks for your help, Michael - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5.1 Question regarding BeanModel and BeanModelSource
Thank you Robert! To give you a way of looking at my problem. Bean Customizing has some usual properties that are read only, like symbol, isDeclared, etc. but only one property that is writeable, the value. The read only properties provide meaning to the person fostering the Customizing instance. Now there is the usual approach that I prepare a distinct page (which in fact I did) to collect the value for the Customizing instance. This page displays the rest of the bean in a verbose mode to the user. Straight forward, no problem. Anyway, I'm just curious: Since I can imagine many occasions where a bean not only would hold data but also some semantics on the data that would be useful to be displayed to a person editing this bean. Is there a standard way to get this job done by BeanEditor/ BeanModel? To pick up your snippet: On my concrete BeanModel for bean Customizing I would need something like BeanModel getModel() { BeanModel model = beanModelSource.createDisplayModel( Customizing.class, messages ); // property description is read only but contains information on how the // fostering of this Customizing instance will influence the behaviour of // the application model.display( "description" ); return model; } Is there a way to get this done? Would be nice somehow. Michael Zeigler schrieb: So: 1) createDisplayModel() acts the same as createModel(...,false,...); and createEditModel is like createModel(...,true,...) So if you have your bean, the @NonVisual properties won't show up for editing or display. Using createDisplayModel will add all properties with a getter that aren't otherwise marked as @NonVisual, and using createEditModel will only add the properties will getters and setters. But once you have the model, you can manipulate it anyway you want. For example: BeanModel getModel() { BeanModel model = beanModelSource.createDisplayModel(MyBean.class,messages); model.exclude("someProp"); return model; } Robert On Jun 8, 2009, at 6/810:38 AM , Michael Gerzabek wrote: Hi, BeanModelSource now has deprecated create(..) in favor of createDisplayModel(..) and createEditModel(..). This is a nice feature leaving me with one question: I want to edit a bean that has some properties that should not be displayed at all (@NonVisual), some properties that should be displayed but not enabled for editing. Those properties can have setters but some also don't have setters at all. And then there are some properties that should be editable. How would I achive this? Thanks for your help, Michael - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5.1 Question regarding BeanModel and BeanModelSource
So: 1) createDisplayModel() acts the same as createModel(...,false,...); and createEditModel is like createModel(...,true,...) So if you have your bean, the @NonVisual properties won't show up for editing or display. Using createDisplayModel will add all properties with a getter that aren't otherwise marked as @NonVisual, and using createEditModel will only add the properties will getters and setters. But once you have the model, you can manipulate it anyway you want. For example: BeanModel getModel() { BeanModel model = beanModelSource.createDisplayModel(MyBean.class,messages); model.exclude("someProp"); return model; } Robert On Jun 8, 2009, at 6/810:38 AM , Michael Gerzabek wrote: Hi, BeanModelSource now has deprecated create(..) in favor of createDisplayModel(..) and createEditModel(..). This is a nice feature leaving me with one question: I want to edit a bean that has some properties that should not be displayed at all (@NonVisual), some properties that should be displayed but not enabled for editing. Those properties can have setters but some also don't have setters at all. And then there are some properties that should be editable. How would I achive this? Thanks for your help, Michael - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: T5.1 Question regarding BeanModel and BeanModelSource
Two separate beans--you create one bean on your view page (to be passed into BeanDisplay), another bean on your edit page (to be passed into BeanEditForm). They can have completely distinct sets of properties. On Mon, Jun 8, 2009 at 11:38 AM, Michael Gerzabek wrote: > Hi, > > BeanModelSource now has deprecated create(..) in favor of > createDisplayModel(..) and createEditModel(..). This is a nice feature > leaving me with one question: > > I want to edit a bean that has some properties that should not be displayed > at all (@NonVisual), some properties that should be displayed but not > enabled for editing. Those properties can have setters but some also don't > have setters at all. And then there are some properties that should be > editable. How would I achive this? > > Thanks for your help, > Michael > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >
T5.1 Question regarding BeanModel and BeanModelSource
Hi, BeanModelSource now has deprecated create(..) in favor of createDisplayModel(..) and createEditModel(..). This is a nice feature leaving me with one question: I want to edit a bean that has some properties that should not be displayed at all (@NonVisual), some properties that should be displayed but not enabled for editing. Those properties can have setters but some also don't have setters at all. And then there are some properties that should be editable. How would I achive this? Thanks for your help, Michael - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
BeanModel
A question about BeanModel again http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/PropertyConduit.html It looks like "PropertyConduit" is the only way to modify a BeanModel - but this relies on Annotation...so adding fields that "do no exist" as metadata through Annotations in a class file can not be added? Is it maybe possible to "fake annotations" and add virtual annotation metadata to a dummy class somehow? Thanks! Toby - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
T5: Query about BeanModel
Am I correct in thinking that the default BeanModel only recognises the standard property types (String, double, etc, etc)? I have a bean with several properties, one of which is one of my own types. When I attempt to use this bean in Grid I am unable to specify the property in the include list. If I specify that particular property an error occurs and claims that the property does not exist (and it does not appear in the list of available properties). p. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Working with BeanModel
For future reference, here is the fix. I found it by looking at the source for BeanModelSourceImpl.java: BeanModel toReturn = _beanModelSource.create( MyClass.class, false, _componentResources ); toReturn.exclude( (String[])toReturn.getPropertyNames() .toArray( new String[0] ) ); PropertyConduit pc = _propertyConduitSource.create( MyClass.class, "pstlCode" ); ClassPropertyAdapter cpa = _propertyAccess.getAdapter( MyClass.class ); PropertyAdapter pa = cpa.getPropertyAdapter( "pstlCode" ); String dataType = _dataTypeAnalyzer.identifyDataType( pa ); toReturn.add( "pstlCode", pc ).dataType( dataType ); return( toReturn ); In the above example, the following were all injected: _beanModelSource _componentResources _propertyConduitSource _propertyAccess _dataTypeAnalyzer On Wed, 2008-07-02 at 03:34 -0400, Andy Huhn wrote: > Hello, > > I have a class defined (MyClass) that has a String property pstlCode, > with a getter and a setter. > > If I use BeanModelSource to create a BeanModel for MyClass, the > BeanModel has a property pstlCode that can be used to access the > pstlCode. > > However, if I exclude the pstlCode property, and then attempt to add it > back in with > > myBeanModel.exclude( "pstlCode" ); > myBeanModel.add( "pstlCode" ); > > it doesn't seem to pick up the data type of the property. Help? > > Thanks, > Andy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: Working with BeanModel
Hello, I have a class defined (MyClass) that has a String property pstlCode, with a getter and a setter. If I use BeanModelSource to create a BeanModel for MyClass, the BeanModel has a property pstlCode that can be used to access the pstlCode. However, if I exclude the pstlCode property, and then attempt to add it back in with myBeanModel.exclude( "pstlCode" ); myBeanModel.add( "pstlCode" ); it doesn't seem to pick up the data type of the property. Help? Thanks, Andy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: Clearing BeanModel properties and adding them back
Hello, It seems that if I create a BeanModel using BeanModel toReturn = _beanModelSrc.create( MyObject.class, false, _cmpntRsrcs ); Things work as they should - I can then use the properties in the BeanModel, as I expect to. But, if I first clear all properties from the BeanModel, and then try to add them back one-by-one, the BeanModel doesn't properly associate the "pstlCode" property with the getter/setter in MyObject.class: BeanModel toReturn = _beanModelSrc.create( MyObject.class, false, _cmpntRsrcs ); toReturn.exclude( (String[])toReturn.getPropertyNames().toArray( new String[0] ) ); toReturn.add( "pstlCode" ); Here is the error I receive: Unable to locate a block to edit property 'pstlCode' (with data type 'null') of object [EMAIL PROTECTED]: There is no defined way to edit data of type 'null'. Make a contribution to the BeanBlockSource service for this type. Any ideas? I'm on T5.0.13. Thanks, Andy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: BeanModel and complex types?
Hi Kris, thank you for the quick response! Thats what I was looking for. Udo. Original-Nachricht > Datum: Wed, 25 Jun 2008 10:18:33 +0200 > Von: Kristian Marinkovic <[EMAIL PROTECTED]> > An: "Tapestry users" > Betreff: Re: BeanModel and complex types? > hi udo, > > you have to contribute the child property type to the > DefaultDataTypeAnaylzer > so the BeanModelSource will not ignore it > > public static void contributeDefaultDataTypeAnalyzer...{ >configuration.add(MyType.class,"myType"); > > take a look https://issues.apache.org/jira/browse/TAPESTRY-2460 > it has two examples how to display a complex child property with another > block (containing another BeanEditor) > > g, > kris > > > > > "Udo Abel" <[EMAIL PROTECTED]> > 25.06.2008 10:05 > Bitte antworten an > "Tapestry users" > > > An > users@tapestry.apache.org > Kopie > > Thema > BeanModel and complex types? > > > > > > > > Hi, > > in many situations I have objects containing other objects as fields, > resulting from a 1:1 reference in a database. E.g., an employee has a > refrence to the subsidiary where he is working. > In those cases I want to display the name of the subsidiary in a Grid > component. > The property can be accessed by something like > employee.getSubsidiary().getName(); > > Is there a way to extend the BeanModel to access those properties? > Or do I have to duplicate all fields from complex types in simple fields > at the top level object, like > employee.getSubsidiaryName(); > ? > > Thanks, > Udo. > -- > Pt! Schon vom neuen GMX MultiMessenger gehört? > Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Pt! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: BeanModel and complex types?
hi udo, you have to contribute the child property type to the DefaultDataTypeAnaylzer so the BeanModelSource will not ignore it public static void contributeDefaultDataTypeAnalyzer...{ configuration.add(MyType.class,"myType"); take a look https://issues.apache.org/jira/browse/TAPESTRY-2460 it has two examples how to display a complex child property with another block (containing another BeanEditor) g, kris "Udo Abel" <[EMAIL PROTECTED]> 25.06.2008 10:05 Bitte antworten an "Tapestry users" An users@tapestry.apache.org Kopie Thema BeanModel and complex types? Hi, in many situations I have objects containing other objects as fields, resulting from a 1:1 reference in a database. E.g., an employee has a refrence to the subsidiary where he is working. In those cases I want to display the name of the subsidiary in a Grid component. The property can be accessed by something like employee.getSubsidiary().getName(); Is there a way to extend the BeanModel to access those properties? Or do I have to duplicate all fields from complex types in simple fields at the top level object, like employee.getSubsidiaryName(); ? Thanks, Udo. -- Pt! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
BeanModel and complex types?
Hi, in many situations I have objects containing other objects as fields, resulting from a 1:1 reference in a database. E.g., an employee has a refrence to the subsidiary where he is working. In those cases I want to display the name of the subsidiary in a Grid component. The property can be accessed by something like employee.getSubsidiary().getName(); Is there a way to extend the BeanModel to access those properties? Or do I have to duplicate all fields from complex types in simple fields at the top level object, like employee.getSubsidiaryName(); ? Thanks, Udo. -- Pt! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: clearing BeanModel properties
Hello, It seems that if I create a BeanModel using BeanModel toReturn = _beanModelSrc.create( MyObject.class, false, _cmpntRsrcs ); Things work as they should - I can then use the properties in the BeanModel, as I expect to. But, if I first clear all properties from the BeanModel, and then try to add them back one-by-one, I receive an error: BeanModel toReturn = _beanModelSrc.create( MyObject.class, false, _cmpntRsrcs ); toReturn.exclude( (String[])toReturn.getPropertyNames().toArray( new String[0] ) ); toReturn.add( "pstlCode" ); Here is the error I receive: Unable to locate a block to edit property 'pstlCode' (with data type 'null') of object [EMAIL PROTECTED]: There is no defined way to edit data of type 'null'. Make a contribution to the BeanBlockSource service for this type. Any ideas? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Contributing to the BeanModel
I am a sole developer on my project, and I am also using Fernando's approach. The "form beans" help solve order of data entry and other dependencies that I just wouldn't want to encode in the persistent model. In addition, I've found these "form beans" are a great way to insert hard coded data and do testing. i.e. public void generateSampleReportingUsers() { Registration r = new Registration(); r.setUsername("daniel.jue"); r.setPassword("urshipmentofFAILhasarrived"); r.setFirstName("Daniel"); r.setMiddleInitial(""); r.setLastName("Jue"); r.setInstallationAccess("DEMO"); r.setDatabaseAccess("DEMO"); ... ... this.addReportingUser(r); } On Wed, May 28, 2008 at 4:43 PM, Fernando Padilla <[EMAIL PROTECTED]> wrote: > The design pattern that we are starting to play with is to create beans > specifically for the forms. Then write code that ferries the data between > the form-bean and the actual persistent objects. > > This gives you more grunt work, but it adds a point of abstraction and > flexibility. For the most part it gives you freedom to construct your > form/ui differently than the underlying persistent model. For example, all > validator/data type annotations are tied to the form-bean instead of the > underlying persistent model, which might not match cleanly. Also your > persistent model might not be what you actually want to expose to the form. > Or you can expose a more complicated form which maps to persistent model in > different ways (multiple objects, etc etc). > > At the moment, it's not as "easy" as just giving the bean edit form your > persistent objects, but I think it's more flexible in the long run. So it's > just another option to keep in mind. You just have to keep your form-beans > outside of the components/pages packages or you'll have issues with the > tapestry enhancing classloaders.. We keep them under a forms package.. > > > Filip S. Adamsen wrote: >> >> Well, you're right. But to me, at least, it's not that big of a deal. The >> dependency will be to tapestry5-annotations, which is a very small >> dependency. >> >> Anyhow, developing Tapestry apps is just a hobby of mine - for now, anyhow >> - so I make the decisions myself. >> >> Sadly, I don't know of any other way to specify which constructor to use. >> I suggest you raise a JIRA issue if you want an alternative way to do it. >> >> -Filip >> >> On 2008-05-28 20:13, José Paumard wrote: >>> >>> Hello Filip, From what I understand, that would involve changing the object model >>> >>> (not so nice, I dont have the hand on that), and making a dependency >>> from this model to T5. I can already hear ppl screaming at that ;) >>> >>> Am I right ? >>> Thank you, >>> >>> José >>> >>> Filip S. Adamsen a écrit : Hi José, You can put @Inject in the constructor you want Tapestry to use for auto-instantiation. Should solve your problem. -Filip >>> >>> >>> - >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >> >> - >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Contributing to the BeanModel
The design pattern that we are starting to play with is to create beans specifically for the forms. Then write code that ferries the data between the form-bean and the actual persistent objects. This gives you more grunt work, but it adds a point of abstraction and flexibility. For the most part it gives you freedom to construct your form/ui differently than the underlying persistent model. For example, all validator/data type annotations are tied to the form-bean instead of the underlying persistent model, which might not match cleanly. Also your persistent model might not be what you actually want to expose to the form. Or you can expose a more complicated form which maps to persistent model in different ways (multiple objects, etc etc). At the moment, it's not as "easy" as just giving the bean edit form your persistent objects, but I think it's more flexible in the long run. So it's just another option to keep in mind. You just have to keep your form-beans outside of the components/pages packages or you'll have issues with the tapestry enhancing classloaders.. We keep them under a forms package.. Filip S. Adamsen wrote: Well, you're right. But to me, at least, it's not that big of a deal. The dependency will be to tapestry5-annotations, which is a very small dependency. Anyhow, developing Tapestry apps is just a hobby of mine - for now, anyhow - so I make the decisions myself. Sadly, I don't know of any other way to specify which constructor to use. I suggest you raise a JIRA issue if you want an alternative way to do it. -Filip On 2008-05-28 20:13, José Paumard wrote: Hello Filip, From what I understand, that would involve changing the object model (not so nice, I dont have the hand on that), and making a dependency from this model to T5. I can already hear ppl screaming at that ;) Am I right ? Thank you, José Filip S. Adamsen a écrit : Hi José, You can put @Inject in the constructor you want Tapestry to use for auto-instantiation. Should solve your problem. -Filip - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Contributing to the BeanModel
Well, you're right. But to me, at least, it's not that big of a deal. The dependency will be to tapestry5-annotations, which is a very small dependency. Anyhow, developing Tapestry apps is just a hobby of mine - for now, anyhow - so I make the decisions myself. Sadly, I don't know of any other way to specify which constructor to use. I suggest you raise a JIRA issue if you want an alternative way to do it. -Filip On 2008-05-28 20:13, José Paumard wrote: Hello Filip, From what I understand, that would involve changing the object model (not so nice, I dont have the hand on that), and making a dependency from this model to T5. I can already hear ppl screaming at that ;) Am I right ? Thank you, José Filip S. Adamsen a écrit : Hi José, You can put @Inject in the constructor you want Tapestry to use for auto-instantiation. Should solve your problem. -Filip - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Contributing to the BeanModel
Hello Filip, From what I understand, that would involve changing the object model (not so nice, I dont have the hand on that), and making a dependency from this model to T5. I can already hear ppl screaming at that ;) Am I right ? Thank you, José Filip S. Adamsen a écrit : Hi José, You can put @Inject in the constructor you want Tapestry to use for auto-instantiation. Should solve your problem. -Filip - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Contributing to the BeanModel
Hi José, You can put @Inject in the constructor you want Tapestry to use for auto-instantiation. Should solve your problem. -Filip On 2008-05-28 15:59, José Paumard wrote: Hello Marcus, Thank you for your answer, but the customization provided by the BeanModel are about properties, their orders etc... A bean is built by a call to newInstance, defined in the BeanModel interface. The way the bean is built comes from InternalUtils.findAutobuildConstructor. This class choses a constructor with a given algorithm, namely it choses the constructor with the largest number of arguments. Then T5 tries to match the arguments it needs with the services it has at hand. This approach is smart, but it would need a major refactoring of the object (old and legacy) model I already have, so I dont want to use it. It would be great if I could write something like configuration.add(MyBean.class, "constructor", myBeanConstructor) ; to tell T5 what constructor I want to see used for what class, or configuration.add(MyBean.class, BeanModel.class, MyBeanModelImpl.class) to tell T5 that for MyBean.class, I want to use the given implementation of bean model, in that case I could overide the newInstance method. But BeanModelImpl is in the internal package, so this would be a less robust approach. Thank you, José - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Contributing to the BeanModel
Hello Marcus, Thank you for your answer, but the customization provided by the BeanModel are about properties, their orders etc... A bean is built by a call to newInstance, defined in the BeanModel interface. The way the bean is built comes from InternalUtils.findAutobuildConstructor. This class choses a constructor with a given algorithm, namely it choses the constructor with the largest number of arguments. Then T5 tries to match the arguments it needs with the services it has at hand. This approach is smart, but it would need a major refactoring of the object (old and legacy) model I already have, so I dont want to use it. It would be great if I could write something like configuration.add(MyBean.class, "constructor", myBeanConstructor) ; to tell T5 what constructor I want to see used for what class, or configuration.add(MyBean.class, BeanModel.class, MyBeanModelImpl.class) to tell T5 that for MyBean.class, I want to use the given implementation of bean model, in that case I could overide the newInstance method. But BeanModelImpl is in the internal package, so this would be a less robust approach. Thank you, José Marcus a écrit : Hi José, Maybe this help. http://tapestry.apache.org/tapestry5/tapestry-core/guide/beaneditform.html http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app3/ http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/ Marcus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
use final for BeanModel fields
Hi Guys, just a little side note on Filip´s suggesion. Instead of initializing the BeanModel in onActivate() you could do this: private final BeanModel model; { model = beanModelSource.create(User.class, false, componentResources); model.get("username").sortable(false); } Mind the final. This way the BeanModel is only created once. With onActivate() it is created every time the page is requested, which is less efficient. Of course this only works, if you do not want to change the BeanModel after creation. Cheers nillehammer - original Nachricht > Hi, > > You're not disturbing - this is a mailing list, if you can't post to it, > what good is it? :) > > Anyhow, YourGridRowClassType is User in your case. So if you want to > disable sorting on the username property, you would do it like this: > >@Inject >private BeanModelSource beanModelSource; > >@Inject >private ComponentResources componentResources; > >private BeanModel model; > >void onActivate() { > model = beanModelSource.create(User.class, false, componentResources); > model.get("username").sortable(false); >} > > Hope that helps. > > -Filip - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Contributing to the BeanModel
Hi José, Maybe this help. http://tapestry.apache.org/tapestry5/tapestry-core/guide/beaneditform.html http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app3/ http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app3/ Marcus
Re: T5: Teaching the BeanModel to always add my class
Hi Filip, it's good to hear that it is just a leftover, so I can ignore it and stop wondering. Thanks again for your help! Tobias Filip S. Adamsen schrieb: Hi, On 2008-04-15 19:13, Tobias Wehrum wrote: Thank you, Filip! Looking through the page you suggested, I found the missing piece of code: -- public static void contributeDefaultDataTypeAnalyzer(MappedConfiguration configuration) { configuration.add(Status.class, "status"); } -- And now it works! :) Great. :) Just because I'm curious: What does contributeTranslatorDefaultSource do? Using it didn't seem to have any effect. Well, it's a leftover from earlier on when you had to contribute to both TranslatorSource and TranslatorDefaultSource. It was kind of awkward so it was changed. Tobias -Filip Tobias Wehrum schrieb: Hi there, yes, maybe I caused confusion. To further point out what I'm trying to do: I just want to output whatever value Status.toString() will return to me, for example in a grid. When I add the property to the BeanModel, tapestry has no problems calling toString() automatically; but at the moment, like I said, I have to add it first to the BeanModel, and I want to automatize this. (When it comes to input, I will implement t:parameter for it.) Regards, Tobias Filip S. Adamsen schrieb: Oh, sorry, didn't catch that all you want to edit is a String property from another class. I don't know what else there is to do, then. -Filip On 2008-04-15 18:41, Filip S. Adamsen wrote: Hi, You might need to add a new property editor, see Adding New Property Editors at http://tapestry.apache.org/tapestry5/tapestry-core/guide/beaneditform.html. -Filip On 2008-04-15 18:37, Tobias Wehrum wrote: Hi there, I have a class named "Status" which implements toString(). But still when I have class A, which has a property of type Status, I always have to add the Status property to the BeanModel with model.add("myStatus"). Obviously implementing toString() isn't enough to teach my the BeanModel a new trick. So I tried to contribute a TypeCoercer and a TranslatorSource, but neither of them seems to work. My try on TypeCoercer: -- public static void contributeTypeCoercer(Configuration configuration) { Coercion coercionStatusString = new Coercion() { public String coerce(Status input) { return input.toString(); } }; configuration.add(new CoercionTupleString>(Status.class, String.class, coercionStatusString)); } -- My try on TranslatorSource: -- public static void contributeTranslatorDefaultSource(MappedConfigurationTranslator> configuration) { configuration.add(Status.class, new StatusTranslator()); } public static void contributeTranslatorSource(MappedConfigurationTranslator> configuration) { configuration.add("status", new StatusTranslator()); } -- -- public class StatusTranslator implements Translator { public Class getType() { return Status.class; } public Status parseClient(String arg0, Messages arg1) throws ValidationException { throw new ValidationException("StatusTranslator cannot implement parseClient()"); } public String toClient(Status arg0) { return arg0.toString(); } } -- Am I missing something? Or am I on a complete wrong path? Any hints on how to solve my problem are welcome. Thanks in advance, Tobias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Teaching the BeanModel to always add my class
Hi, On 2008-04-15 19:13, Tobias Wehrum wrote: Thank you, Filip! Looking through the page you suggested, I found the missing piece of code: -- public static void contributeDefaultDataTypeAnalyzer(MappedConfiguration configuration) { configuration.add(Status.class, "status"); } -- And now it works! :) Great. :) Just because I'm curious: What does contributeTranslatorDefaultSource do? Using it didn't seem to have any effect. Well, it's a leftover from earlier on when you had to contribute to both TranslatorSource and TranslatorDefaultSource. It was kind of awkward so it was changed. Tobias -Filip Tobias Wehrum schrieb: Hi there, yes, maybe I caused confusion. To further point out what I'm trying to do: I just want to output whatever value Status.toString() will return to me, for example in a grid. When I add the property to the BeanModel, tapestry has no problems calling toString() automatically; but at the moment, like I said, I have to add it first to the BeanModel, and I want to automatize this. (When it comes to input, I will implement t:parameter for it.) Regards, Tobias Filip S. Adamsen schrieb: Oh, sorry, didn't catch that all you want to edit is a String property from another class. I don't know what else there is to do, then. -Filip On 2008-04-15 18:41, Filip S. Adamsen wrote: Hi, You might need to add a new property editor, see Adding New Property Editors at http://tapestry.apache.org/tapestry5/tapestry-core/guide/beaneditform.html. -Filip On 2008-04-15 18:37, Tobias Wehrum wrote: Hi there, I have a class named "Status" which implements toString(). But still when I have class A, which has a property of type Status, I always have to add the Status property to the BeanModel with model.add("myStatus"). Obviously implementing toString() isn't enough to teach my the BeanModel a new trick. So I tried to contribute a TypeCoercer and a TranslatorSource, but neither of them seems to work. My try on TypeCoercer: -- public static void contributeTypeCoercer(Configuration configuration) { Coercion coercionStatusString = new Coercion() { public String coerce(Status input) { return input.toString(); } }; configuration.add(new CoercionTupleString>(Status.class, String.class, coercionStatusString)); } -- My try on TranslatorSource: -- public static void contributeTranslatorDefaultSource(MappedConfigurationTranslator> configuration) { configuration.add(Status.class, new StatusTranslator()); } public static void contributeTranslatorSource(MappedConfiguration configuration) { configuration.add("status", new StatusTranslator()); } -- -- public class StatusTranslator implements Translator { public Class getType() { return Status.class; } public Status parseClient(String arg0, Messages arg1) throws ValidationException { throw new ValidationException("StatusTranslator cannot implement parseClient()"); } public String toClient(Status arg0) { return arg0.toString(); } } -- Am I missing something? Or am I on a complete wrong path? Any hints on how to solve my problem are welcome. Thanks in advance, Tobias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Teaching the BeanModel to always add my class
Thank you, Filip! Looking through the page you suggested, I found the missing piece of code: -- public static void contributeDefaultDataTypeAnalyzer(MappedConfiguration configuration) { configuration.add(Status.class, "status"); } -- And now it works! :) Just because I'm curious: What does contributeTranslatorDefaultSource do? Using it didn't seem to have any effect. Tobias Tobias Wehrum schrieb: Hi there, yes, maybe I caused confusion. To further point out what I'm trying to do: I just want to output whatever value Status.toString() will return to me, for example in a grid. When I add the property to the BeanModel, tapestry has no problems calling toString() automatically; but at the moment, like I said, I have to add it first to the BeanModel, and I want to automatize this. (When it comes to input, I will implement t:parameter for it.) Regards, Tobias Filip S. Adamsen schrieb: Oh, sorry, didn't catch that all you want to edit is a String property from another class. I don't know what else there is to do, then. -Filip On 2008-04-15 18:41, Filip S. Adamsen wrote: Hi, You might need to add a new property editor, see Adding New Property Editors at http://tapestry.apache.org/tapestry5/tapestry-core/guide/beaneditform.html. -Filip On 2008-04-15 18:37, Tobias Wehrum wrote: Hi there, I have a class named "Status" which implements toString(). But still when I have class A, which has a property of type Status, I always have to add the Status property to the BeanModel with model.add("myStatus"). Obviously implementing toString() isn't enough to teach my the BeanModel a new trick. So I tried to contribute a TypeCoercer and a TranslatorSource, but neither of them seems to work. My try on TypeCoercer: -- public static void contributeTypeCoercer(Configuration configuration) { Coercion coercionStatusString = new Coercion() { public String coerce(Status input) { return input.toString(); } }; configuration.add(new CoercionTupleString>(Status.class, String.class, coercionStatusString)); } -- My try on TranslatorSource: -- public static void contributeTranslatorDefaultSource(MappedConfigurationTranslator> configuration) { configuration.add(Status.class, new StatusTranslator()); } public static void contributeTranslatorSource(MappedConfiguration configuration) { configuration.add("status", new StatusTranslator()); } -- -- public class StatusTranslator implements Translator { public Class getType() { return Status.class; } public Status parseClient(String arg0, Messages arg1) throws ValidationException { throw new ValidationException("StatusTranslator cannot implement parseClient()"); } public String toClient(Status arg0) { return arg0.toString(); } } -- Am I missing something? Or am I on a complete wrong path? Any hints on how to solve my problem are welcome. Thanks in advance, Tobias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Teaching the BeanModel to always add my class
Hi there, yes, maybe I caused confusion. To further point out what I'm trying to do: I just want to output whatever value Status.toString() will return to me, for example in a grid. When I add the property to the BeanModel, tapestry has no problems calling toString() automatically; but at the moment, like I said, I have to add it first to the BeanModel, and I want to automatize this. (When it comes to input, I will implement t:parameter for it.) Regards, Tobias Filip S. Adamsen schrieb: Oh, sorry, didn't catch that all you want to edit is a String property from another class. I don't know what else there is to do, then. -Filip On 2008-04-15 18:41, Filip S. Adamsen wrote: Hi, You might need to add a new property editor, see Adding New Property Editors at http://tapestry.apache.org/tapestry5/tapestry-core/guide/beaneditform.html. -Filip On 2008-04-15 18:37, Tobias Wehrum wrote: Hi there, I have a class named "Status" which implements toString(). But still when I have class A, which has a property of type Status, I always have to add the Status property to the BeanModel with model.add("myStatus"). Obviously implementing toString() isn't enough to teach my the BeanModel a new trick. So I tried to contribute a TypeCoercer and a TranslatorSource, but neither of them seems to work. My try on TypeCoercer: -- public static void contributeTypeCoercer(Configuration configuration) { Coercion coercionStatusString = new Coercion() { public String coerce(Status input) { return input.toString(); } }; configuration.add(new CoercionTupleString>(Status.class, String.class, coercionStatusString)); } -- My try on TranslatorSource: -- public static void contributeTranslatorDefaultSource(MappedConfigurationTranslator> configuration) { configuration.add(Status.class, new StatusTranslator()); } public static void contributeTranslatorSource(MappedConfiguration configuration) { configuration.add("status", new StatusTranslator()); } -- -- public class StatusTranslator implements Translator { public Class getType() { return Status.class; } public Status parseClient(String arg0, Messages arg1) throws ValidationException { throw new ValidationException("StatusTranslator cannot implement parseClient()"); } public String toClient(Status arg0) { return arg0.toString(); } } -- Am I missing something? Or am I on a complete wrong path? Any hints on how to solve my problem are welcome. Thanks in advance, Tobias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Teaching the BeanModel to always add my class
Oh, sorry, didn't catch that all you want to edit is a String property from another class. I don't know what else there is to do, then. -Filip On 2008-04-15 18:41, Filip S. Adamsen wrote: Hi, You might need to add a new property editor, see Adding New Property Editors at http://tapestry.apache.org/tapestry5/tapestry-core/guide/beaneditform.html. -Filip On 2008-04-15 18:37, Tobias Wehrum wrote: Hi there, I have a class named "Status" which implements toString(). But still when I have class A, which has a property of type Status, I always have to add the Status property to the BeanModel with model.add("myStatus"). Obviously implementing toString() isn't enough to teach my the BeanModel a new trick. So I tried to contribute a TypeCoercer and a TranslatorSource, but neither of them seems to work. My try on TypeCoercer: -- public static void contributeTypeCoercer(Configuration configuration) { Coercion coercionStatusString = new Coercion() { public String coerce(Status input) { return input.toString(); } }; configuration.add(new CoercionTupleString>(Status.class, String.class, coercionStatusString)); } -- My try on TranslatorSource: -- public static void contributeTranslatorDefaultSource(MappedConfigurationTranslator> configuration) { configuration.add(Status.class, new StatusTranslator()); } public static void contributeTranslatorSource(MappedConfiguration configuration) { configuration.add("status", new StatusTranslator()); } -- -- public class StatusTranslator implements Translator { public Class getType() { return Status.class; } public Status parseClient(String arg0, Messages arg1) throws ValidationException { throw new ValidationException("StatusTranslator cannot implement parseClient()"); } public String toClient(Status arg0) { return arg0.toString(); } } -- Am I missing something? Or am I on a complete wrong path? Any hints on how to solve my problem are welcome. Thanks in advance, Tobias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Teaching the BeanModel to always add my class
Hi, You might need to add a new property editor, see Adding New Property Editors at http://tapestry.apache.org/tapestry5/tapestry-core/guide/beaneditform.html. -Filip On 2008-04-15 18:37, Tobias Wehrum wrote: Hi there, I have a class named "Status" which implements toString(). But still when I have class A, which has a property of type Status, I always have to add the Status property to the BeanModel with model.add("myStatus"). Obviously implementing toString() isn't enough to teach my the BeanModel a new trick. So I tried to contribute a TypeCoercer and a TranslatorSource, but neither of them seems to work. My try on TypeCoercer: -- public static void contributeTypeCoercer(Configuration configuration) { Coercion coercionStatusString = new Coercion() { public String coerce(Status input) { return input.toString(); } }; configuration.add(new CoercionTupleString>(Status.class, String.class, coercionStatusString)); } -- My try on TranslatorSource: -- public static void contributeTranslatorDefaultSource(MappedConfiguration configuration) { configuration.add(Status.class, new StatusTranslator()); } public static void contributeTranslatorSource(MappedConfiguration configuration) { configuration.add("status", new StatusTranslator()); } -- -- public class StatusTranslator implements Translator { public Class getType() { return Status.class; } public Status parseClient(String arg0, Messages arg1) throws ValidationException { throw new ValidationException("StatusTranslator cannot implement parseClient()"); } public String toClient(Status arg0) { return arg0.toString(); } } -- Am I missing something? Or am I on a complete wrong path? Any hints on how to solve my problem are welcome. Thanks in advance, Tobias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: Teaching the BeanModel to always add my class
Hi there, I have a class named "Status" which implements toString(). But still when I have class A, which has a property of type Status, I always have to add the Status property to the BeanModel with model.add("myStatus"). Obviously implementing toString() isn't enough to teach my the BeanModel a new trick. So I tried to contribute a TypeCoercer and a TranslatorSource, but neither of them seems to work. My try on TypeCoercer: -- public static void contributeTypeCoercer(Configuration configuration) { Coercion coercionStatusString = new Coercion() { public String coerce(Status input) { return input.toString(); } }; configuration.add(new CoercionTupleString>(Status.class, String.class, coercionStatusString)); } -- My try on TranslatorSource: -- public static void contributeTranslatorDefaultSource(MappedConfiguration configuration) { configuration.add(Status.class, new StatusTranslator()); } public static void contributeTranslatorSource(MappedConfiguration configuration) { configuration.add("status", new StatusTranslator()); } -- -- public class StatusTranslator implements Translator { public Class getType() { return Status.class; } public Status parseClient(String arg0, Messages arg1) throws ValidationException { throw new ValidationException("StatusTranslator cannot implement parseClient()"); } public String toClient(Status arg0) { return arg0.toString(); } } -- Am I missing something? Or am I on a complete wrong path? Any hints on how to solve my problem are welcome. Thanks in advance, Tobias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[T5] BeanModel and null values
Hi all, I'm working with the Grid component and customizing the BeanModel for display. I'd like to show complex paths in the grid. So, I've added them to the model and everything works well, except when there's a null somewhere along the path. Then in get an NPE in the ConduitWrapper. How does one go about handling null values in this case? I'd like to just register a null value handler and have it spit out "Not Available" if a null value occurs at all in the property path. For what it's worth, I can handle it in the template by controlling the cell rendering. But, as soon as one tries to sort that column, the NPE is triggered again. Any help would be much appreciated. Thanks, Kevin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]