Another newbie question: Type coercions not working for me
Hi again. Another noob question: I've been trying to google this one for quite some time, but I still can't figure out how I can pass a CayenneDataObject to a component using a binding. I have registered a Type Coercer from String to CayenneDataObject, and it's getting invoked when I read the binding, but if I do this… t:MyCustomComponent input=someCayenneDataObject / …the coerce( String ) method of the Type Coercer recieves the string someCayenneDataObject as parameter? Help! - hugi - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Another newbie question: Type coercions not working for me
On Fri, 09 Dec 2011 09:08:13 -0200, Hugi Thordarson h...@karlmenn.is wrote: Hi again. Hi! Another noob question: I've been trying to google this one for quite some time, but I still can't figure out how I can pass a CayenneDataObject to a component using a binding. Just do it. :) I have registered a Type Coercer from String to CayenneDataObject, and it's getting invoked when I read the binding, but if I do this… t:MyCustomComponent input=someCayenneDataObject / …the coerce( String ) method of the Type Coercer recieves the string someCayenneDataObject as parameter? Tapestry parameters can be of any type without any conversion to String needed. What's the type of the input filed in your custom component? What's its binding? Could you post the component source (or at least the component declaration)? -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Another newbie question: Type coercions not working for me
Oh dear… After reading the sentence Tapestry parameters can be of any type without any conversion I performed a little sanity check on my code—turns out the example code I copied form somewhere had defaultPrefix = BindingConstants.LITERAL specified on the binding. Silly, silly… Thanks! - hugi On 9.12.2011, at 11:54, Thiago H. de Paula Figueiredo wrote: On Fri, 09 Dec 2011 09:08:13 -0200, Hugi Thordarson h...@karlmenn.is wrote: Hi again. Hi! Another noob question: I've been trying to google this one for quite some time, but I still can't figure out how I can pass a CayenneDataObject to a component using a binding. Just do it. :) I have registered a Type Coercer from String to CayenneDataObject, and it's getting invoked when I read the binding, but if I do this… t:MyCustomComponent input=someCayenneDataObject / …the coerce( String ) method of the Type Coercer recieves the string someCayenneDataObject as parameter? Tapestry parameters can be of any type without any conversion to String needed. What's the type of the input filed in your custom component? What's its binding? Could you post the component source (or at least the component declaration)? -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Another newbie question: Type coercions not working for me
OK, now it _almost_ works Still, interestingly enough though, it doesn't seem to work in a loop. Consider the following code: t:loop source=objects value=currentObject t:ObjectLink object=currentObject${currentObject.name}/t:ObjectLink /t:loop In the component ObjectLink, I can print the value of currentObject.name. However, if I use the object binding in an action method (onActionFromSelect) the object parameter is always null? Code for ObjectLink here: https://gist.github.com/1451368 Any ideas? Cheers, - hugi On 9.12.2011, at 12:02, Hugi Thordarson wrote: Oh dear… After reading the sentence Tapestry parameters can be of any type without any conversion I performed a little sanity check on my code—turns out the example code I copied form somewhere had defaultPrefix = BindingConstants.LITERAL specified on the binding. Silly, silly… Thanks! - hugi On 9.12.2011, at 11:54, Thiago H. de Paula Figueiredo wrote: On Fri, 09 Dec 2011 09:08:13 -0200, Hugi Thordarson h...@karlmenn.is wrote: Hi again. Hi! Another noob question: I've been trying to google this one for quite some time, but I still can't figure out how I can pass a CayenneDataObject to a component using a binding. Just do it. :) I have registered a Type Coercer from String to CayenneDataObject, and it's getting invoked when I read the binding, but if I do this… t:MyCustomComponent input=someCayenneDataObject / …the coerce( String ) method of the Type Coercer recieves the string someCayenneDataObject as parameter? Tapestry parameters can be of any type without any conversion to String needed. What's the type of the input filed in your custom component? What's its binding? Could you post the component source (or at least the component declaration)? -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - 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: Another newbie question: Type coercions not working for me
Hmm, interesting. Doesn't seem to work even if I send the object as a context parameter, the object is still null in the action method :-/ - hugi On 9.12.2011, at 12:50, Thiago H. de Paula Figueiredo wrote: On Fri, 09 Dec 2011 10:38:07 -0200, Hugi Thordarson h...@karlmenn.is wrote: In the component ObjectLink, I can print the value of currentObject.name. However, if I use the object binding in an action method (onActionFromSelect) the object parameter is always null? Because onActionFromSelect() is invoked in another request, so the value of currentObject is lost unless you persist it in some way. In Tapestry 4 your code would work, but T4 had something called the rewind phase that caused worse problems, so T5 doesn't have rewind (yeah!). The recommended solution here is to add context=currentObject to the ActionLink inside your component and make onActionFromSelect() to receive the context. Something like this: t:actionLink t:id=select context=objectt:body //t:actionLink Object onActionFromSelect(CayenneDataObject object) { Class pageClass = CRUDUtil.detailPageClass( object.getClass() ); DetailPageCayenneDataObject t = (DetailPageCayenneDataObject)componentSource.getPage( pageClass ); t.setSelectedObject( object ); return t; } -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Another newbie question: Type coercions not working for me
(just ignore the commented out code, it's what I'm using to work around the problem until I find a solution) What's the rendered HTML? Well, if I disable the ValueEncoder I made for CayenneDataObjects, it will look like this: http://localhost:8080/tap/userlist.objectlink2.select/$007b$003cObjectId:User$002c$0020id$003d2$003e$003b$0020committed$003b$0020$005bid$003d$003e2$003b$0020creationDate$003d$003eFri$0020Dec$002002$002015:37:45$0020GMT$00202011$003b$0020registrationOffers$003d$003e$003f$003b$0020address$003d$003eGla$00f0heimar$002010$003b$0020contactName$003d$003eGummi$003b$0020userDocuments$003d$003e$003f$003b$0020registrations$003d$003e$003f$003b$0020visitorID$003d$003e1$003b$0020visitor$003d$003e$003f$003b$0020city$003d$003eReykjav$00edk$003b$0020ipAddress$003d$003e$005d$007d But if the ValueEncoder is enabled, it looks like this: http://localhost:8080/tap/userlist.objectlink2.select/1503831936-User-2 I think the commented-out code is better because it avoids one request (the redirection). Ah, I see. I like the other style better since it allows me to work with the actual page class (passing in variables etc). It seems that when I use the LinkSource-method of generating page URLs, variables I set in a page one time leak over to the next time the page is opened (for inspecting a different object). I'm still not entirely sure what how the lifecycle of page instances works, so I guess I'm going back to the documentation on that one. Thanks you for all your help. Cheers, - hugi - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Another newbie question: Type coercions not working for me
On Fri, 09 Dec 2011 13:01:10 -0200, Hugi Thordarson h...@karlmenn.is wrote: What's the rendered HTML? Well, if I disable the ValueEncoder I made for CayenneDataObjects, it will look like this: http://localhost:8080/tap/userlist.objectlink2.select/$007b$003cObjectId:User$002c$0020id$003d2$003e$003b$0020committed$003b$0020$005bid$003d$003e2$003b$0020creationDate$003d$003eFri$0020Dec$002002$002015:37:45$0020GMT$00202011$003b$0020registrationOffers$003d$003e$003f$003b$0020address$003d$003eGla$00f0heimar$002010$003b$0020contactName$003d$003eGummi$003b$0020userDocuments$003d$003e$003f$003b$0020registrations$003d$003e$003f$003b$0020visitorID$003d$003e1$003b$0020visitor$003d$003e$003f$003b$0020city$003d$003eReykjav$00edk$003b$0020ipAddress$003d$003e$005d$007d But if the ValueEncoder is enabled, it looks like this: http://localhost:8080/tap/userlist.objectlink2.select/1503831936-User-2 The CayenneDataObject = String mapping seems to work. Have you checked if the String = CayenneDataObject works? Ah, I see. I like the other style better since it allows me to work with the actual page class (passing in variables etc). Yep, this has this advantage. :) But, if you're just passing data, I still prefer the page activation context. Of course, it depends on each specific case. It seems that when I use the LinkSource-method of generating page URLs, variables I set in a page one time leak over to the next time the page is opened (for inspecting a different object). This looks like a bug in your code. Please post the source of the page that displays or edits the object. The links generated by PageRenderLinkSource (which is used by PageLink) don't do anything related to page lifecycle. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Another newbie question: Type coercions not working for me
So it looks like the value is being put into the url, as expected for the context of an action link. Is your onAction method receiving that context? onActionFromSelect(CayenneDataObject object) {...} If you have your original method: onActionFromSelect() {...} then it's not going to do what you expect; either way, the @Parameter object is going to be null (unless you explicitly set it in your onAction method). But the right way, you will recover the appropriate object from the method parameter. Robert On Dec 9, 2011, at 12/99:01 AM , Hugi Thordarson wrote: (just ignore the commented out code, it's what I'm using to work around the problem until I find a solution) What's the rendered HTML? Well, if I disable the ValueEncoder I made for CayenneDataObjects, it will look like this: http://localhost:8080/tap/userlist.objectlink2.select/$007b$003cObjectId:User$002c$0020id$003d2$003e$003b$0020committed$003b$0020$005bid$003d$003e2$003b$0020creationDate$003d$003eFri$0020Dec$002002$002015:37:45$0020GMT$00202011$003b$0020registrationOffers$003d$003e$003f$003b$0020address$003d$003eGla$00f0heimar$002010$003b$0020contactName$003d$003eGummi$003b$0020userDocuments$003d$003e$003f$003b$0020registrations$003d$003e$003f$003b$0020visitorID$003d$003e1$003b$0020visitor$003d$003e$003f$003b$0020city$003d$003eReykjav$00edk$003b$0020ipAddress$003d$003e$005d$007d But if the ValueEncoder is enabled, it looks like this: http://localhost:8080/tap/userlist.objectlink2.select/1503831936-User-2 I think the commented-out code is better because it avoids one request (the redirection). Ah, I see. I like the other style better since it allows me to work with the actual page class (passing in variables etc). It seems that when I use the LinkSource-method of generating page URLs, variables I set in a page one time leak over to the next time the page is opened (for inspecting a different object). I'm still not entirely sure what how the lifecycle of page instances works, so I guess I'm going back to the documentation on that one. Thanks you for all your help. Cheers, - hugi - 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