com\esri\arcgis\sample\bookmarks\BookmarkDetailsRenderer.java
/* Copyright 2010 ESRI * * All rights reserved under the copyright laws of the United States * and applicable international laws, treaties, and conventions. * * You may freely redistribute and use this sample code, with or * without modification, provided you include the original copyright * notice and use restrictions. * * See the use restrictions. * */ package com.esri.arcgis.sample.bookmarks; import com.esri.adf.web.faces.component.MapControl; import com.esri.adf.web.faces.renderkit.xml.ajax.AJAXRenderer; import com.esri.adf.web.util.XMLUtil; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import org.w3c.dom.Element; /** * AJAXRenderer to render selected bookmark's details as XML */ public class BookmarkDetailsRenderer implements AJAXRenderer { private final static Logger logger = Logger.getLogger(com.esri.arcgis.sample.bookmarks.BookmarkDetailsRenderer.class.getName()); public void renderAjaxResponse(FacesContext facesContext, UIComponent uIComponent, Object object, boolean b, Element element) { //get bookmark object from request map Map map = facesContext.getExternalContext().getRequestMap(); Object bookmarkObj = map.get(BookmarksPhaseListener.BOOKMARK_KEY); if (bookmarkObj == null) return; //cast to Bookmark Bookmark bookmark = (Bookmark) bookmarkObj; try { //add xml content Element detailsElement = XMLUtil.createElement("bookmark-details", null, element); XMLUtil.createElement("label", bookmark.getLabel(), detailsElement); XMLUtil.createElement("desc", bookmark.getDescription(), detailsElement); } catch (Exception e) { logger.log(Level.WARNING, "Unable to render bookmark details.", e); } } public Object getOriginalState(UIComponent uIComponent) { return null; } /** * Bookmark details renderer works with MapControl */ public Class getControlClass() { return MapControl.class; } }