包装了render属性后,未在复合组件上调用encodeAll() [英] encodeAll() not called on a composite component when rendered attribute is wrapped

查看:123
本文介绍了包装了render属性后,未在复合组件上调用encodeAll()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我这样做时:

<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()不会在my:component上被调用,随后将不显示现有值.

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 />

后一个示例毫无用处,因为我想要动态输入.现有的(默认)组件,如datepicker,inputtext,...功能正常,只有我的组件不显示现有值(未调用encodeAll).

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).

我还尝试了h:datatable组件而不是ui:repeat(虽然不确定为什么),但结果相同.

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

推荐答案

我无法根据给定的代码重现您的问题,但是当我将其包装在PrimeFaces组件中时,我可以重现它.例如.当<ui:fragment><p:panel>替换时(没有rendered!).这是由于PrimeFaces CoreRenderer不在renderChildren()方法中调用UIComponent#encodeAll(),而是分别在encodeBegin()encodeChildren()encodeEnd()中调用.

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.

如果您在encodeBegin()而不是encodeAll()中执行作业,则它应该可以工作.我已经相应地更新了我的复合组件文章.

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

这篇关于包装了render属性后,未在复合组件上调用encodeAll()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆