在一个抽象级别,将软件分成能执行单个任务的多个方法。使用 Composed Method 模式的好处已经有大量书面记载(详细说明,请参见 Neal Ford 的 “” )。在这里,我将侧重于介绍如何在 JSF 视图中使用 Composed Method 模式。
1 2 3 4 5 6 7 8 9 10 11 12 13 | <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <div class="menuLeftText"> #{msgs.welcomeGreeting} <div class="welcomeImage"> <h:graphicImage library="images" name="cloudy.gif"/> </div> </div> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:util="http://java.sun.com/jsf/composite/components/util"> <div class="placesSearchForm"> <div class="placesSearchFormHeading"> #{msgs.findAPlace} </div> <h:form prependId="false"> <h:panelGrid columns="2"> #{msgs.streetAddress} <h:inputText value="#{place.streetAddress}" size="15"/> #{msgs.city} <h:inputText value="#{place.city}" size="10"/> #{msgs.state} <h:inputText value="#{place.state}" size="3"/> #{msgs.zip} <h:inputText value="#{place.zip}" size="5"/> <h:commandButton value="#{msgs.goButtonText}" style="font-familyalatino;font-style:italic" action="#{place.fetch}"/> </h:panelGrid> </h:form> </div> <util:icon image="#{resource['images:back.jpg']}" actionMethod="#{places.logout}" style="border: thin solid lightBlue"/> </ui:composition> |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |