I've got a couple of questions regarding models and state between
pages when using AbstractDetachableModel.

I want to do a simple CRUD of en entity called Circulars.

I begin with a ListCircularsPage wich uses a DefaultDataTable with a
CircularProvider I've written. The provider uses an
CircularDetachableModel wich extends AbstractDetachableModel.
At the end of the table I display an "Add"-link that shows an
EditCircularPage, the code looks like this:

Form form = new Form("createForm");
   form.add((new Button("createButton") {
      protected void onSubmit() {
         setResponsePage(new EditCircularPage(getPage(), 0));
      }
   }));
add(form);

So, when the user presses the createbutton a new EditCircularPage is created.
The 0 represents the id of the Circular to edit, if it's a 0 I create a new one.
I send the current page to the EditCircularPage to have a page to
return to when done.
In the EditCircularPage the onSubmit-handler looks like this:

add(new Button("save") {
                protected void onSubmit() {
                    Circular circular = (Circular) getForm().getModelObject();
                    getCircularDao().makePersistent(circular);
                    System.out.println("Returning to: " +
EditCircularPage.this.backPage.getId());
                    setResponsePage(EditCircularPage.this.backPage);
                }
            });

This setup works great! The list is updated with the new entities when
I add them from the EditCircularPage.

The problem is that when I introduce an intermediary page ShowCircular
it never gets updated after en edit.The idea is that when a user
selects a Circular i the datatable the ShowCircularPage is called. I
added a Panel to the DefaultDataTable with a link:

public ActionsPanel(String id, final Circular circular) {
            super(id);
            add(new Link("showLink") {
                public void onClick() {
                   setResponsePage(new ShowCircularPage(getPage(),
circular.getId()));
                }
            });
        }

The panel works fine, the ShowCircularPage is displayed and returning
to the list works fine as well. But, when I move from the
ShowCircularPage to the EditCircularPage in the same manner as from
ListCircularsPage to EditCircular, the ShowCircularPage is not updated
with the edited Circular entity.
However if you move back to the list, it reflects the changes to the
underlying model.

If I look at the generated urls I can see that going from:
circular (displays the list)
"create" ->
circular?path=1 (displays edit view)
"save" ->
circular?path=0&version=1 (displays the updated list)

If I start over and do:
circular (displays the list)
"edit" ->
circular?path=1 (displays show view)
"edit" ->
circular?path=2 (displays edit view)
"save" ->
circular?path=1 (displays the same show view as before and NOT updated)

I noticed that the &version=1 is missing on the last url...

What completely throws me is that the call to the EditCircularPage is
the same in both instances.

I thought that every time a page is called, the onBeginRequest  and
onEndRequest is called, but when I added a simple debug panel to my
page it says that the onEndRequest is called 1 more time than
onBeginRequest? Should those two add up?

The CircularDetachableModel attach and detach methods doesn't get 
called when going from the edit page to the show page. I've added the
model to both the page and the components (a panel) on the page to no
avail.

Am I going about this the wrong way?

Any suggestions? :)

Regards Mats


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to