3 Replies Latest reply on Nov 20, 2008 8:57 PM by nbelaevski

    CDK vcp-body problem with condition

    asrichas2can

      I'm developing a template based component similar to link.jspx

      There is one section for including the child nodes:

      <vcp:body>
       <f:call name="renderChildren" />
       </vcp:body>


      The generator works fine.
      But if I introduce a condition then I get compiler error like "illegal start of expression" in the renderer class.

      I tried <c:if> as well as
       <jsp:scriptlet>
       <![CDATA[
       if (condition) {
       ]]>
       </jsp:scriptlet>


      The generated code is corrupt.
      But if I remove the <vcp:body> section, everything works fine - except I cannot use chield node like <f:param> any more :-(



        • 1. Re: CDK vcp-body problem with condition
          asrichas2can

          Now I understood the problem.
          When the code generators finde the vcp:body-Tag, it stopps writing the code into doEncodeBegin() and starts with doEncodeChildren().
          So there are if-statement starting before the body and ending after it, then the closing } ends in a different method and causes an error.

          It replaced this by separate if-clause. But there are 2 disadvantages:
          [list=]
          Some xml thinks now there are unbalanced tags, because a div-Tag is opened in one if-clause and must be closed in another.

          • 2. Re: CDK vcp-body problem with condition
            asrichas2can

            // Please ignore my previous reply, it is incomplete.

            Now I understood the problem.
            When the code generators finds the vcp:body-Tag, it stopps writing the code into doEncodeBegin() and starts with doEncodeChildren().
            So if there are if-statement starting before the body and ending after it, then the closing } ends in a different method and causes an compiler error.

            I replaced this by separate if-clause. But there are 2 disadvantages:

            Some xml parser thinks now there are unbalanced tags, because a div-Tag is opened in one if-clause and must be closed in another. How can I disabled this well-formed checker?

            The other problem is that I define a condition variable in a jsp-scriptlet. Because the visibility of this scriptlet ends in doEncodeBegin() but the value would be needed also in doEncodeEnd(), I have to repeat the code, which is not very readable.


            • 3. Re: CDK vcp-body problem with condition
              nbelaevski

               

              "AsRichAs2Can" wrote:
              Some xml parser thinks now there are unbalanced tags, because a div-Tag is opened in one if-clause and must be closed in another. How can I disabled this well-formed checker?

              Use ResponseWriter#startElement/endElement in scriptlet to handle this.

              "AsRichAs2Can" wrote:
              The other problem is that I define a condition variable in a jsp-scriptlet. Because the visibility of this scriptlet ends in doEncodeBegin() but the value would be needed also in doEncodeEnd(), I have to repeat the code, which is not very readable.

              Use c:set tag and org.ajax4jsf.renderkit.ComponentVariables class to pass variables between methods. Check source of this project: http://anonsvn.jboss.org/repos/richfaces/trunk/ui/componentControl