2015-11-06 27 views
0

我的Java Web是新的,而我只是学习英语...... 我有倍数复合材料部件,工作正常,等等,例如,该代码提出了新的成分存在的成分里面

<composite:interface> 
    <composite:attribute name="usernameValue" /> 
</composite:interface> 
<composite:implementation> 

<h:form> 
    <h:outputText id="username" value="#{cc.attrs.usernameValue}" /> 
</h:form> 

当我需要使用这个组件,我只是做:

<myComposite:myComponent usernameValue="My user name value"/> 

该工程确定。

但是,如何做,如果我需要把更多的组件此之前创建的组件内部,如:

<h:form> 
    <h:outputText id="username" value="My text 1" /> 
    <p:commandButton value="New button 2"/> 
    <p:commandButton value="New button 3"/> 
    <p:commandButton value="New button 4"/> 
<h:form/> 

有没有办法做这样的事情:

<myComposite:myComponent usernameValue="This will render default inside composite output text"> 
    <p:commandButton value="New button 1 to render inside my composite"/> 
    <p:commandButton value="New button 2 to render inside my composite"/> 
    <p:commandButton value="New button 3 to render inside my composite"/> 
<myComposite:myComponent/> 

我学习,这次我根据我将使用的组件重新创建了需要使用的属性render="true or false"的所有组合,但这就像XGH。

对不起,我的英语,我知道我需要提高它...提前

谢谢...

回答

1

如果我理解正确你的问题,你的努力实现的是什么标签insertChildren呢。

在您的例子,它会像:

<composite:implementation> 
    <h:form> 
     <h:outputText id="username" value="#{cc.attrs.usernameValue}" /> 
     <composite:insertChildren /> 
    </h:form> 
</composite:implementation> 

,然后使用该组件像你预期:

<myComposite:myComponent usernameValue="This will render default inside composite output text"> 
    <p:commandButton value="New button 1 to render inside my composite"/> 
    <p:commandButton value="New button 2 to render inside my composite"/> 
    <p:commandButton value="New button 3 to render inside my composite"/> 
<myComposite:myComponent/> 

而且insertChildren标签被定义成CommandButton控件将被放置。

Here是它的用法的另一个例子。

+0

谢谢...像我需要的一样工作。 –