Thanks Bob for the clarification.
If I understand correctly the search table patter does the following things:
1. when the search button is clicked, the form is saved to session.
2. A new page is created and load the saved form from session and populate
the table.
3. when a page link is clicked, form is restored again from session(saved in
step 1), and render the next page.

I removed my form save method from link control listner, but still have same
problem.
I think my problem is that the form saves fine when click the form post
button, but seems cleared on page link clicked(in step three).

This is the my first attempt to migrate from stateful page to stateful
control, and the table is inherited from a parent class. probably some thing
there preventing it working properly, i will check the parent class for some
hint.

Thanks again for you response.

Yinghai

On Thu, Mar 10, 2011 at 6:48 AM, Bob Schellink <[email protected]> wrote:

> Hi,
>
> addControl is for adding controls while addModel is for adding non controls
> such as domain objects.
>
> A table link is a normal HTML link and performs a get request not a form
> post. So you cannot save
> form state from the table control as no Form data is available.
>
> regards
>
> Bob
>
> On 2011/03/09 22:06 PM, Yinghai Zhao wrote:
> > I'm trying to create a page similar to the searchable table example.
> >
> > I have a form which have a fieldset and a submit button, the fieldset
> includes two fields,a
> > CheckList and a Select.
> > the form's state will be saved when the submit button is clicked, as well
> as in a
> > tables ActionListener(when paging and sorting).
> > And on init, the page will restore the saved fields from the form and
> retrieve database record based
> > on the field values.
> >
> > I found some interesting behaviors when saving the form's state.
> >
> > 1.if the form is declared with @Bindable, the submit botton will save the
> form's value and populate
> > the table. if form is added using addModel instead of @Bindable. field
> value will be cleared after
> > button click and the table will be empty.
> >
> > 2. table paging will not save the state of the form, if i try to go to
> the next page. the form will
> > be cleared and table showing no records.
> > I have another page does similar things, the only different is that that
> form only includes a text
> > field, a select and submit button without fieldset.
> >
> > Currently my work around is setting the page back to stateful again,
> seems working fine.
> >
> >
> > here are some relevant code snippet in the page.
> >
> > on init method:
> >
> >     public void onInit()
> >     {
> >     super.onInit();
> >         Context context = getContext();
> >
> >         // Restore form and table state from the session
> >         form.restoreState(context);
> >         table.restoreState(context);
> >
> >         table.getControlLink().setActionListener(new ActionListener() {
> >             public boolean onAction(Control source) {
> >             form.saveState(getContext());
> >                 table.saveState(getContext());
> >
> >                 return true;
> >             }
> >         });
> >
> > buttons listener method:
> >
> >     public boolean onSubmitClicked(){
> >         try{
> >             form.saveState(getContext());
> >             return true;
> >         }catch(Exception e)
> >         {
> >             msg = " Failed due to: " + e.toString();
> >             getContext().setFlashAttribute("flash", msg);
> >         }
> >         return false;
> >     }
> >
>
>

Reply via email to