javaserverfaces-spec-public
  1. javaserverfaces-spec-public
  2. JAVASERVERFACES_SPEC_PUBLIC-1115

How does JSF handle children when they are not JSF components?

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Mojarra 2.1

      Description

      I've tryed to find in the spec how a JSF component should handle its children if those are HTML tags or plain text instead of JSF components but I couldn't really find anything. So please, if I've miss it, just indicate me the chapter number.

      So I've make some tests and it appears that Mojarra is always wrapping those kind of child inside a UIInstructions (which is implementation specific). Shouldn't a standard way should be specify to let people know how to handle with non JSF content inside a JSF component? So every JSF implementation use the same mechanism.

      In the same topic, I'm fine when plain text is nested inside a UIInstructions, but a bit sad when several HTML tags are nested inside only one UIInstructions. Why? Because I can no longer easily use both JSF components and HTML tags at the same time. For example, let's say I have a dropdown menu that will wrap each of its child inside a <li> tag when rendered.

      <x:dropdownMenu>
      	<h:link outcome="/index" value="Home"/>
      	<h:link outcome="/admin" value="Admin"/>
      </x:dropdownMenu>
      

      Should generated, by iterating over the children, something like:

      <ul class="dropdown">
      	<li><a href="you.context.path/index.jsf">Home</a></li>
      	<li><a href="you.context.path/admin.jsf">Home</a></li>
      </ul>
      

      But what if I use HTML tags directly now?

      <x:dropdownMenu>
      	<h:link outcome="/index" value="Home"/>
      	<h:link outcome="/admin" value="Admin"/>
      	<a href="help.externatsite.com">Help</a>
      	<a href="partner.com">Our partner</a>
      </x:dropdownMenu>
      

      The generated code will be:

      <ul class="dropdown">
      	<li><a href="you.context.path/index.jsf">Home</a></li>
      	<li><a href="you.context.path/admin.jsf">Home</a></li>
      	<li><a href="help.externatsite.com">Help</a><a href="partner.com">Our partner</a></li>
      </ul>
      

      Why is that? Because the two HTML tags are wrapped inside only one UIInstructions, so for the parent JSF component, both of them are only one child, and so they are both nested inside only one <li> tag.

      You could say that I could have used <h:outputLink> but that's not the point here. There is lots of HTML tags that just don't have a JSF equivalent, even more since HTML5, and those tags are not greatly handle when it comes to tree hierarchy IMO. Since the goal of JSF is to generate HTML, it should be able to plug with HTML natively.

      What about creating a JSF component like "UIHtmlTag" that would wrap any HTML tag found? So, in the previous example, instead of having only one UIInstructions, you would have two UIHtmlTag, far better for child rendering purpose. UIInstructions would be use for plain text only. What do you think?

        Activity

        Hide
        Ed Burns added a comment -

        Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

        Show
        Ed Burns added a comment - Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.
        Hide
        Manfred Riem added a comment -

        Setting priority to Minor

        Show
        Manfred Riem added a comment - Setting priority to Minor

          People

          • Assignee:
            Unassigned
            Reporter:
            paul_dijou
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated: