在JSF 2.0中,我想將多個小部件放入小部件容器(即帶有標題文本的div)。如何在JSF 2.0的複合容器中嵌入多個複合材料(小部件)?
我創建的微件容器作爲複合:
<?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>
下面是需要在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>
:
<!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
下面的title
股利?
預先感謝任何有經驗的知識共享。
你的問題是模糊的,但你基本上是問如何在複合組件中使用''?對不起,如果我問明顯,但如果你只是嘗試它會發生什麼?這應該工作得很好。 –
BalusC
嗨Balus,謝謝你的表面上看起來很明顯。 我曾嘗試, mywidgets:tileContainer> 這不會在tile容器中顯示pictureTextTile。不是很明顯,這是行不通的。我基本上在詢問這種情況下的最佳做法。那麼,如何將小部件放在小部件中(使用JSF術語:您如何從容器組合中的合成站點複合體調用?)? –
feder
呃,說明你是如何嘗試這種方式的。也許你只是忘記了聲明它的XML命名空間'xmlns:mywidgets'? – BalusC