• Problem using Dojo Name Text Box with bean

    By Tommy Valand 1 decade ago

    I use the Name Text Box (from now on NTB), with multi value separator set to ",", in conjunction with a Name Picker.

    The NTB is bound to a field in the bean of type Vector. If I edit the underlying document for the bean in Notes, the NTB shows the values for the field correctly, but when I try to update the bean (submit button), I get this error: java.lang.IllegalArgumentException: argument type mismatch

    It seems like for some reason or other the multivalue conversion fails. I've tried changing the bean field type to List, ArrayList, with and without generics, but I just can't seem to make it work. It fails whether there's no value, one value, or multiple values.

    Snippet from what's posted to the server:

    Content-Disposition: form-data; name="view:_id1:_id2:mainCol:contentAccessGroups"
    PWM,PWM Bryne

     

    • Need a sample NSF

      By Philippe Riand 1 decade ago

      Please send some sample code to reproduce the issue

      • Demoapp/found a workaround

        By Tommy Valand 1 decade ago

        I figured out my issue. I used "strict" getters and setters. I expected the XPages runtime to get/set a list of values when the field had the multipleSeparator set to some value.

        What it does is to set a string when the field in the web form has single value, and a list when the field has multiple values.

        The demoapp contains several different controls bound to bean fields.

        Would it be possible to have a property in the name picker that let's you choose if the user can select one or multiple values? Then I would write my own custom converter that avoids the issue with loose typing in getters and setters. The current way works great if you have a document bound to the field, but as more and more developers are starting to use beans, I would expect that they run into the same issues (expecting to be able to use Lists in getters/setters).

        If that's not possible, could you be able to improve the error message. E.g. 

        java.lang.IllegalArgumentException: argument type mismatch (Expected Vector, got String)