You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Raymond <pp...@hotmail.com> on 2004/12/19 09:13:28 UTC

2 Contrib Table questions

Hi Tapestry developers and users,

Two questions on the Contrib Table component:

1.I know I can control the styles of rows and columns with parameters. But 
how do you make the table rows appear in Alternating colors/styles? e.g row 
1, 3, 5,... with bgcolor=blue  and row 2, 4, 6,... with bgcolor=red?

2. How to make the table State-less? For some reason I need to initiate 
session for every visitor to my site no matter the visitor has logged in or 
not. And there's a free page (just BasePage) of Table-based info for every 
visitor to see. But I found when clicking the column heading links after 
session-timeout would cause a StaleLinkException. How to avoid that?

Thanks a lot.
Raymond 

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


Re: 2 Contrib Table questions

Posted by Mind Bridge <mi...@yahoo.com>.
Hi,

> 1.I know I can control the styles of rows and columns with parameters. But
> how do you make the table rows appear in Alternating colors/styles? e.g
row
> 1, 3, 5,... with bgcolor=blue  and row 2, 4, 6,... with bgcolor=red?

Place in your specification file (.page or .jwc) the following:

<bean name="tableClass" class="org.apache.tapestry.bean.EvenOdd"
lifecycle="request"/>

then add the following to your Table:

rowsClass="ognl:beans.tableClass.next"

and then add the following to your CSS (in your CSS file or in the head of
the HTML page):

even { color: red; }
odd { color: blue; }

That should do it.

> 2. How to make the table State-less? For some reason I need to initiate
> session for every visitor to my site no matter the visitor has logged in
or
> not. And there's a free page (just BasePage) of Table-based info for every
> visitor to see. But I found when clicking the column heading links after
> session-timeout would cause a StaleLinkException. How to avoid that?

Normally, the Table stores its state in a persistent property and tries to
get it from there when rerendered. Hence the StaleLinkException when the
session timeouts -- it is thrown when the framework finds out that the
property is no longer there. 3.1 would allow properties to be stored in the
URL as well, which means that it would be possible to make the table
stateless by simply flicking a flag.

At the moment, however, there is another way you can make Table not throw a
StaleLinkException. The 'tableSessionStoreManager' parameter allows you to
specify exactly how to store the Table session information. Modifying that
allows you to make the component insensitive to session timeouts.

For example, in the Java file of your page add something like the following:

private final static ITableSessionStoreManager SESSION_STORE_MGR =
   new ITableSessionStoreManager() {
      public Serializable loadState(IRequestCycle objCycle) {
         Object visit = objCycle.getEngine().getVisit(); // returns null if
session expired
         if (visit == null) return null; // i.e. there is no session or it
has expired

         Map myProperties = (Map) visit; // or something like that -- may
depend on your application's visit
         return (Serializable) myProperties.get(TABLE_STORE_KEY);
      }

      public void saveState(IRequestCycle objCycle, Serializable objState) {
         Object visit = objCycle.getEngine().getVisit(objCycle);
         Map myProperties = (Map) visit;
         myProperties.put(TABLE_STORE_KEY, objState);
      }
   };

public getSessionStoreManager() {
   return SESSION_STORE_MGR;
}

Finally add the following property to your Table component:
tableSessionStoreManager='ognl:sessionStoreManager';


I hope this helps,
-mb

----- Original Message ----- 
From: "Raymond" <pp...@hotmail.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Sunday, December 19, 2004 10:13 AM
Subject: 2 Contrib Table questions


> Hi Tapestry developers and users,
>
> Two questions on the Contrib Table component:
>
> 1.I know I can control the styles of rows and columns with parameters. But
> how do you make the table rows appear in Alternating colors/styles? e.g
row
> 1, 3, 5,... with bgcolor=blue  and row 2, 4, 6,... with bgcolor=red?
>
> 2. How to make the table State-less? For some reason I need to initiate
> session for every visitor to my site no matter the visitor has logged in
or
> not. And there's a free page (just BasePage) of Table-based info for every
> visitor to see. But I found when clicking the column heading links after
> session-timeout would cause a StaleLinkException. How to avoid that?
>
> Thanks a lot.
> Raymond
>
> ---------------------------------------------------------------------
> 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


Re: 2 Contrib Table questions

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Dec 19, 2004, at 3:13 AM, Raymond wrote:
> 1.I know I can control the styles of rows and columns with parameters. 
> But how do you make the table rows appear in Alternating 
> colors/styles? e.g row 1, 3, 5,... with bgcolor=blue  and row 2, 4, 
> 6,... with bgcolor=red?

Register and EvenOdd bean in your .page file:

<page-specification class="lia.tapestry.History">
   <property-specification name="row"/>

   <bean name="evenOdd" class="org.apache.tapestry.bean.EvenOdd"/>
</page-specification>


And then use it with the Table component:

   <table jwcid="@contrib:Table"
          source="ognl:visit.historyData"
          columns="word,count"
          row="ognl:row"
          rowsClass="ognl:beans.evenOdd.next + 'Row'">
     <tr jwcid="wordColumnValue@Block">
       <a jwcid="@ExternalLink" page="Home" parameters="ognl:row.word">
         <span jwcid="@Insert" value="ognl:row.word"/>
       </a>
     </tr>
   </table>

I have css items called "evenRow" and "oddRow".  Use CSS classes 
instead of bgcolor directly on <tr>.

	Erik


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