You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by SWC <ma...@crissman.net> on 2003/09/25 18:23:20 UTC

Foreach binding/rewind help?

I have a list of files that I am trying to allow a user to
download, or, if the file is a folder, drill down into.  My
page has a collection of files, and I use a foreach
statement, with source being files, and the value being
file.  With some minor difficulty, I was able to get the
download functionality implemented correctly by overriding
the asset service (thanks Harish!).

I am currently having trouble with getting the drill down
functionality to work the way I want it to.  I can get
everything to work if I use an ActionLink, but I would like
to use an image, and thus was trying to get it to work using
an ImageSubmit.  I apparently do not understand the rewind
cycle or something, because I was under the impression that
when the form's listener got called, the value binding of
the foreach statement would be set to the appropriate value.
This seems to be true if I use the actionlink, but not if I
use a form in my foreach.  Can someone help straighten me
out?

Here is some code to make things more clear:

---------------
Main.java

...
// With appropriate get/setters ommitted
private ArrayList files;
private File file;

public void directoryDown(IRequestCycle cycle)
{
     MyVisit theVisit = ((MyVisit)getVisit());
     theVisit.getDirectoryManager().moveDownTo(
file.getName() );
}
...

----------------
Main.page
...
   <component id="viewedFiles" type="Foreach" >
     <binding name="source" expression="files"/>
     <binding name="value" expression="file"/>
   </component>
...


-----------------
Main.html

...
<table width="80%" align="center">
   <tr jwcid="viewedFiles" element="tr">
     <td>
       <a jwcid="@Insert" 
value="ognl:files[components.viewedFiles.index].name"/>
     </td>
     <td>
       <div jwcid="@Conditional" condition="ognl:
file.isDirectory()" >
         <form jwcid="@Form">
           <a jwcid="@LinkSubmit"
listener="ognl:listeners.directoryDown">Look Inside</a>
         </form>
       </div>
     </td>
   </tr>
</table>

As I said, if I replace the form with an actionlink, file
contains the correct value, and everything works fine, but
when I use the form and any type of submit, I always get the
last item in the list, regardless of which I click on.
Which leads me to believe that it doesnt get reset at the
same time as everything else, or something?

I've also tried adding a selectedFile member variable to the
page, and setting that with the submit via selected binding,
and setting the tag = file.name, but that also did not work.

Thanks for your help,

Spencer


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