You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jean-Philippe Steinmetz <st...@ISI.EDU> on 2007/09/26 01:42:42 UTC

[T5] Linkable rows with Grid component

I would like to make each of the rows in my grid component output link to
some page. For instance have each row link to a detail page about that row.
Is this possible with the grid component? If so how can I do it? Thanks

 

Jean-Philippe Steinmetz

 


Re: [T5] Linkable rows with Grid component

Posted by Nick Westgate <ni...@key-planning.co.jp>.
I think there's a good argument for making the components as malleable
as possible - much more so than the other framework APIs. The exposure
to upgrade breakages is probably a necessary trade-off. E.g. for the full
utility of mixins to be realized:
https://issues.apache.org/jira/browse/TAPESTRY-1764

Cheers,
Nick.


Howard Lewis Ship wrote:
> Alternately, you could subclass GridRows to provide the hooks for what you
> need, then subclass Grid to make use of your custom GridRows.
> 
> The components in Tapestry are not meant to be sacrosanct, just useful.
> 
> Though that does bring up the question of component compatibility between
> releases.  Hmph.
> 
> On 9/27/07, Carl Pulley <c....@acme-labs.org.uk> wrote:
>>
>> Having now had the chance to tidy up my example code, here's my MixIn code
>> for the Grid Component:
>>
>> @MixinAfter
>> public class ActionRows {
>>
>>      public static final String event = "rowAction";
>>
>>     @Parameter(value="click", defaultPrefix="literal")
>>      private String action;
>>
>>     @Parameter(required=true)
>>      private String rowid;
>>
>>     @Inject
>>      private ComponentResources resources;
>>
>>     @AfterRender
>>     void after(MarkupWriter writer) {
>>         final String tbodyPath = "div/table/tbody";
>>         Element tbody = writer.getElement().find(tbodyPath);
>>         if (tbody == null) {
>>                 throw new RuntimeException(...);
>>         }
>>         for (Node rowNode : tbody.getChildren()) {
>>                 if (rowNode instanceof Element) {
>>                         ((Element) rowNode).attribute("on" + action, "
>> window.location.assign('" +
>> resources.createActionLink(event, false, new Object[] { rowid }) + "')");
>>                 }
>>         }
>>     } // end of AfterRender method
>>
>> } // end of MixIn class ActionRows
>>
>> and here's a typical page-usage scenario:
>>
>> @Component(parameters = { "action=dblclick", "rowid=row.id", "row=row",
>> ...
>> })
>> @MixinClasses(ActionRows.class)
>> private Grid displayData;
>>
>> @OnEvent(value = ActionRows.event, component = ...)
>> public Object displayRow(int id) {
>>   ...
>> }
>>
>> Hope that helps,
>>
>>   Carl.
>> --
>> View this message in context:
>> http://www.nabble.com/-T5--Linkable-rows-with-Grid-component-tf4519155.html#a12916995
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 

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


Re: [T5] Linkable rows with Grid component

Posted by Howard Lewis Ship <hl...@gmail.com>.
Alternately, you could subclass GridRows to provide the hooks for what you
need, then subclass Grid to make use of your custom GridRows.

The components in Tapestry are not meant to be sacrosanct, just useful.

Though that does bring up the question of component compatibility between
releases.  Hmph.

On 9/27/07, Carl Pulley <c....@acme-labs.org.uk> wrote:
>
>
> Having now had the chance to tidy up my example code, here's my MixIn code
> for the Grid Component:
>
> @MixinAfter
> public class ActionRows {
>
>      public static final String event = "rowAction";
>
>     @Parameter(value="click", defaultPrefix="literal")
>      private String action;
>
>     @Parameter(required=true)
>      private String rowid;
>
>     @Inject
>      private ComponentResources resources;
>
>     @AfterRender
>     void after(MarkupWriter writer) {
>         final String tbodyPath = "div/table/tbody";
>         Element tbody = writer.getElement().find(tbodyPath);
>         if (tbody == null) {
>                 throw new RuntimeException(...);
>         }
>         for (Node rowNode : tbody.getChildren()) {
>                 if (rowNode instanceof Element) {
>                         ((Element) rowNode).attribute("on" + action, "
> window.location.assign('" +
> resources.createActionLink(event, false, new Object[] { rowid }) + "')");
>                 }
>         }
>     } // end of AfterRender method
>
> } // end of MixIn class ActionRows
>
> and here's a typical page-usage scenario:
>
> @Component(parameters = { "action=dblclick", "rowid=row.id", "row=row",
> ...
> })
> @MixinClasses(ActionRows.class)
> private Grid displayData;
>
> @OnEvent(value = ActionRows.event, component = ...)
> public Object displayRow(int id) {
>   ...
> }
>
> Hope that helps,
>
>   Carl.
> --
> View this message in context:
> http://www.nabble.com/-T5--Linkable-rows-with-Grid-component-tf4519155.html#a12916995
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

RE: [T5] Linkable rows with Grid component

Posted by Carl Pulley <c....@acme-labs.org.uk>.
Having now had the chance to tidy up my example code, here's my MixIn code
for the Grid Component:

@MixinAfter
public class ActionRows {
	
     public static final String event = "rowAction";

    @Parameter(value="click", defaultPrefix="literal")
     private String action;
	
    @Parameter(required=true)
     private String rowid;
	
    @Inject
     private ComponentResources resources;
	
    @AfterRender
    void after(MarkupWriter writer) {
    	final String tbodyPath = "div/table/tbody";
	Element tbody = writer.getElement().find(tbodyPath);
	if (tbody == null) {
		throw new RuntimeException(...);
	}
	for (Node rowNode : tbody.getChildren()) {
		if (rowNode instanceof Element) {
			((Element) rowNode).attribute("on" + action, "window.location.assign('" +
resources.createActionLink(event, false, new Object[] { rowid }) + "')");
		}
	}
    } // end of AfterRender method
	
} // end of MixIn class ActionRows

and here's a typical page-usage scenario:

@Component(parameters = { "action=dblclick", "rowid=row.id", "row=row", ...
})
@MixinClasses(ActionRows.class)
private Grid displayData;

@OnEvent(value = ActionRows.event, component = ...)
public Object displayRow(int id) {
  ...
}

Hope that helps,

  Carl.
-- 
View this message in context: http://www.nabble.com/-T5--Linkable-rows-with-Grid-component-tf4519155.html#a12916995
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


RE: [T5] Linkable rows with Grid component

Posted by Carl Pulley <c....@acme-labs.org.uk>.
To achieve this effect, I've defined a mixin class that, after the component
has rendered, finds each row in the rendered element and then adds in an
attribute analogous to your example below.

Its far from glamourous (and certainly not as robust as one would like), but
it does the trick.


Jean-Philippe Steinmetz-2 wrote:
> 
> That's actually not quite what I'm looking for but I guess it'll have to
> do.
> I'm actually looking for a way to click the entire row. For instance the
> output HTML could be...
> 
> <table>
> 	<tr onclick="window.location.assign('itemdetail/34')">
> 		<td>Item 34</td>
> 		<td>Blah</td>
> 	</tr>
> 	<tr onclick=" window.location.assign('itemdetail/16')">
> 		<td>Item 16</td>
> 		<td>blah blah blah</td>
> 	</tr>
> </table>
> 
> 

-- 
View this message in context: http://www.nabble.com/-T5--Linkable-rows-with-Grid-component-tf4519155.html#a12906019
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


RE: [T5] Linkable rows with Grid component

Posted by Jean-Philippe Steinmetz <st...@ISI.EDU>.
That's actually not quite what I'm looking for but I guess it'll have to do.
I'm actually looking for a way to click the entire row. For instance the
output HTML could be...

<table>
	<tr onclick="window.location.assign('itemdetail/34')">
		<td>Item 34</td>
		<td>Blah</td>
	</tr>
	<tr onclick=" window.location.assign('itemdetail/16')">
		<td>Item 16</td>
		<td>blah blah blah</td>
	</tr>
</table>

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of sun58224
> Sent: Wednesday, September 26, 2007 2:17 AM
> To: users@tapestry.apache.org
> Subject: Re: [T5] Linkable rows with Grid component
> 
> 
> 
> Howard Lewis Ship <hlship <at> gmail.com> writes:
> 
> >
> > You just leverage the ability to override how particular columns are
> rendered:
> >
> > This assumes that your items have a property named label that you want
> > to convert into a link.
> >
> > <t:grid row="item" ...>
> >   <t:parameter name="label">
> >     <t:pagelink page="ItemDetail" context="item.id">${item.label}
> </t:pagelink>
> >   </t:parameter>
> > </t:grid>
> >
> > On 9/25/07, Jean-Philippe Steinmetz <steinmet <at> isi.edu> wrote:
> > > I would like to make each of the rows in my grid component output link
> to
> > > some page. For instance have each row link to a detail page about that
> row.
> > > Is this possible with the grid component? If so how can I do it?
> Thanks
> > >
> > >
> > >
> > > Jean-Philippe Steinmetz
> > >
> > >
> > >
> > >
> >
> 
> <t:grid row="item" ...>
>   <t:parameter name="labelCell">
>     <t:pagelink page="ItemDetail"
> context="item.id">${item.label}</t:pagelink>
>   </t:parameter>
> </t:grid>
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org


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


Re: [T5] Linkable rows with Grid component

Posted by sun58224 <su...@sina.com>.

Howard Lewis Ship <hlship <at> gmail.com> writes:

> 
> You just leverage the ability to override how particular columns are 
rendered:
> 
> This assumes that your items have a property named label that you want
> to convert into a link.
> 
> <t:grid row="item" ...>
>   <t:parameter name="label">
>     <t:pagelink page="ItemDetail" context="item.id">${item.label}
</t:pagelink>
>   </t:parameter>
> </t:grid>
> 
> On 9/25/07, Jean-Philippe Steinmetz <steinmet <at> isi.edu> wrote:
> > I would like to make each of the rows in my grid component output link to
> > some page. For instance have each row link to a detail page about that row.
> > Is this possible with the grid component? If so how can I do it? Thanks
> >
> >
> >
> > Jean-Philippe Steinmetz
> >
> >
> >
> >
> 

<t:grid row="item" ...>
  <t:parameter name="labelCell">
    <t:pagelink page="ItemDetail" context="item.id">${item.label}</t:pagelink>
  </t:parameter>
</t:grid>





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


Re: [T5] Linkable rows with Grid component

Posted by Howard Lewis Ship <hl...@gmail.com>.
You just leverage the ability to override how particular columns are rendered:

This assumes that your items have a property named label that you want
to convert into a link.


<t:grid row="item" ...>
  <t:parameter name="label">
    <t:pagelink page="ItemDetail" context="item.id">${item.label}</t:pagelink>
  </t:parameter>
</t:grid>


On 9/25/07, Jean-Philippe Steinmetz <st...@isi.edu> wrote:
> I would like to make each of the rows in my grid component output link to
> some page. For instance have each row link to a detail page about that row.
> Is this possible with the grid component? If so how can I do it? Thanks
>
>
>
> Jean-Philippe Steinmetz
>
>
>
>


-- 
Howard M. Lewis Ship
Partner and Senior Architect at Feature50

Creator Apache Tapestry and Apache HiveMind

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