Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-13386

Fix NPE for suggestion widgets within list widgets

    XMLWordPrintable

    Details

    • Tags:
    • Upgrade notes:
      Hide

      suggestion widgets now work in list widgets

      Show
      suggestion widgets now work in list widgets

      Description

      When having a suggestion widget within a list widget, we get a NullPointerException. Example of layout:

          <layout name="layout@Book-create">
            <templates>
              <template mode="any">/layouts/grenard-SANDBOX_layout_template.xhtml</template>
            </templates>
            <rows>
              <row>
                <properties mode="any">
                  <property name="nxl_colspan_0">1</property>
                </properties>
                <widget>title</widget>
              </row>
              <row>
                <properties mode="any">
                  <property name="nxl_colspan_0">1</property>
                </properties>
                <widget>description</widget>
              </row>
              <row>
                <properties mode="any">
                  <property name="nxl_colspan_0">1</property>
                </properties>
                <widget>text</widget>
              </row>
              <row>
                <properties mode="any">
                  <property name="nxl_colspan_0">1</property>
                </properties>
                <widget>text1</widget>
              </row>
              <row>
                <properties mode="any">
                  <property name="nxl_colspan_0">1</property>
                </properties>
                <widget>text2</widget>
              </row>
              <row>
                <properties mode="any">
                  <property name="nxl_colspan_0">1</property>
                </properties>
                <widget>dummyPAth</widget>
              </row>
              <row>
                <properties mode="any">
                  <property name="nxl_colspan_0">1</property>
                </properties>
                <widget>testComplex</widget>
              </row>
            </rows>
            <widget name="title" type="text">
              <labels>
                <label mode="any">Title</label>
              </labels>
              <translated>false</translated>
              <fields>
                <field>dc:title</field>
              </fields>
              <properties widgetMode="edit">
                <property name="styleClass">dataInputText</property>
                <property name="required">true</property>
              </properties>
            </widget>
            <widget name="description" type="textarea">
              <labels>
                <label mode="any">Description</label>
              </labels>
              <translated>false</translated>
              <fields>
                <field>dc:description</field>
              </fields>
            </widget>
            <widget name="text" type="text">
              <labels>
                <label mode="any">WARNING</label>
              </labels>
              <translated>false</translated>
              <widgetModes>
                <mode value="create">view</mode>
              </widgetModes>
              <properties widgetMode="view">
                <property name="value">This layout can be configured on the "Create Layout" tab of this document type in Studio</property>
              </properties>
            </widget>
            <widget name="text1" type="htmltext">
              <labels>
                <label mode="any">Text1</label>
              </labels>
              <translated>false</translated>
              <fields>
                <field>bk:text1</field>
              </fields>
            </widget>
            <widget name="text2" type="htmltext">
              <labels>
                <label mode="any">Text2</label>
              </labels>
              <translated>false</translated>
              <fields>
                <field>bk:text2</field>
              </fields>
            </widget>
            <widget name="dummyPAth" type="path">
              <labels>
                <label mode="any">DummyPAth</label>
              </labels>
              <translated>false</translated>
              <fields>
                <field>bk:dummyPAth</field>
              </fields>
              <properties widgetMode="edit">
                <property name="required">true</property>
              </properties>
            </widget>
            <widget name="testComplex" type="list">
              <labels>
                <label mode="any">TestComplex</label>
              </labels>
              <translated>false</translated>
              <fields>
                <field>bk:testComplex</field>
              </fields>
              <properties widgetMode="edit">
                <property name="hideSubLabels">true</property>
              </properties>
              <subWidgets>
                <widget name="sub0" type="suggestManyDirectory">
                  <labels>
                    <label mode="any">TestMultiSelect</label>
                  </labels>
                  <translated>false</translated>
                  <fields>
                    <field>testMultiSelect</field>
                  </fields>
                  <properties widgetMode="edit">
                    <property name="directoryName">country</property>
                  </properties>
                </widget>
              </subWidgets>
            </widget>
          </layout>
      

      The stacktrace is

      Caused by: javax.el.ELException: /widgets/suggest_many_directory_widget_template.xhtml @68,92 value="#{select2Actions.encodeParametersForDirectory(widget, widgetProperties)}": java.lang.NullPointerException
      	at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
      	at javax.faces.component.UIOutput.getValue(UIOutput.java:184)
      	... 170 more
      Caused by: java.lang.NullPointerException
      	at org.nuxeo.ecm.platform.ui.select2.Select2ActionsBean.encodeParameters(Select2ActionsBean.java:219)
      	at org.nuxeo.ecm.platform.ui.select2.Select2ActionsBean.encodeParametersForDirectory(Select2ActionsBean.java:149)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
      	at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
      	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
      	at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
      	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      	at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:68)
      	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      	at org.nuxeo.ecm.platform.ui.web.util.NuxeoExceptionInterceptor.aroundInvoke(NuxeoExceptionInterceptor.java:79)
      	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      	at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
      	at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
      	at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
      	at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
      	at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
      	at org.nuxeo.ecm.platform.ui.select2.Select2ActionsBean_$$_javassist_56.encodeParametersForDirectory(Select2ActionsBean_$$_javassist_56.java)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:329)
      	at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:274)
      	at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
      	at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
      	at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
      	at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
      	... 171 more
      

      Debugging the code shows that the widgetProperties map has en entry with key="onclick" and value="null".

      Two things can be done:
      1- Protect Select2ActionsBeans.java against widget properties of which the value is null.
      2- Find out (probably in our xhtml template) where we propagate this null properties and remove it.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: