Jsf 2 在JSF2.0中,如何在复合容器中嵌入多个复合(小部件)?
在JSF2.0中,我想将多个小部件放入一个小部件容器(即带有标题文本的div) 我将小部件容器创建为一个组合:Jsf 2 在JSF2.0中,如何在复合容器中嵌入多个复合(小部件)?,jsf-2,facelets,composite-component,Jsf 2,Facelets,Composite Component,在JSF2.0中,我想将多个小部件放入一个小部件容器(即带有标题文本的div) 我将小部件容器创建为一个组合: <?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h=
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface name="tileContainer" displayName="Tile container respectively category."
shortDescription="This tile container may be used to gather multiple different tiles. Caution. Let CSS take care of the layout, the composite the logic.">
<composite:attribute name="title" default="" required="false"
type="java.lang.String" />
</composite:interface>
<composite:implementation>
<div class="tileContainer">
<div class="title">#{cc.attrs.title}</div>
</div>
</composite:implementation>
</html>
#{cc.attrs.title}
以下是需要嵌入tileContainer中的小部件:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:composite="http://java.sun.com/jsf/composite">
<!-- INTERFACE -->
<composite:interface name="pictureTextTile" shortDescription="Provides a top-aligned imaged followed by text.">
<composite:attribute name="title" default="" required="false"
type="java.lang.String" />
<composite:attribute name="isVerticalStacked" default="true" type="java.lang.Boolean"/>
<composite:attribute name="picture" required="false"/>
<composite:attribute name="teaser" required="false" type="java.lang.String"/>
<composite:attribute name="article" required="true" type="java.lang.String"/>
</composite:interface>
<!-- IMPLEMENTATION: REUSABLE FOR CREATE AND UPDATE ACTIONS-->
<composite:implementation>
<div class="tile">
<div class="image">#{cc.attrs.image}</div>
<div class="title">#{cc.attrs.title}</div>
<div class="teaser">#{cc.attrs.teaser}</div>
<div class="article">#{cc.attrs.article}</div>
</div>
</composite:implementation>
</html>
#{cc.attrs.image}
#{cc.attrs.title}
#{cc.attrs.trister}
#{cc.attrs.article}
我试着这样调用它:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:mywidgets="http://java.sun.com/jsf/composite/widgets">
<ui:composition template="/templates/overview.xhtml">
<ui:define name="title">Overview</ui:define>
<ui:define name="body">
<mywidgets:tileContainer title="Profession">
<mywidgets:pictureTextTile title="Websockets" article="Lorem Ipsum"></mywidgets:pictureTextTile>
</mywidgets:tileContainer>
<mywidgets:tileContainer title="Sports"/>
</ui:define>
</ui:composition>
</html>
概述
如何将不同类型的其他小部件(组合)插入标题下的tileContainer
提前感谢您有经验的知识共享。您可以使用来指定复合组件的子组件应插入的位置
<div class="title">#{cc.attrs.title}</div>
<cc:insertChildren />
{cc.attrs.title}
您的问题很模糊,但您基本上是在问如何在复合组件中使用
?对不起,如果我问显而易见的问题,但是如果你只是尝试一下会发生什么?这应该很好。嗨,巴卢斯,谢谢你问这个看似显而易见的问题。我确实尝试过,但这不会在磁贴容器中显示pictureTextTile。不太明显,这是否有效。我基本上是在问这种情况下的最佳实践。那么,您如何将小部件放在小部件中(用JSF术语来说:如何从组合站点调用容器组合中的组合?)?嗯,展示您是如何尝试这种方式的。也许您只是忘记声明它的XML名称空间xmlns:mywidgets
?好的。我把它附在我原来的问题之后。只是想让您知道,pictureTextTile如果没有嵌入到tileContainer中就可以工作。从图形上看,这应该是一个盒子(小部件)中的一个盒子(小部件)。没什么特别的。哦,你想声明另一个复合材料作为复合材料的主体。我知道您想在
中使用另一个组合。(失败的)代码尝试使这一点更加清晰。是的,这正是我想要的。谢谢你,巴卢斯。