Igor Vaynberg wrote:

Ok that approach is clear. Although it would also be nice just to have
an API call for just accessing the items shown on the page.

in wicket we use models to glue components to properties just so we dont have to go through components and see their values. in this example the components drop off their selection in a set for you so you can just traverse the set.
Aha, but I solved a problem with a back button yesterday which was caused by the model (that I saved as a private instance variable of  the page) getting out of sync with the actual model. The problem was that wicket components only call getters and setters on the model, but they cannot manage associations. In my case, I had a one to many relation in my model which was manipulated by the user (adding and removing items). In this case, just accessing the model from my private instance variable for the final save action on form submission gave the wrong result, even though the model as seen by the components on the page was correct (it was a copy of an old version including the relations).

So what I learned from this is that the page objects themselves are not versioned, only the component models are. In other words, saving a model as a private instance variable can cause problems if the model has more operations than just getters and setters.

In this particular case I am wondering about back button support for the selections instance variable. Here, if a user goes back to the previous version of the page and submits it, the selections instance variable is not updated to reflect the current version, even though the checkbox models are. The problem is that the selections instance variable is not retrieved from a model. If it would be part of a model and we would retrieve the selections through a component model then it would be ok.

Is there a simple way to put the selections in a model of some dummy component just to get back button support? Thinking about this, I think it would also solve my previous problem with the back button. For instance:

   VersionedObject<Set> selections; // private instance variable

// pseudo code
class VersionedObject<T extends Serializable> extends Component {
     VersionedObject(String aId, T aObject) {
         super(aId, new Model(aObject));
       
    }

    T get() {
        return (T) getModel().getObject(null);
    }
}

In this way, I can store any type of object as private instance variable and make sure that its properly versioned no matter what.

Cheers
  Erik

what you want is already there, see MarkupContainer.visitChildren() - but in order for this to work you will need to know what entity the checkbox is tied to. this is much less elegant imho because the likely scenario is that you will build the set yourself by visiting these components anyways.

>
> then after the form submit read the selected set for selected ids. if
> you have paging you need to write your own navigator that uses
> submitlink instead of link....or use an ajax checkbox
I don't understand this why does this have anything to do with paging?

checkboxes are form components in html - in order for you to get their value on serverside the form has to be submitted. the paging navigator by default uses regular anchor links, when pressed they will not submit the form and so you will lose your selection from that page.

-Igor



------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to