真正的动态声明性组件
生活随笔
收集整理的這篇文章主要介紹了
真正的动态声明性组件
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
在這篇簡(jiǎn)短的文章中,我將重點(diǎn)介紹ADF動(dòng)態(tài)聲明性組件。 我的意思是一個(gè)眾所周知的ADF標(biāo)簽af:declarativeComponent 。 它可以用作將頁(yè)面設(shè)計(jì)為頁(yè)面片段和組件組成的一種非常便捷的方法。 例如,我們的頁(yè)面可以包含以下代碼片段:
PageFragment.jsff是像這樣的普通頁(yè)面片段:
<?xml version='1.0' encoding='UTF-8'?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"xmlns:af="http://xmlns.oracle.com/adf/faces/rich"><af:panelGroupLayout id="pgl1"><af:outputText value="This is a page fragment. You can add your content to the following facet:"id="ot1"/><af:facetRef facetName="TheFacet"/></af:panelGroupLayout> </jsp:root>如果我們需要能夠?qū)⒛承﹨?shù)傳遞給頁(yè)面片段,則可以將片段定義為組件:
<?xml version='1.0' encoding='UTF-8'?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"xmlns:af="http://xmlns.oracle.com/adf/faces/rich"> <af:componentDef var="attrs"><af:xmlContent><component xmlns="http://xmlns.oracle.com/adf/faces/rich/component"><facet><facet-name>TheFacet</facet-name></facet><attribute><attribute-name>Title</attribute-name></attribute></component></af:xmlContent><af:panelGroupLayout id="pgl1"><af:outputText value="This is a component #{attrs.Title}.You can add your content to the following facet:" id="ot1"/><af:facetRef facetName="TheFacet"/></af:panelGroupLayout></af:componentDef> </jsp:root>在此示例中,我們可以傳遞如以下代碼片段所示的Title屬性的值:
<af:declarativeComponent viewId="ComponentFragment.jsff"id="dc2"Title="Buttom Container">??????????????????? <f:facet name="TheFacet"><af:button text="button 2" id="b2"/></f:facet>??????????????????? </af:declarativeComponent>這項(xiàng)技術(shù)最酷的地方是viewId屬性不僅可以接受靜態(tài)字符串,還可以接受EL表達(dá)式:
<af:declarativeComponent viewId="#{TheBean.fragmentViewID}"id="dc1"><f:facet name="TheFacet"><af:button text="button 1" id="b1"/></f:facet>??????????????????? </af:declarativeComponent>public String getFragmentViewID() {return "PageFragment.jsff"; }實(shí)際上,這就是為什么這種構(gòu)造稱為動(dòng)態(tài)的原因,也就是為什么可以將此功能視為構(gòu)建結(jié)構(gòu)良好,靈活而動(dòng)態(tài)的UI的強(qiáng)大工具。
而已!
翻譯自: https://www.javacodegeeks.com/2014/09/really-dynamic-declarative-components.html
總結(jié)
以上是生活随笔為你收集整理的真正的动态声明性组件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 电脑显卡cfu作用是什么(cf主要看显卡
- 下一篇: 修一个电脑的桥(电脑怎么搭桥)