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 34 35 | public class Place { ... private String[] mapUrls private String weather ... public String fetch() { FacesContext fc = FacesContext.getCurrentInstance() ELResolver elResolver = fc.getApplication().getELResolver() // Get maps MapService ms = elResolver.getValue( fc.getELContext(), null, "mapService") mapUrls = ms.getMap(streetAddress, city, state) // Get weather WeatherService ws = elResolver.getValue( fc.getELContext(), null, "weatherService") weather = ws.getWeatherForZip(zip, true) // Get places Places places = elResolver.getValue( fc.getELContext(), null, "places") // Add new place to places places.addPlace(streetAddress, city, state, mapUrls, weather) return null } } |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:form> <!-- Iterate over the list of places --> <ui:repeat value="#{places.placesList}" var="place"> <div class="placeHeading"> <h:panelGrid columns="1"> <!-- Address at the top --> <h:panelGroup> <div style="padding-left: 5px;"> <i><hutputText value="#{place.streetAddress}"/></i>, <hutputText value="#{place.city}"/> <hutputText value="#{place.state}"/> <hr/> </div> </h:panelGroup> <!-- zoom level prompt and drop down --> <h:panelGrid columns="2"> <!-- prompt --> <div style="padding-right: 10px;margin-bottom: 10px;font-size:14px"> #{msgs.zoomPrompt} </div> <!-- dropdown --> <h:selectOneMenu onchange="submit()" value="#{place.zoomIndex}" valueChangeListener="#{place.zoomChanged}" style="font-size:13px;font-familyalatino"> <f:selectItems value="#{places.zoomLevelItems}"/> </h:selectOneMenu> </h:panelGrid> <!-- The map --> <h:graphicImage url="#{place.mapUrl}" style="border: thin solid gray"/> </h:panelGrid> <!-- The weather --> <div class="placeMap"> <div style="margin-top: 10px;width:250px;"> <hutputText style="font-size: 12px;" value="#{place.weather}" escape="false"/> </div> </div> </div> </ui:repeat> </h:form> </ui:composition> |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |