Details

    • Type: Enhancement
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.2.1.Final
    • Fix Version/s: 4.5-Tracking
    • Component/s: cdk
    • Labels:
    • Environment:

      All

      Description

      When using "cdk:object" tag, the cast will only occur for a part of the generated Java code, not for all of it. Here is an example :

      <cc:implementation>
          <cdk:object type="..." name="objectName" />
          // HTML code using "objectName"
          <cdk:body />
          // HTML code using "objectName"
      </cc:implementation>
      

      This will not work because the first part of the HTML code will be in "encodeBegin" method and the second part will be in "encodeEnd" method. But the cast will only happens in the "encodeBegin" method. And so there will be an error in "encodeEnd". The workaround is to copy/paste <cdk:object/> after the <cdk:body />. Ugly!

      One solution would be that <cdk:object/> would generate Java code in every method that could use the variable even if they don't (methods like "encodeBegin", "encodeEnd", ...).

      Another one would be that <cdk:object/> generates the following method :

      <cdk:object type="org.richfaces.bootstrap.component.AbstractBlockquote" name="blockquote" value="#{castComponent(component)}"/>
      

      public AbstractBlockquote getCdkObjectBlockquote(FacesContext facesContext, UIComponent component) {
          // From "value" attribute :
          AbstractBlockquote blockquote = this.castComponent(component); 
          return blockquote;
      }
      

      And then replace all "blockquote" calls in HTML code with getCdkObjectBlockquote(facesContext, component);. Not sure if this last part is possible if the generation is only a copy/paste from the EL.

      An alternative would be to use it like a singleton.

      public class BlockquoteRenderer extends BlockquoteRendererBase {
          private AbstractBlockquote blockquote;
       
          private AbstractBlockquote getBlockquote(FacesContext facesContext, UIComponent component) {
              if(blockquote == null) {
                  blockquote = getCdkObjectBlockquote(facesContext, component);
              }
              return blockquote;
          }
      }
      

      Or any other idea that allow to call <cdk:object/> only once in the template.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated: