panelgrid内部的复合组件未“扩展" [英] a composite component inside panelgrid is not 'expanded'

查看:68
本文介绍了panelgrid内部的复合组件未“扩展"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我在panelgrid内一次又一次地使用这种模式:

Basically, i've been using this pattern again and again inside a panelgrid :

<h:panelGrid columns="2" >
    <h:outputLabel for="heroName" value="Hero Name : " />
    <h:panelGroup>
        <h:inputText label="Hero Name : "
            value="#{ccBean.data.map['heroName']}" id="heroName" />
        <p:message for="heroName" />
    </h:panelGroup>
    ...
</h:panelGrid>

我注意到我做了很多重复,例如h:inputText中的id,它将在 for ="idValue" 中再次复制为outputLabel,然后在 p中再次复制:消息. inputText的 label 值和 h:outputLabel 值也会发生相同的情况.

I notice that i duplicate things so much, like the id in h:inputText, which will be duplicated again in for="idValue" for outputLabel, and then again in p:message. The same thing happens with the inputText's label value and h:outputLabel value.

因此,我正在考虑制作一个简单的复合组件以将其包装起来:

So, i was thinking about making a simple composite component to wrap these up :

<composite:interface>
    <composite:attribute name="id" required="true" />
    <composite:attribute name="label" required="true" />
    <composite:attribute name="value" required="true" />
    <composite:attribute name="includeLabel" required="false" default="false"/>
</composite:interface>

<composite:implementation>
    <h:outputLabel for="#{cc.attrs.id}" value="#{cc.attrs.label}" 
            render="#{cc.attrs.includeLabel}" />
    <h:panelGroup>
        <h:inputText label="#{cc.attrs.label}"
            value="#{cc.attrs.value}" id="#{cc.attrs.id}" />
        <p:message for="#{cc.attrs.id}" />
    </h:panelGroup>
</composite:implementation>

然后我利用复合组件:

<h:panelGrid columns="2" >
    <s:inputText
        id="heroName"
        label="Hero Name : "
        value="#{ccBean.data.map['heroName']}"
            includeLabel="true"
    />
    <s:inputText
        id="heroName2"
        label="Hero Name 2 : "
        value="#{ccBean.data.map['heroName2']}"
            includeLabel="true"
    />
    ...
</h:panelGrid>

该复合组件可以正常工作,但是panelGrid现在假定s:inputText是一个组件.在使用复合组件之前,必须在一行中有2个组件,分别是outputLabel和panelGroup.

That composite component works fine, but the panelGrid now assumes that the s:inputText is one component. Before using the composite component, there are 2 components in one row, which is the outputLabel and the panelGroup.

在这种情况下是否可以暗示复合组件自身扩展",从而使其占据2列而不是我的panelGrid中的1列?

Is it possible to hint the composite component to 'expand' itself in this case so that it takes up 2 columns instead of 1 column in my panelGrid ?

谢谢!

推荐答案

否,不幸的是,没有.最好的选择是创建一个简单的标记文件.

No, unfortunately not. Your best bet is to create a simple tag file instead.

这篇关于panelgrid内部的复合组件未“扩展"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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