2013-03-25 69 views
1

当我不称为复合组件上: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() doesen't被调用上my:component并且随后的现有值未示出。

如果我这样做,虽然

<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,...函数ok,它只是我的组件不显示现有值(encodeAll未调用)。

我也尝试过h:datatable组件而不是ui:重复(不知道为什么),结果相同。

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 
+0

它是自定义组件(Java)还是组合组件(XHTML)?你的问题标题和问题标签是相互矛盾的。要知道区别,请阅读http://stackoverflow.com/questions/6822000/when-to-use-uiinclude-tag-files-composite-components-and-or-custom-componen/6822269#6822269 – BalusC 2013-03-25 12:00:40

+0

这是一个自定义组件http://balusc.blogspot.de/2013/01/composite-component-with-multiple-input.html - 受你的代码启发 – apod 2013-03-25 12:25:12

+0

这不完全是一个自定义组件,这是一个复合组件。 – BalusC 2013-03-25 12:26:28

回答

4

根据给定的代码,我无法重现你的问题,但我可以重现它,当我在PrimeFaces组件包裹。例如。当<ui:fragment><p:panel>(没有rendered!)代替时。这是由PrimeFaces CoreRenderer单独在renderChildren()方法中不调用UIComponent#encodeAll(),而是encodeBegin(),encodeChildren()encodeEnd()造成的。

如果您在encodeBegin()而不是encodeAll()执行作业,那么它应该工作。我相应地更新了我的复合组件文章。

+0

谢谢BalusC,你刚刚救了我一天。 – apod 2013-03-25 12:56:27

+0

不客气。 – BalusC 2013-03-25 12:56:32