I haven't seen enough code to really understand what you are doing wrong. Storing your search criteria in the session is a reasonable approach. Don't store your search results in the session though, that would be a scalability nightmare...
Here is fully functioning code that accepts search parameters in an object on one page and transfers the object to another for rendering. ListPerson.tml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>List</title> </head> <body> <h1 t:type="if" test="filterPerson">Search Results: ${filterPerson?.name} ${filterPerson?.age}</h1> <h1 t:type="unless" test="filterPerson">All People:</h1> <table> <tr t:type="loop" source="people" value="person"> <td>${person.name}</td> <td>${person.age}</td> </tr> </table> <t:if test="filterPerson"><a href="#" t:type="eventLink" t:event="clearFilter">Clear Filter</a><br/></t:if> <a href="#" t:type="pageLink" t:page="person/search">Search</a> </body> ************* ListPerson.java package usr.joshcan.tapestry.pages.person; import org.apache.tapestry5.annotations.Persist; import org.apache.tapestry5.annotations.Property; import org.apache.tapestry5.ioc.annotations.Inject; import usr.joshcan.support.Person; import usr.joshcan.tapestry.services.PersonSource; import java.util.List; /** * User: joshcanfield * Date: Oct 6, 2009 */ public class ListPerson { @Property private List<Person> _people; @Property private Person _person; @Property @Persist private Person _filterPerson; @Inject private PersonSource _source; public void setFilter(Person person) { _filterPerson = person; } void setupRender() { if (_filterPerson != null) { _people = _source.find(_filterPerson); } else { _people = _source.find(); } } void onClearFilter() { _filterPerson = null; } } ************** SearchPerson.tml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Search People</title> </head> <body> <t:form t:id="searchForm"> <t:label for="name">Name</t:label> <t:textfield t:id="name"/> <br/> <t:label for="age">age</t:label> <t:textfield t:id="age"/> <br/> <t:submit value="search"/> </t:form> </body> </html> **************** SearchPerson.java package usr.joshcan.tapestry.pages.person; import org.apache.tapestry5.annotations.InjectPage; import org.apache.tapestry5.annotations.Property; import usr.joshcan.support.Person; /** * User: joshcanfield * Date: Oct 6, 2009 */ public class SearchPerson { @Property private String _name; @Property private Integer _age; @InjectPage private ListPerson _listPerson; ListPerson onSuccessFromSearchForm() { _listPerson.setFilter(new Person(_name, _age)); return _listPerson; } } **** for completeness PersonSource.java (bound as a service in AppModule) package usr.joshcan.tapestry.services; import usr.joshcan.support.Person; import java.util.ArrayList; import java.util.List; /** * User: joshcanfield * Date: Oct 6, 2009 */ public class PersonSource { private static final List<Person> _source = new ArrayList<Person>(); { _source.add(new Person("John", 24)); _source.add(new Person("Jane", 52)); _source.add(new Person("Fred", 27)); _source.add(new Person("Bill", 95)); } public List<Person> find() { return _source; } public List<Person> find(Person filter) { List<Person> filtered = new ArrayList<Person>(); for (Person p : _source) { if (filter.getName() != null) { if (p.getName().contains(filter.getName())) { filtered.add(p); } } if (filter.getAge() != null) { if (p.getAge().equals(filter.getAge())) { filtered.add(p); } } } return filtered; } } Josh On Tue, Oct 6, 2009 at 2:48 AM, 976 <amsc...@gmail.com> wrote: > > I'm totally new to Tapestry (2 days playing with it), but I'm stuck with > quite simple problem;( (At least I guess so). > > What I want to to is to create 4 pages for Client entity: > - list (list all clients or ones from search result) > - edit > - add > - find > > Didn't have any problems with first three, but having problems with last > one. > > I've created SearchClient, AddClient, ListClients pages (java+tml). > > What I want to do is to input search criteria on SearchClient and list the > results in ListClients and I don't really now how to pass data between > pages. > First of all AddClient and SearchClient have > > @IncludePage > private ListClients listClients; > and AddClient has: > public Object onSuccess() { > clientService.addClient(client); > return listClients; > } > > which works just fine. > > In SearchClient I firstly tried to retrieve data onSuccess and pass the > collection to onActivate method of ListClients but passing it didn't work;( > Can't get the idea of what happens there, but what I wanted to do show > collection passed from SearchClient if it existed and list all if it didnt. > And always came up with list of all clients. > > Later I tried putting in SearchClient: > Object onSuccess() { > listClients.setClient(client); > return listClients; > } > > Still - this client was always null in the following: > public void onActivate(){ > if(client==null){ > clients = clientService.getClients(); > }else{ > clients = clientService.getClientByCriteria(client); > } > } > > After doing some search I tried doing @Persist on client property in, but it > turned out to ALWAYS be set which wasn't also good as couldn't list all > clients - always one from criteria. > > So I tried @Persist("flash") - and the behavior of this one I can't even > describe;) > > I really tried to google the solution for search screen + results screen but > with no luck. > > Is this onActivate() approach good at all or should I use some other way of > passing data between pages? > As I said - what I want to accomplish is to list clients from search screen > and if this criteria was not created at all (list all clients from dirrenent > link) I want to list them all. > > > Will be very grateful for any help. > bwt. I made sure to look over all info on tapestry main page;( + other > googled examples/tutorials > > Thanks, > Adam > > -- > View this message in context: > http://www.nabble.com/passing-values-between-pages-%28search--%3E-result%29-tp25765698p25765698.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- -- TheDailyTube.com. Sign up and get the best new videos on the internet delivered fresh to your inbox. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org