Uploaded image for project: 'Errai'
  1. Errai
  2. ERRAI-938

Having an option on @DataField for alternative attribute merging strategies

    Details

    • Type: Feature Request
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 4.0.0.Beta1
    • Fix Version/s: 4.0.0.Beta3
    • Component/s: ErraiUI
    • Labels:
      None
    • Story Points:
      100
    • Estimated Difficulty:
      Low
    • Release Notes Text:
      Hide
      Data fields now support two different strategies for merging attributes: USE_BEAN, and USE_TEMPLATE.

      For most attributes: USE_TEMPLATE overwrites attribute values on the bean field with values from the template. USE_BEAN only writes attribute values from the template to the bean field if the bean field did not already have a value for the respective attribute.

      The "class" and "style" attributes work differently, since they both represent lists of values. For "class", all class names from the template and bean field are kept regardless of strategy. For "style", style properties are merged together, and the strategy USE_BEAN or USE_TEMPLATE is used to decide which property value is used in the event of a conflict.
      Show
      Data fields now support two different strategies for merging attributes: USE_BEAN, and USE_TEMPLATE. For most attributes: USE_TEMPLATE overwrites attribute values on the bean field with values from the template. USE_BEAN only writes attribute values from the template to the bean field if the bean field did not already have a value for the respective attribute. The "class" and "style" attributes work differently, since they both represent lists of values. For "class", all class names from the template and bean field are kept regardless of strategy. For "style", style properties are merged together, and the strategy USE_BEAN or USE_TEMPLATE is used to decide which property value is used in the event of a conflict.

      Description

      Hi Errai Team,

      We have some issues in to our GMD Widgets that everytime we inject the component widget it overrides it's class for e.g.

      Inside WelcomPage.html

      <div data-field="icon" class="red-text"></div>
      

      Inside WelcomePage.java

      @Inject
      @DataField("icon")
      MaterialIcon icon; // this component has setStyleName("material-icon"); on its constructor.
      

      This is the MaterialIcon architecture

          /**
           * Creates an empty icon.
           */
          public MaterialIcon() {
              super();
              addStyleName("material-icons");
          }
      

      Question
      Can we avoid overriding the stylename once it's being rendered ? Instead we can append it so that it will not break the initialization of predefined class into MaterialIcon widget.

      Conclusion
      This feature request was discussed on this Github Issue thread https://github.com/errai/errai/issues/170#issuecomment-216293832. And we would to have an option on @DataField for alternative attribute merging strategies might be a good idea.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mbarkley Max Barkley
                Reporter:
                mark.kevin.ringor mark kevin ringor
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: