Hi,
I have a page similar to the Search Table Pattern example
(http://click.avoka.com/click-examples/table/search-table.htm).
However, my search is more complex than in the example since you can add and
remove filters to narrow-down your search.
To make this work I must save an object that contains the active filters for
the search.
With statefull pages this worked automagically, since my object was a field of
the class and so was saved automatically.
In click 2.3 stateful pages are deprecated, so what is the best way to achieve
the same result?
As of now i have solved this issue by creating a fake control to hold my
object, that is persisted as other stateful controls:
public class FakeControl<T extends Serializable> implements Stateful {
private String name;
private T object;
public FakeControl(String name) {
this.name = name;
}
@Override
public Object getState() {
return object;
}
@SuppressWarnings("unchecked")
@Override
public void setState(Object state) {
this.object = (T) state;
}
public T getObject() {
return object;
}
public void setObject(T object) {
this.object = object;
}
public void removeState(Context context) {
ClickUtils.removeState(this, getName(), context);
}
public void restoreState(Context context) {
ClickUtils.restoreState(this, getName(), context);
}
public void saveState(Context context) {
ClickUtils.saveState(this, getName(), context);
}
public String getName() {
return name;
}
}
--
Lorenzo