When you click on a DirectLink, the specified listener method will be called (and without the page being rewinded.) That is why your getCurrentProject() is returning null. A fix is to pass the currentProject (or its key) to the DirectLink component, so that when a DirectLink is clicked, the corresponding project (key) is available in the listener method.
(Doc on DireclLink: http://jakarta.apache.org/tapestry/tapestry/ComponentReference/DirectLink.html ) You might like to try something like this : <span jwcid="@For" source="ognl:activeProjects" value="ognl:currentProject"> <a jwcid="@DirectLink" listener="listener:selectProject" href="HomePage.html" parameters="ognl:(key of currentProject)"> <span jwcid="@Insert" value="ognl:currentProject.name">ScannerInterface</span></a> </span> In your .java file : // assuming the currentProject has a key of type int public void selectProject(IRequestCycle cycle, int projectKey){ Project selectedProject = (retreive project with projectKey); //Carry on what you were doing before } Shing --- Tim Sawyer <[EMAIL PROTECTED]> wrote: > I'm having a problem in a for loop and I think I'm > misunderstanding how this > is supposed to work. I'm using Tapestry4 beta 13. > > I have a component for rendering a list of projects. > The html does this: > > <span jwcid="@For" source="ognl:activeProjects" > value="ognl:currentProject"> > <a jwcid="@DirectLink" > listener="listener:selectProject" > href="HomePage.html"><span jwcid="@Insert" > value="ognl:currentProject.name">ScannerInterface</span></a> > </span> > > The java code returns a List of Project instances in > getActiveProjects(). The > list of projects is shown on the page correctly. > > In my listener method, I do this: > > PropertiesService lPropertyService = > this.getPropertiesService(); > lPropertyService.storeUserProperty(this.getToken(), > "default.project", > this.getCurrentProject().getId()); > > which always fails as getCurrentProject() is > returning null. > > I have abstract getter and setter methods for > currentProject in the component: > > public abstract void setCurrentProject(Project > pProject); > public abstract Project getCurrentProject(); > > Has anyone got any ideas why it's always null? I > thought I could use it to > identify the row that was selected. > > ta, > > Tim. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > Home page : http://uk.geocities.com/matmsh/index.html ___________________________________________________________ NEW Yahoo! Cars - sell your car and browse thousands of new and used cars online! http://uk.cars.yahoo.com/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
