I have a Form with a list of Checks in a CheckGroup. In the same Form, there
is a DropDownChoice with a dynamic choices model. The choices are the
selected checks plus some fixed options.
It has to be considered that some Checks can be preselected at construction
time, and that the choices have to be updated while the user checks the
Checks. The Checks have an EventAjaxBehavior("onclick") in order to do some
processing and update the ddc's choice Model.

So, the Choices Model looks like this:

IModel choiceModel = new AbstractReadOnlyModel(){
   public Object get(){
      List<String> checkeds;
      if (!checkGroup.hasRawInput()){
          // With no input, get the ModelObject - construction time case
          checkeds = checkGroup.getModelObject();
      }
      else {
          checkeds = checkGroup.getConvertedInput();
      }
      // Add fixed options....
      checkeds.add (...);
      return checkeds;
   }
};

I find it quite annoying to have to do that kind of conditional. I have seen
there is the getValue() method, but that method returns getInput() or
getModelObjectAsString(). Isn't there any method to get ConvertedInput or
ModelObject instead ? Or any better way to achieve this ?

Also, I don't know if the choices Model will be updated automatically, or if
I have to perform some manual operation, if possible at all. Even if it's
not possible, I found this issue in other circumstances...

Cheers,
Xavier

Reply via email to