1

When I do:

<h:form>
    <ui:repeat ...>
        <ui:fragment rendered="#{xyz.type eq 1}"
           <h:inputText value="#{xyz}"/>
        </ui:frament>

        <ui:fragment rendered="#{xyz.type eq 2}"
           <my:component value="#{xyz}"/>
        </ui:frament>
    <ui:repeat />
</h:form>

encodeAll() doesen't get called on my:component and subsequently the existing values are not shown.

If I do the following though

    <ui:repeat ...>
        <ui:fragment rendered="#{xyz.type eq 1}"
           <h:inputText value="#{xyz}"/>
        </ui:frament>

        <ui:fragment rendered="#{xyz.type eq 2}"
           <h:form>
               <my:component value="#{xyz}"/>
           </h:form>
        </ui:frament>
    <ui:repeat />

The latter example is useless of course, as I want to have dynamic inputs. Existing (default) components as datepicker, inputtext, ... function ok, it is only my component that doesnt show existing values (encodeAll not called).

I also tried h:datatable component instead of ui:repeat (not sure why though), with same results.

INFO: Initializing Mojarra 2.1.6 (SNAPSHOT 20111206) for context '/webclient'
INFO: Running on PrimeFaces 3.5
INFO: Running on PrimeFaces Extensions 0.6.3
apod
  • 81
  • 1
  • 10
  • Is it a custom component (Java) or a composite component (XHTML)? Your question title and question tags are contradicting each other. To know the difference, read http://stackoverflow.com/questions/6822000/when-to-use-uiinclude-tag-files-composite-components-and-or-custom-componen/6822269#6822269 – BalusC Mar 25 '13 at 12:00
  • It is a custom component http://balusc.blogspot.de/2013/01/composite-component-with-multiple-input.html - inspired by your code – apod Mar 25 '13 at 12:25
  • That's not precisely a custom component, that's a composite component. – BalusC Mar 25 '13 at 12:26
  • I posted an answer, but in the future, please provide a real SSCCE instead of a too oversimplified snippet which doesn't reproduce the problem at all when copy'n'paste'n'runned into a blank playground environment. – BalusC Mar 25 '13 at 12:42

1 Answers1

5

I can't reproduce your problem based on the given code, but I can reproduce it when I wrap it in a PrimeFaces component. E.g. when <ui:fragment> is replaced by <p:panel> (without rendered!). This is caused by the PrimeFaces CoreRenderer not calling UIComponent#encodeAll() in renderChildren() method, but encodeBegin(), encodeChildren() and encodeEnd() individually.

If you perform the job in encodeBegin() instead of encodeAll(), then it should work. I have updated my composite component article accordingly.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555