Hi there,

I've a LoadableDetachableModel which works pretty much like all LDM
examples. There is an overwritten load method that returns an object
based on an id member which is set via the constructor.
In addition there is a DropDownChoice added to the WebPage (no form is
used). The choices object is a model which returns a list of Strings.

Each string of that list represents an id which is necessary to retrieve
an object.
And here the problem start. I'd like to use the LDM to return an object
based on the selected id of the DDC.

Beside the component id and the choices list (IModel), I'd like to
utilize the third mode parameter (IModel). From my understanding, model
allows to preselect an item in the DCC. But as well the item selected by
the user is that written back into Model. Very convenient!
But in my case, since choices is based on a list of Strings, only a
String is written to the model.

So, I don't know how to connect the new value of my DDC model with the
LDM that I use.

As well, I overwrite the onSelectionChanged method of the DDC. Within
this method I try to assign a new LDM with the newSelection value as a
constructor argument to a global LDM model, but the LDM id member value
never changes:
public class HomePage extends WebPage{
  private MyLDM myLDM = new MyLDM("123");
...
  public HomePage(final PageParameters parameters) {
...
    add(new DropDownChoice(
            "idSelection",
            [a model ... but how to use it to update the LDM id],
            new PropertyModel(Cases, "allCases")) {
      @Override
      protected void onSelectionChanged(Object newSelection) {
        myLDM= new MyLDM((String) newSelection);
      }
...

I'm very much lost. Maybe my approach is simply wrong. I have the gut
feeling that it is easy to solve, but as a beginner I got lost in the
model jungle. Get me out there ... please ;)

Thanks,
Walter

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to