Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-12201

Add common method to all generated CDK component

    Details

    • Type: Enhancement
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Rejected
    • Affects Version/s: 4.2.1.Final
    • Fix Version/s: None
    • Component/s: cdk
    • Labels:
    • Environment:

      All

      Description

      Looking at CDK AbstractComponent, or RendererBase or template.xml, I find lot of code copy/paste again and again. Maybe it could be usefull to have some common methods automatically generated by the CDK. I have some ideas right now, but I guess it will increase with time.

      Sometime, I call the method in the "component" var inside the template. Maybe it would not be possible since we can only add methods to the "AbstractComponent". I'm fine with having them there and casting the component at the beginning of the template using <cdk:object>.

      1) Test if an attribute is present :

      <c:when test="#{component.attributes['brand']!= null and not component.attributes['brand'].equals('')}">
      

      Can become :

      <c:when test="#{component.hasAttribute('brand')}">
      

      public boolean hasAttribute(String attributeName) {
          // TODO : test if the attribute is present
      }
      

      2) Test if a facet is present

      Same as before but about JSF facets

      <c:when test="#{component.getFacet('brand') != null and component.getFacet('brand').rendered}">
      

      Become

      <c:when test="#{component.hasFacet('brand')}">
      

      public boolean hasFacet(String facetName) {
          // TODO : test if the facet is present and rendered
      }
      

      3) The castComponent method

      This one is present in like 9 out of 10 AbstractComponent in the Bootstrap sandbox. I don't know how RF-11668 will be resolved. But if we still need to cast the component, having the method in every component by default would be really nice.

      4) Generate both "get..." and "is..." method for Boolean and boolean attributes

      If you have an attribute like :

      @Attribute
      abstract public boolean isClosable();
      

      This will generate a "isClosable()" method of course. But, then, trying to access it in a template like :

      <c:if test="#{alert.closable}">
      

      Will crash since JSF try to call the "getClosable()" method. The workaround is to write :

      <c:if test="#{alert.isClosable()}">
      

      But it would be nicer if the "geClosable()" method was generated in the same time of the "isClosable()" method.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  paul.dijou Paul Dijou
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: