You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jim Menard <ji...@io.com> on 2003/12/19 23:13:17 UTC
Nested Foreach
I've been struggling with nested Foreach components all day. I have a
list of albums with cover photos and captions, and want to display them
in a grid, across as well as down.
I am trying nested Foreach components, like this:
LatestAlbumTable.html:
<table width="100%">
<form jwcid="viewAlbumForm">
<span jwcid="@Foreach" source="ognl:albumRows" value="ognl:row">
<tr>
<span jwcid="@Foreach" source="ognl:row" value="ognl:albumView"
element="td">
<span jwcid="albumNotNull">
<a jwcid="albumLink1"><span
jwcid="albumImage"/>[Image]</a>
<br>
<a jwcid="albumLink2"><span jwcid="albumName">Album
Name</span></a>
</span>
<span jwcid="albumNull"> </span>
</span>
</tr>
</span>
</form>
</table>
LatestAlbumTable.albumRows returns LatestAlbumRow objects, and
LatestAlbumRow.albumView returns AlbumView objects.
I am having problems with how to reference the row and albumView
objects, both here in the HTML and in the components contained in the
inner loop. Should "ognl:albumView" be "ognl:row.albumView"? Should the
inner components refer to "row.albumView"? When I do all this, I see
the error message
========================
Unable to update expression 'row.albumView' for
com.preclick.photowiki.tapestry.components.LatestAlbumTable$Enhance_0@4c
0017[Home/latestAlbumTable] to
com.preclick.photowiki.tapestry.components.LatestAlbumRow@56d485[null].
binding: ExpressionBinding[Home/latestAlbumTable row.albumView]
location: classpath:/tapestry/components/LatestAlbumTable.html, line 5
ognl.MethodFailedException
Method "setAlbumView" failed for object
com.preclick.photowiki.tapestry.components.LatestAlbumRow@56d485[null]
java.lang.NoSuchMethodException
setAlbumView(com.preclick.photowiki.tapestry.components.LatestAlbumRow)
========================
But LatestAlbumRow *does* have a method named setAlbumView. Wait a
minute! It takes an albumView, not an albumRow. Why is the inner
foreach trying to pass in a row object instead of an albumView object?
Both the returned row object and the row's returned albumView objects
are subclasses of BaseComponent. That is necessary, isn't it?
By the way, albumLink1 and albumLink2 are exactly the same thing. I
naively tried naming them the same thing, but saw an error message
about having two things with the same name. That's not possible?
As always, thank you for your help.
Jim
--
Jim Menard, jimm@io.com, http://www.io.com/~jimm/
As a math major, I don't have to be able to add -- I just have to be
able
to PROVE that I can add.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Nested Foreach
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Friday, December 19, 2003, at 05:39 PM, Jim Menard wrote:
> What does jwcid="rows@Foreach" mean? Is that the same as
> <span jwcid"@Foreach" value="rows">
No... it is the same as this:
.html:
<span jwcid="rows">...</span>
.page:
<component id="rows" type="@Foreach">...</component>
It is just giving it a name, which can be referred to elsewhere.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Nested Foreach
Posted by Jim Menard <ji...@io.com>.
Harish,
On Dec 19, 2003, at 5:33 PM, Harish Krishnaswamy wrote:
> Your LatestAlbumTable.java is the context class for both your Foreach
> components so you should have the both the setRow(LatestAlbumRow) and
> setAlbumView(AlbumView) in LatestAlbumTable.java.
Thanks. I'll try that, because it seems simpler.
> There is another way of getting to the value of the current iteration,
> try this...
>
> LatestAlbumTable.html:
>
> <table width="100%">
> <form jwcid="viewAlbumForm">
> <span jwcid="rows@Foreach" source="ognl:albumRows">
What does jwcid="rows@Foreach" mean? Is that the same as
<span jwcid"@Foreach" value="rows">
?
> <tr>
> <span jwcid="cols@Foreach" source="ognl:components.rows.value"
> <!-- Returns AlbumRow --> element="td">
> <span jwcid="@Insert"
> value="ognl:components.cols.value..." /> <!-- Returns AlbumView -->
> </span>
> </tr>
> </span>
> </form>
> </table>
Jim
--
Jim Menard, jimm@io.com, http://www.io.com/~jimm/
Dash dash space newline
Four-line witty quotation
Perfect message end
-- Donald Welsh in rec.humor.oracle.d
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Nested Foreach
Posted by Harish Krishnaswamy <hk...@comcast.net>.
Your LatestAlbumTable.java is the context class for both your Foreach components so you should have
the both the setRow(LatestAlbumRow) and setAlbumView(AlbumView) in LatestAlbumTable.java.
There is another way of getting to the value of the current iteration, try this...
LatestAlbumTable.html:
<table width="100%">
<form jwcid="viewAlbumForm">
<span jwcid="rows@Foreach" source="ognl:albumRows">
<tr>
<span jwcid="cols@Foreach" source="ognl:components.rows.value" <!-- Returns AlbumRow -->
element="td">
<span jwcid="@Insert" value="ognl:components.cols.value..." /> <!-- Returns AlbumView -->
</span>
</tr>
</span>
</form>
</table>
-Harish
Jim Menard wrote:
> I've been struggling with nested Foreach components all day. I have a
> list of albums with cover photos and captions, and want to display them
> in a grid, across as well as down.
>
> I am trying nested Foreach components, like this:
>
> LatestAlbumTable.html:
>
> <table width="100%">
> <form jwcid="viewAlbumForm">
> <span jwcid="@Foreach" source="ognl:albumRows" value="ognl:row">
> <tr>
> <span jwcid="@Foreach" source="ognl:row" value="ognl:albumView"
> element="td">
> <span jwcid="albumNotNull">
> <a jwcid="albumLink1"><span
> jwcid="albumImage"/>[Image]</a>
> <br>
> <a jwcid="albumLink2"><span jwcid="albumName">Album
> Name</span></a>
> </span>
> <span jwcid="albumNull"> </span>
> </span>
> </tr>
> </span>
> </form>
> </table>
>
> LatestAlbumTable.albumRows returns LatestAlbumRow objects, and
> LatestAlbumRow.albumView returns AlbumView objects.
>
> I am having problems with how to reference the row and albumView
> objects, both here in the HTML and in the components contained in the
> inner loop. Should "ognl:albumView" be "ognl:row.albumView"? Should the
> inner components refer to "row.albumView"? When I do all this, I see
> the error message
>
> ========================
> Unable to update expression 'row.albumView' for
> com.preclick.photowiki.tapestry.components.LatestAlbumTable$Enhance_0@4c
> 0017[Home/latestAlbumTable] to
> com.preclick.photowiki.tapestry.components.LatestAlbumRow@56d485[null].
>
> binding: ExpressionBinding[Home/latestAlbumTable row.albumView]
>
> location: classpath:/tapestry/components/LatestAlbumTable.html, line 5
>
> ognl.MethodFailedException
>
> Method "setAlbumView" failed for object
> com.preclick.photowiki.tapestry.components.LatestAlbumRow@56d485[null]
>
>
> java.lang.NoSuchMethodException
> setAlbumView(com.preclick.photowiki.tapestry.components.LatestAlbumRow)
> ========================
>
> But LatestAlbumRow *does* have a method named setAlbumView. Wait a
> minute! It takes an albumView, not an albumRow. Why is the inner
> foreach trying to pass in a row object instead of an albumView object?
>
> Both the returned row object and the row's returned albumView objects
> are subclasses of BaseComponent. That is necessary, isn't it?
>
> By the way, albumLink1 and albumLink2 are exactly the same thing. I
> naively tried naming them the same thing, but saw an error message
> about having two things with the same name. That's not possible?
>
> As always, thank you for your help.
>
> Jim
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org