6 Replies Latest reply on Jan 31, 2010 9:16 AM by Stefan Huber

    conditional attribute in RichFaces CDK template (custom component)

    Stefan Huber Newbie

      Hi everybody!

       

        We're implementing a cusomt RichFaces component with the CDK. The template contains some HTML input elements:

      <input id="..." type="text" ... />

      What's the best way to implement the HTML attribut "disabled" for those elements?

       

      We exposed the disabled attribute via the component configuration and the most meaningful way to disable the component would be to mark each single <input> element with the HTML disabled attriubute.

       

      Now what I am doing now ist this (shortened):

      {code:xml}

          <jsp:scriptlet>
          <![CDATA[
          boolean disabled = getUtils().isBooleanAttribute(component, "disabled");
          if (disabled) {
          ]]>
          </jsp:scriptlet>
            <input id="#{clientId}T" name="#{clientId}T" type="text"
                 value="#{component.attributes['valueT']}"
                 disabled="disabled"/>

       

            <input id="#{clientId}N" name="#{clientId}N" type="text"
                 value="#{component.attributes['valueN']}"
                 disabled="disabled"/>

          <jsp:scriptlet>
          <![CDATA[
          } else {
          ]]>
          </jsp:scriptlet>

            <input id="#{clientId}T" name="#{clientId}T" type="text"
                 value="#{component.attributes['valueT']}"/>

       

            <input id="#{clientId}N" name="#{clientId}N" type="text"
                 value="#{component.attributes['valueN']}"/>

          <jsp:scriptlet>
          <![CDATA[
          }
          ]]>
          </jsp:scriptlet>

      {code}

       

       

      It would be nice, if I could have the markup just once and the disabled attribute only written if the component is disabled.
      Can I somehow define an entity &isDisabled; that is empty or not? I think, that's the only way to do this in valid in XML markup, right?