You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ra <ry...@gazeta.pl> on 2006/10/31 22:33:56 UTC

links in a table

I'd like display links in a table, but ... column names are unknown at the
development time

I'm new to tapestry and don't what is the best solution.
What I found is I can override method getValueRender in i.e.
SimpleTableRenderer and return somehow PageLink instance but it's abstract
class and have no idea how to do it
-- 
View this message in context: http://www.nabble.com/links-in-a-table-tf2548557.html#a7103183
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: links in a table

Posted by Daniel Jue <te...@gmail.com>.
I would recommend Kent Tong's book.  It's more of an advanced tutorial
than a book.  If I didn't have it, I would not be programming in
Tapestry at all.  And it was like $20US for the PDF.  BTW, the pdf is
better since you can copy and paste the code, and search for examples
much quicker.  Plus I can keep it on my thumb drive to use where-ever.

Are you using the Contrib Table?  Or are you trying to roll your own?
The book covers both, but I really like taking advantage of the
Contrib Table's features.

I am still a Tapestry novice myself, and I reference that book everyday.

Dan

On 10/31/06, ra <ry...@gazeta.pl> wrote:
>
>
> Ok. and how can I construct the url to a page ? The page name is known.
> Sorry I'm a novice
>
> Regards,
> Arek
>
>
>
> andyhot wrote:
> >
> > ok, so generate the String returned by getTableColumns()
> > at runtime...
> >
> >
> >
> > ra wrote:
> >>
> >> Daniel Jue wrote:
> >>
> >>> I recently found a solution due to some help on this mailing list.
> >>>
> >>> Here's what we came up with.  It displays a table of people, and the
> >>> extent of people details are not known until runtime (i.e. should we
> >>> display the first name, last name, email, etc)
> >>>
> >>> In the page file:
> >>>
> >>>     <component id="table" type="Contrib:Table">
> >>>         <binding name="source" value="users"/>
> >>>         <binding name="columns" value="tableColumns"/>
> >>>         <binding name="columnsClass" value="literal:title"/>
> >>>         <binding name="pageSize" value="10"/>
> >>>     </component>
> >>>
> >>> In your class for that page have this method:
> >>>
> >>> public String getTableColumns()
> >>> {
> >>>    //For reference
> >>>    //Column id:Column Title:ognl expression
> >>>    //value="literal:id, firstName:First name:name.firstName,
> >>>    //  lastName:name.lastName, telNo"/>
> >>>
> >>>    return
> >>> "data0:ID:getUserDetails('USERGUID'),data1:Email:getUserDetails('EMAIL'),data2:First
> >>> Name:getUserDetails('FIRSTNAME'),data3:Last
> >>> Name:getUserDetails('LASTNAME')";
> >>>
> >>>
> >>
> >> Sorry it doesn't help. As I wrote I don't know column names at
> >> development
> >> time. I don't know even the class name because model is created during
> >> runtime. I can give more details if it's not clear
> >>
> >>
> >>
> >
> >
> > --
> > Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
> > Tapestry / Tacos developer
> > Open Source / J2EE Consulting
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/links-in-a-table-tf2548557.html#a7104908
> 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: links in a table

Posted by ra <ry...@gazeta.pl>.

Ok. and how can I construct the url to a page ? The page name is known.
Sorry I'm a novice

Regards,
Arek



andyhot wrote:
> 
> ok, so generate the String returned by getTableColumns()
> at runtime...
> 
> 
> 
> ra wrote:
>>
>> Daniel Jue wrote:
>>   
>>> I recently found a solution due to some help on this mailing list.
>>>
>>> Here's what we came up with.  It displays a table of people, and the
>>> extent of people details are not known until runtime (i.e. should we
>>> display the first name, last name, email, etc)
>>>
>>> In the page file:
>>>
>>>     <component id="table" type="Contrib:Table">
>>>         <binding name="source" value="users"/>
>>>         <binding name="columns" value="tableColumns"/>
>>>         <binding name="columnsClass" value="literal:title"/>
>>>         <binding name="pageSize" value="10"/>
>>>     </component>
>>>
>>> In your class for that page have this method:
>>>
>>> public String getTableColumns()
>>> {	
>>>    //For reference
>>>    //Column id:Column Title:ognl expression
>>>    //value="literal:id, firstName:First name:name.firstName,
>>>    //  lastName:name.lastName, telNo"/>
>>>
>>>    return
>>> "data0:ID:getUserDetails('USERGUID'),data1:Email:getUserDetails('EMAIL'),data2:First
>>> Name:getUserDetails('FIRSTNAME'),data3:Last
>>> Name:getUserDetails('LASTNAME')";
>>>
>>>     
>>
>> Sorry it doesn't help. As I wrote I don't know column names at
>> development
>> time. I don't know even the class name because model is created during
>> runtime. I can give more details if it's not clear
>>
>>
>>   
> 
> 
> -- 
> Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
> Tapestry / Tacos developer
> Open Source / J2EE Consulting 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/links-in-a-table-tf2548557.html#a7104908
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: links in a table

Posted by andyhot <an...@di.uoa.gr>.
ok, so generate the String returned by getTableColumns()
at runtime...



ra wrote:
>
> Daniel Jue wrote:
>   
>> I recently found a solution due to some help on this mailing list.
>>
>> Here's what we came up with.  It displays a table of people, and the
>> extent of people details are not known until runtime (i.e. should we
>> display the first name, last name, email, etc)
>>
>> In the page file:
>>
>>     <component id="table" type="Contrib:Table">
>>         <binding name="source" value="users"/>
>>         <binding name="columns" value="tableColumns"/>
>>         <binding name="columnsClass" value="literal:title"/>
>>         <binding name="pageSize" value="10"/>
>>     </component>
>>
>> In your class for that page have this method:
>>
>> public String getTableColumns()
>> {	
>>    //For reference
>>    //Column id:Column Title:ognl expression
>>    //value="literal:id, firstName:First name:name.firstName,
>>    //  lastName:name.lastName, telNo"/>
>>
>>    return
>> "data0:ID:getUserDetails('USERGUID'),data1:Email:getUserDetails('EMAIL'),data2:First
>> Name:getUserDetails('FIRSTNAME'),data3:Last
>> Name:getUserDetails('LASTNAME')";
>>
>>     
>
> Sorry it doesn't help. As I wrote I don't know column names at development
> time. I don't know even the class name because model is created during
> runtime. I can give more details if it's not clear
>
>
>   


-- 
Andreas Andreou - andyhot@apache.org - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / J2EE Consulting 


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


Re: links in a table

Posted by ra <ry...@gazeta.pl>.


Daniel Jue wrote:
> 
> Hi,
> 
> Perhaps I am not understanding your situation or perhaps my example
> failed to stimulate your creativity. ;-)
> 
> If you don't know the class, at the minumum the class should implement
> something that will spit out the column names, and the way to get the
> elements of each row.
> 
> For instance, if your model classes all implemented a method that gave
> the Contrib table the column metadata it was looking for, it could
> return a runtime generated string that looks like this:
> 
> "data0:ID:getUserDetails('USERGUID'),data1:Email:getUserDetails('EMAIL'),data2:First
>  Name:getUserDetails('FIRSTNAME'),data3:Last
> Name:getUserDetails('LASTNAME')";
> 
> 

My English is not perfect can be I don't understand your ideas well.
The above string I can generate ok. But in the html template I have to use
data0, data1 to override the column body but I don't know number of columns
It's kind of generic search component. Lets say the class name is a
parameter here. Based on additional class's properties attributies criteria
form is generated (not all properties are shown). Next after search button
is clicked page with results is shown as links (again not all columns are
shown). If you click on a link you are redirected to the requsted page. If
somebody knows peoplesoft it's more or less copied idea. I write except
result page. Eventually I can render results in the for loop

-- 
View this message in context: http://www.nabble.com/links-in-a-table-tf2548557.html#a7105296
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: links in a table

Posted by Daniel Jue <te...@gmail.com>.
Hi,

Perhaps I am not understanding your situation or perhaps my example
failed to stimulate your creativity. ;-)

If you don't know the class, at the minumum the class should implement
something that will spit out the column names, and the way to get the
elements of each row.

For instance, if your model classes all implemented a method that gave
the Contrib table the column metadata it was looking for, it could
return a runtime generated string that looks like this:

"data0:ID:getUserDetails('USERGUID'),data1:Email:getUserDetails('EMAIL'),data2:First
 Name:getUserDetails('FIRSTNAME'),data3:Last
Name:getUserDetails('LASTNAME')";

Or more abstractly, the string above is 3 of these, one for each column of data:

"RowIdentifierForTheLoopToReference" + ":"+
"commonMethodForGettingColumnDisplayName()" +":" +
"commonMethodForGettingDataValue()"

The "RowIdentifierForTheLoopToReference" can be anything string, like "cat".
The table will increment the name for each row (row 8 would be "cat8")



So your data model class might have something like this?

Public Abstract Class DataModelBaseClass
{
public String GetStringForContribTableColNames();
public Object GetData(String ColName);
}

I am out of coffee, so I'm going home now.  Good luck!

Dan

On 10/31/06, ra <ry...@gazeta.pl> wrote:
>
>
>
> Daniel Jue wrote:
> >
> > I recently found a solution due to some help on this mailing list.
> >
> > Here's what we came up with.  It displays a table of people, and the
> > extent of people details are not known until runtime (i.e. should we
> > display the first name, last name, email, etc)
> >
> > In the page file:
> >
> >     <component id="table" type="Contrib:Table">
> >         <binding name="source" value="users"/>
> >         <binding name="columns" value="tableColumns"/>
> >         <binding name="columnsClass" value="literal:title"/>
> >         <binding name="pageSize" value="10"/>
> >     </component>
> >
> > In your class for that page have this method:
> >
> > public String getTableColumns()
> > {
> >    //For reference
> >    //Column id:Column Title:ognl expression
> >    //value="literal:id, firstName:First name:name.firstName,
> >    //  lastName:name.lastName, telNo"/>
> >
> >    return
> > "data0:ID:getUserDetails('USERGUID'),data1:Email:getUserDetails('EMAIL'),data2:First
> > Name:getUserDetails('FIRSTNAME'),data3:Last
> > Name:getUserDetails('LASTNAME')";
> >
>
> Sorry it doesn't help. As I wrote I don't know column names at development
> time. I don't know even the class name because model is created during
> runtime. I can give more details if it's not clear
>
>
> --
> View this message in context: http://www.nabble.com/links-in-a-table-tf2548557.html#a7104516
> 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: links in a table

Posted by ra <ry...@gazeta.pl>.


Daniel Jue wrote:
> 
> I recently found a solution due to some help on this mailing list.
> 
> Here's what we came up with.  It displays a table of people, and the
> extent of people details are not known until runtime (i.e. should we
> display the first name, last name, email, etc)
> 
> In the page file:
> 
>     <component id="table" type="Contrib:Table">
>         <binding name="source" value="users"/>
>         <binding name="columns" value="tableColumns"/>
>         <binding name="columnsClass" value="literal:title"/>
>         <binding name="pageSize" value="10"/>
>     </component>
> 
> In your class for that page have this method:
> 
> public String getTableColumns()
> {	
>    //For reference
>    //Column id:Column Title:ognl expression
>    //value="literal:id, firstName:First name:name.firstName,
>    //  lastName:name.lastName, telNo"/>
> 
>    return
> "data0:ID:getUserDetails('USERGUID'),data1:Email:getUserDetails('EMAIL'),data2:First
> Name:getUserDetails('FIRSTNAME'),data3:Last
> Name:getUserDetails('LASTNAME')";
> 

Sorry it doesn't help. As I wrote I don't know column names at development
time. I don't know even the class name because model is created during
runtime. I can give more details if it's not clear


-- 
View this message in context: http://www.nabble.com/links-in-a-table-tf2548557.html#a7104516
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: links in a table

Posted by Daniel Jue <te...@gmail.com>.
I recently found a solution due to some help on this mailing list.

Here's what we came up with.  It displays a table of people, and the
extent of people details are not known until runtime (i.e. should we
display the first name, last name, email, etc)

In the page file:

    <component id="table" type="Contrib:Table">
        <binding name="source" value="users"/>
        <binding name="columns" value="tableColumns"/>
        <binding name="columnsClass" value="literal:title"/>
        <binding name="pageSize" value="10"/>
    </component>

In your class for that page have this method:

public String getTableColumns()
{	
   //For reference
   //Column id:Column Title:ognl expression
   //value="literal:id, firstName:First name:name.firstName,
   //  lastName:name.lastName, telNo"/>

   return "data0:ID:getUserDetails('USERGUID'),data1:Email:getUserDetails('EMAIL'),data2:First
Name:getUserDetails('FIRSTNAME'),data3:Last
Name:getUserDetails('LASTNAME')";
	}

As you can see, the string that defines the columns, along this their
display names and "ID"s for the loop, can be generated at runtime.  I
thought that was really nifty.

As for the links, lets say you wanted the links to be on the user's email.


Add this to the page file:

<component id="data1ColumnValue" type="Block"/>
    <component id="emailLink" type="DirectLink">
    <binding name="listener" value="listener:onShowDetails"/>
    <binding name="parameters"
value="components.table.tableRow.getUserDetails('EMAIL')"/>
</component>

<component id="emailLinkDisplay" type="Insert">
    <binding name="value"
value="components.table.tableRow.getUserDetails('EMAIL')"/>
</component>

Note that getUserDetails() is my own function that a User object
posesses.  It just provides a way to look up details stored in a Map
object.  I'm using the db column names as the keys for the data.

Now my html looks like this:

<table border="1" jwcid="table">
<tr><th>id</th><th>email</th></tr>
<tr><td>1</td>
      <td jwcid="data1ColumnValue">
         <a href="" jwcid="emailLink">
             <span jwcid="emailLinkDisplay">email@address.com</span>
         </a>
      </td>
</tr>
</table>


Back in the page Class, you'll need a listener and the page you want to return:

@InjectPage("ShowDetails")
public abstract ShowDetails getUserDetailsPage();

public ShowUserDetails onShowDetails(String email) {
   System.out.println("Showing details for " + email);
   getUserDetailsPage().setViewUserWithEmail(email);
   return getUserDetailsPage();
}



Hope this helps.

Dan

On 10/31/06, ra <ry...@gazeta.pl> wrote:
>
> I'd like display links in a table, but ... column names are unknown at the
> development time
>
> I'm new to tapestry and don't what is the best solution.
> What I found is I can override method getValueRender in i.e.
> SimpleTableRenderer and return somehow PageLink instance but it's abstract
> class and have no idea how to do it
> --
> View this message in context: http://www.nabble.com/links-in-a-table-tf2548557.html#a7103183
> 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