开发者

Output arbitrary tag element in Facelets?

开发者 https://www.devze.com 2023-02-24 03:55 出处:网络
I want to output a tag with dynamic attributes like: <foo attr1=开发者_如何学编程\"val1\" attr2=\"val1\"

I want to output a tag with dynamic attributes like:

<foo attr1=开发者_如何学编程"val1"
     attr2="val1"
     attr3="val1">
    Contents
</foo>

Where attribute names is unknown in compile time.

It's obviously c:forEach or ui:repeat doesn't work here:

<foo <c:forEach ... /> >

So, is there something like this?

<x:element name='foo'>
    <forEach>
        <x:attribute name='#{"attr" + index}'>
            #{"val" + index}
        </x:attribute>
    </forEach>
</x:element>

Thanks.


You can do it with f:attribute (xmlns:f=http://java.sun.com/jsf/core), which would associates an attribute with the nearest parent UIComponent.

See:

  • http://download.oracle.com/docs/cd/E17802_01/j2ee/j2ee/javaserverfaces/1.2/docs/tlddocs/
  • http://myfaces.apache.org/core11/myfaces-impl/tlddoc/f/attribute.html


Try using xslt parsing for the existing xml feed. I think you can use for this. Please go through the xslt tutorial for more details.

http://www.w3schools.com/xsl/

0

精彩评论

暂无评论...
验证码 换一张
取 消