RichFaces
  1. RichFaces
  2. RF-10192

rich:dropDownMenu: Enum in renderer vs. String in Component API - EL coercion problem

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved (View Workflow)
    • Priority: Major Major
    • Resolution: Done
    • Affects Version/s: 4.0.0.Milestone5
    • Fix Version/s: 4.0.0.Milestone6
    • Component/s: component-menu
    • Security Level: Public (Everyone can see)
    • Labels:
      None
    • Environment:
      RichFaces 4 M5
    • Similar Issues:
      Show 10 results 

      Description

      <r:dropDownMenu mode="#

      {beanNull.mode}

      " >

      java.lang.IllegalArgumentException: No enum const class org.richfaces.component.Mode.
      at java.lang.Enum.valueOf(Enum.java:196)
      at org.richfaces.component.Mode.valueOf(Mode.java:24)
      at org.richfaces.renderkit.html.MenuItemRendererBase.resolveSubmitMode(MenuItemRendererBase.java:120)

      Reason:
      MenuItemRendererBase calls Mode.valueOf(abstractDropDownMenu.getMode()); but AbstractDropDownMenu.getMode() returns String - then if #{} resolves to null, EL will coerce null to "" ([1]) and returns it from getMode() method.

      Solutions:
      1) use quick fix like:
      String mode = parent.getMode();
      if (StringUtils.isEmpty(mode))

      { return Mode.server; }

      2) Disable this (stupid) coercion rule (workaround):
      JUEL: http://juel.sourceforge.net/guide/advanced/index.html
      TOMCAT: http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html - COERCE_*

      3) Use org.richfaces.component.Mode in AbstractDropDownMenu API:
      EL 2.2 spec 1.18.6 Coerce A to an Enum Type T: "If A is null, return null" - for Enum here is no coercion problem.

      I would prefer solution 3) if possibible, because we use Java API directly (menu.setMode(Mode.Server) is nicer and safer than a menu.setMode(Mode.server.name())

      [1]
      https://jsp-spec-public.dev.java.net/issues/show_bug.cgi?id=183
      https://uel.dev.java.net/issues/show_bug.cgi?id=12

        Activity

        Hide
        Anton Belevich
        added a comment -

        Done. AbstractMenuItem and AbstractDropDownMenu have enum Mode of org.richfaces.component.Mode type.

        Show
        Anton Belevich
        added a comment - Done. AbstractMenuItem and AbstractDropDownMenu have enum Mode of org.richfaces.component.Mode type.

          People

          • Assignee:
            Anton Belevich
            Reporter:
            Martin Kočí
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: