You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Neil Clayton <ne...@cloudnine.net.nz> on 2003/06/15 15:01:06 UTC

Table model "problem"

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well, it might not be problem. More likely, I just don't know the way around 
it :-)

I'm building a simply link farm. Why? Cos I Can :-) (I did the same thing with 
Millstone a while back, so I'm using this as a comparison - since it's going 
to have exactly the same functionality)

A user in the farm (moo) has some number of link containers. Each container 
holds zero or more links. Simple so far.

I thought that it would therefore be possible to do the followin:

<foreach jwcid="usersContainers">
	<table width="85%" border="0">
		<tr>
			<th bgcolor="#eeeee" colspan="3">
				<font size="+2"><span jwcid="@InsertText" 
value="ognl:components.usersContainers.value.description"/></font>
			</th>
		</tr>
		<span jwcid="tableView">
			<tr jwcid="tableRows">
				<td jwcid="tableValues"/>
			</tr>
		</span>
	</table>
</foreach>

I'm using a custom table model, which is created as follows:
		Foreach linkContainers = (Foreach) getComponent("usersContainers");
		LinkContainer container = (LinkContainer) linkContainers.getValue();
		return new LinkContainerTableModel(container);

the idea being that I create a new model for the particular container being 
iterated over.  However; I'm finding that the Table attempts to use the model 
in it's fireBeginRender() handler - but the model cannot be instantiated 
because it is illegal for me to access the value property of the Foreach 
"before rendering". 

I tried using a PageRenderListener on the page itself, so that I knew when 
rendering was occuring (when not, I returned the same table model, but with 
an empty LinkComponent) - however the Table never re-requests the table model 
- - so I never end up giving it the right data to display.

Any ideas on how to get around this? 

- -- 
Neil Clayton
Developer
ThoughtWorks (http://www.thoughtworks.com)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+7G4VLXcfQF3yrNoRAvfyAJ4m3GxfD7u8yD1daTozX1iGUtoaJACcDfJB
xRS5KkZkWvt+vxyzoLzbxt8=
=/46o
-----END PGP SIGNATURE-----


Re: Table model "problem"

Posted by Neil Clayton <ne...@cloudnine.net.nz>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well, Ive got around the problem by passing in 'this' to the table model and 
then having it perform lazy construction of itself...

is there any other way to do this? I guess it's not baaaad bad bad, but I 
wonder if I have missed some simpler path...

Neil

On Sunday 15 Jun 2003 2:01 pm, Neil Clayton wrote:
> Well, it might not be problem. More likely, I just don't know the way
> around it :-)
>
> I'm building a simply link farm. Why? Cos I Can :-) (I did the same thing
> with Millstone a while back, so I'm using this as a comparison - since it's
> going to have exactly the same functionality)
>
> A user in the farm (moo) has some number of link containers. Each container
> holds zero or more links. Simple so far.
>
> I thought that it would therefore be possible to do the followin:
>
> <foreach jwcid="usersContainers">
> 	<table width="85%" border="0">
> 		<tr>
> 			<th bgcolor="#eeeee" colspan="3">
> 				<font size="+2"><span jwcid="@InsertText"
> value="ognl:components.usersContainers.value.description"/></font>
> 			</th>
> 		</tr>
> 		<span jwcid="tableView">
> 			<tr jwcid="tableRows">
> 				<td jwcid="tableValues"/>
> 			</tr>
> 		</span>
> 	</table>
> </foreach>
>
> I'm using a custom table model, which is created as follows:
> 		Foreach linkContainers = (Foreach) getComponent("usersContainers");
> 		LinkContainer container = (LinkContainer) linkContainers.getValue();
> 		return new LinkContainerTableModel(container);
>
> the idea being that I create a new model for the particular container being
> iterated over.  However; I'm finding that the Table attempts to use the
> model in it's fireBeginRender() handler - but the model cannot be
> instantiated because it is illegal for me to access the value property of
> the Foreach "before rendering".
>
> I tried using a PageRenderListener on the page itself, so that I knew when
> rendering was occuring (when not, I returned the same table model, but with
> an empty LinkComponent) - however the Table never re-requests the table
> model - so I never end up giving it the right data to display.
>
> Any ideas on how to get around this?

- -- 
Neil Clayton
Developer
ThoughtWorks (http://www.thoughtworks.com)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+7IYuLXcfQF3yrNoRAnuIAKC5uSy9QHA7Xapw+2pPv/VMHYW0HwCdFMSs
O0N56PG0yAFXFJcoi06N/Cs=
=2Zx2
-----END PGP SIGNATURE-----


Re: Table model "problem"

Posted by Mindbridge <mi...@yahoo.com>.
Hi Neil,

I think the issue here is that you are using the table in a loop and in the
default configuration it is set up so that this would work.

The reason is that by default the component stores the table session state
in a single location -- a persistent page property and when you put it into
a loop, different table models interfere with each other (get stored in the
same place).

To resolve this, implement ITableSessionStoreManager and pass it to the
table -- it determines where to store the table session state. In your case
it is probably best to store it in sth like a map or an array in the Visit,
so that you have a different storage location for the state of each
iteration.

Once you implement that, you can deal with the other aspects of the
iteration -- create a new table model if there is nothing stored in the
visit yet, ignore the invocations if the loop hasn't started yet, etc.

Does this help?

Best regards,
-mb


----- Original Message ----- 
From: "Neil Clayton" <ne...@cloudnine.net.nz>
To: "Tapestry User User (Jakarta)" <ta...@jakarta.apache.org>
Sent: Sunday, June 15, 2003 4:01 PM
Subject: Table model "problem"


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well, it might not be problem. More likely, I just don't know the way around
it :-)

I'm building a simply link farm. Why? Cos I Can :-) (I did the same thing
with
Millstone a while back, so I'm using this as a comparison - since it's going
to have exactly the same functionality)

A user in the farm (moo) has some number of link containers. Each container
holds zero or more links. Simple so far.

I thought that it would therefore be possible to do the followin:

<foreach jwcid="usersContainers">
<table width="85%" border="0">
<tr>
<th bgcolor="#eeeee" colspan="3">
<font size="+2"><span jwcid="@InsertText"
value="ognl:components.usersContainers.value.description"/></font>
</th>
</tr>
<span jwcid="tableView">
<tr jwcid="tableRows">
<td jwcid="tableValues"/>
</tr>
</span>
</table>
</foreach>

I'm using a custom table model, which is created as follows:
Foreach linkContainers = (Foreach) getComponent("usersContainers");
LinkContainer container = (LinkContainer) linkContainers.getValue();
return new LinkContainerTableModel(container);

the idea being that I create a new model for the particular container being
iterated over.  However; I'm finding that the Table attempts to use the
model
in it's fireBeginRender() handler - but the model cannot be instantiated
because it is illegal for me to access the value property of the Foreach
"before rendering".

I tried using a PageRenderListener on the page itself, so that I knew when
rendering was occuring (when not, I returned the same table model, but with
an empty LinkComponent) - however the Table never re-requests the table
model
- - so I never end up giving it the right data to display.

Any ideas on how to get around this?

- -- 
Neil Clayton
Developer
ThoughtWorks (http://www.thoughtworks.com)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+7G4VLXcfQF3yrNoRAvfyAJ4m3GxfD7u8yD1daTozX1iGUtoaJACcDfJB
xRS5KkZkWvt+vxyzoLzbxt8=
=/46o
-----END PGP SIGNATURE-----


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