问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/15613725/encodeall-not-called-on-a-composite-component-when-rendered-attribute-is-wrapp