Uploaded image for project: 'Runtime'
  1. Runtime
  2. RUNTIME-3317

[ScriptHandler] Call a Java method with a Java array with Object signature

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • 4.8.0, 4.7.10
    • 4.3.0
    • None
    • None

      Since GraalJS, I'm trying to call the ModifiableDataHolder.setValue(Object) method with a Java array of String in a script :

      var content = ametysResolver.resolveById("personContent://afa5ba8d-671d-4ce2-ab02-7d9a25028d30");
      var values = ["test1", "test2"];
      content.setValue("role", Java.to(values, "java.lang.String[]"));

      I get the following error :

      ry to set the non string value '[test1, test2]' to the string data 'role' on '/ametys:root/ametys:plugins/odf/ametys:contents/11/91/person-person1-lancelot-fr (afa5ba8d-671d-4ce2-ab02-7d9a25028d30)'
      	at org.ametys.cms.data.type.impl.StringRepositoryElementType.write(StringRepositoryElementType.java:106)
      	at org.ametys.plugins.repository.data.holder.impl.DefaultModifiableModelAwareDataHolder.setValue(DefaultModifiableModelAwareDataHolder.java:284)
      	at org.ametys.plugins.repository.data.ametysobject.ModifiableModelAwareDataAwareAmetysObject.setValue(ModifiableModelAwareDataAwareAmetysObject.java:64)
      [...]

      With a breakpoint, I can see that the value is a PolyglotList.

            Unassigned Unassigned
            bmaurel Bérénice Maurel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: