Hi Konstanin, I don´t think Filips post was irony. It really is simple. Anyway answering your question: Simply returning a component from a getter (in your case a Link from getMyDynaObject) won´t cause tapestry to render it. For a component to be rendered you have to place it somewhere in the template.
The eplanation of the strange behaviour you see is you handing over a Link to a Grid as a data object. The default behaviour of Grid is to "scan" the data object for simple properies (i.e. a public getter and corresponding setter are present and getter returns simple types like Integer, String, Date etc.) and display the values in a table. The only property a Link contains is anchor (look here: http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/Link.html). And that is displayed. To achieve what you want you have to use <t:parameter> within the Grid and place some type of Link-component in the template. Look here for example: http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/Grid.html The UserList.tml right at the middle of the page. Hope that helps, nillehammer ----- original Nachricht -------- Betreff: Re: T5 t:renderObject and pageLink won't render link just text instead Gesendet: Do, 12. Jun 2008 Von: Konstantin<[EMAIL PROTECTED]> > > Irony ... good :-) Thanks for trying to help me with my dumb questions. > I simplified my first sample, let me make it more close to what I wanted: > > @Property > private MyGridRowObject myObject; // <t:grid row="myObject" ...> > > public Object getMyDynaObject() { > Link testLink; > switch(myObject.type) { > case TYPE1: > testLink = > componentResources.createPageLink("targetPageHere", true, "11"); > // here I need to get myObject.description to put it into > link, but > // don't know how to do that, you know ? > // also some link context would be nice but that could be > addParameter("context", "...") ?? > return testLink; > case TYPE2: > return myObject.description; // no link just render text > into this grid cell > } > } > > I created custom component with <t:if> and syntetic properties isType1(), > isType2() as a workaround (or should I say: "As a right way of doing things > in Tapestry"). But that seems weird to do like that. Why can't I use > getMyDynaObject() to tell Tapestry of what I need to render ? > > > Filip S. Adamsen-2 wrote: > > > > Hi, > > > > I see. It's actually easier than you'd think. Here's what you do: > > > > Class: > > > > @Inject > > private ComponentResources componentResources; > > > > public String getLink() { > > return componentResources.createPageLink("targetpagehere", > > true").toURI(); > > } > > > > Template: > > > > ${link} text for link > > > > See? It's easy. :) > > > > But since you're linking to a page, why not just use the PageLink > > component? That's even easier. > > > > <t:pagelink t:page="targetpagehere">text for link</t:pagelink> > > > > You can see all the components here: > > http://tapestry.apache.org/tapestry5/tapestry-core/ref/index.html > > > > Hope this helps. > > > > -Filip > > > > Konstantin skrev: > >> I think I'm missing concept behind renderObject component. > >> The original idea was to render Link or just some text basing on other > >> page > >> properties and actual object to be rendered should be returned by public > >> Object getMyDynaObject(). > >> So I need to get <href ...> in page markup for link, but instead I get > >> "targetPageHere/11". > >> Is it possible to do without creating custom component ? > >> > >> > >> Filip S. Adamsen-2 wrote: > >>> Hi, > >>> > >>> Tapestry does what you ask it to do - returns a (relative) URI for the > >>> link. (Check out the Javadocs/source for AbstractLink to see this.) > >>> > >>> I suspect that calling toAbsoluteURI() on the link will give you what > >>> you want. Oh, and you won't need RenderObject for that - you can just do > > >>> an expansion ${myDynaObject} in that case. > >>> > >>> -Filip > >>> > >>> Konstantin skrev: > >>>> in tml: > >>>> > >>>> <t:renderobject object="myDynaObject"/> > >>>> > >>>> in java: > >>>> > >>>> @Inject > >>>> private ComponentResources componentResources; > >>>> > >>>> public Object getMyDynaObject() { > >>>> Link testLink; > >>>> testLink = componentResources.createPageLink("targetPageHere", > >>>> true, > >>>> "11"); > >>>> return testLink; > >>>> } > >>>> > >>>> Renders text "targetPageHere/11" instead of actual link. What am I > >>>> doing > >>>> wrong here ? > >>>> > >>> --------------------------------------------------------------------- > >>> 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] > > > > > > > > -- > View this message in context: > http://www.nabble.com/T5-t%3ArenderObject-and-pageLink-won%27t-render-link-j > ust-text-instead-tp17782707p17794921.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --- original Nachricht Ende ---- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]