You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Rick Austin <ri...@rickaustin.net> on 2004/10/15 16:49:14 UTC

TapestryTables (examples) - DirectLink Column to Pick Row

I just wanted to share a modification I made to John Reynold's
TapestryTables example. My goal was to provide a link in each row for a
column that can be used to select that row and then move to a detail
page for the selected item. I tested my approaches using the SeventhPass
page from the TapestryTables example.

After trying a couple of things I finally hit upon this approach. There
may be a better way of doing this and if so feel free to let me know
since I've only been using Tapestry for a month or so.

I added the following components to SeventhPass.page:

<component id="SSNColumnValue" type="Block"/>

<!--
 * Used to create a link which has a listener and passes in the current
 * SSN as a parameter.
-->
<component id="SSNLink" type="DirectLink">
	<binding name="listener" expression="listeners.SelectListener"/>
	<binding name="parameters"
expression="components.table.tableRow.SSN"/>
</component> 

<!--
 * Used to output the SSN value into the row since the SSNLink component
 * creates a link but does not have a way of providing the link text.
-->
<component id="SSNText" type="InsertText">
	<binding name="value"
expression="components.table.tableRow.SSN"/>
</component> 

In the SeventhPass.html I made the following changes:

<!--
 * Added the SSNColumnValue block just before the existing
 * WeightColumnValue block.
-->
<span jwcid="SSNColumnValue">
	<span jwcid="SSNLink">
		<span jwcid="SSNText"/>
	</span>
</span>
<span jwcid="WeightColumnValue">
	<span jwcid="editableWeight"/>
</span>

Added the following listener to EditableColumnPage2.java:

public void SelectListener(IRequestCycle cycle) {
	Object[] parameters = cycle.getServiceParameters();
	String SSN = (String)parameters[0];
	// Output the parameter value to the console to see if
	// this works.
	System.out.println("Selected SSN: " + SSN);
}

This works like a charm in the TapestryTables project. For some reason I
can't get this to work in my own pages. The only difference I can find
is that I'm not using abstract getter/setters for my list used to
populate the table. Regardless, I wanted to share this since I could not
find any examples for how to do this.



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


RE: TapestryTables (examples) - DirectLink Column to Pick Row

Posted by John Reynolds <jo...@austin.rr.com>.
Rick,

Your example sounds really good, and I will try to get it included soon.
If you get this technique working in your own project please let me know
so we can document it.  I think it's really useful to know the common
mistakes. 

I updated
https://bloggers.dev.java.net/files/documents/84/7378/TapestryTables.war
this afternoon with some new stuff (I'm up to TenthPass)... 



-----Original Message-----
From: Rick Austin [mailto:rick@rickaustin.net] 
Sent: Friday, October 15, 2004 9:49 AM
To: 'Tapestry users'
Subject: TapestryTables (examples) - DirectLink Column to Pick Row


I just wanted to share a modification I made to John Reynold's
TapestryTables example. My goal was to provide a link in each row for a
column that can be used to select that row and then move to a detail
page for the selected item. I tested my approaches using the SeventhPass
page from the TapestryTables example.

After trying a couple of things I finally hit upon this approach. There
may be a better way of doing this and if so feel free to let me know
since I've only been using Tapestry for a month or so.

I added the following components to SeventhPass.page:

<component id="SSNColumnValue" type="Block"/>

<!--
 * Used to create a link which has a listener and passes in the current
 * SSN as a parameter.
-->
<component id="SSNLink" type="DirectLink">
	<binding name="listener" expression="listeners.SelectListener"/>
	<binding name="parameters"
expression="components.table.tableRow.SSN"/>
</component> 

<!--
 * Used to output the SSN value into the row since the SSNLink component
 * creates a link but does not have a way of providing the link text.
-->
<component id="SSNText" type="InsertText">
	<binding name="value"
expression="components.table.tableRow.SSN"/>
</component> 

In the SeventhPass.html I made the following changes:

<!--
 * Added the SSNColumnValue block just before the existing
 * WeightColumnValue block.
-->
<span jwcid="SSNColumnValue">
	<span jwcid="SSNLink">
		<span jwcid="SSNText"/>
	</span>
</span>
<span jwcid="WeightColumnValue">
	<span jwcid="editableWeight"/>
</span>

Added the following listener to EditableColumnPage2.java:

public void SelectListener(IRequestCycle cycle) {
	Object[] parameters = cycle.getServiceParameters();
	String SSN = (String)parameters[0];
	// Output the parameter value to the console to see if
	// this works.
	System.out.println("Selected SSN: " + SSN);
}

This works like a charm in the TapestryTables project. For some reason I
can't get this to work in my own pages. The only difference I can find
is that I'm not using abstract getter/setters for my list used to
populate the table. Regardless, I wanted to share this since I could not
find any examples for how to do this.



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


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