Hi There, I'm happy to say I'm slowly coming to grips with the Tapestry way of thinking, though I'm at a stage where I'm struggling with trying to make a component stateful.
The question is really: How do I persist a search result so that the user can scroll
through it.
Given I have a component called VisualSearch. This is a visual component that has an
text box for the keywords and submit button. When I click 'Go' I do the search and the
resulting itemList is a property of this component.
ie
================
public class VisualSearch extends BaseComponent {
private String keywords;
private List itemList;
// no code for brevity
public String getKeywords() { .. }
public void setKeywords(String s) { .. }
public List getItemList() {..}
public void setItemList(List l) {...}
public void formSubmit(IRequestCycle cycle){
// do search and set itemList
}
======================
That's all good and well. I then have another visual component that displays an
itemList, ie it does a foreach loop and formats output in nice html. This will most
likely be placed on a different page.
======================
public class SearchResult extends BaseComponent { private List itemList;
private Item item;
private int currPageNumber; // current page of scrollset user is looking at.
private int maxPageNumber; // Maximum page number
private int itemsPerPage; // # of items per page. (determines above two params)
// All getter/setter methods here.
}
==========================================
What's the best way to do this?
Is it by making the component persistent or is using the Visit object the only way?
ie, by putting the itemList intot he visit object?
I get the feeling that's what I need to do but I would be extremely thankful if people
could describe how to get components persisting components like this, or instead tell
me I'm way off the garden path.. :-/
Hope this makes a bit of sense.
Thanks for reading my post.
Regards,
Patrick.
ps. Anyone have a persistent component they could possibly share with the forum? It
would help a lot of newbies.
|
Sorry for my clerical error.
In component java code, fireObservedChange() is
invoked if recorderLocked is *NOT* true, otherwise this mothod is not
invoked.
When I click the page for the first time, an
exception that indicates some states were not been persistented is
thrown.
What's wrong with my code?
| ||||||||
