001/* 002 * (C) Copyright 2006-2007 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Jean-Marc Orliaguet, Chalmers 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.theme.jsf.component; 023 024import java.io.IOException; 025import java.util.HashMap; 026import java.util.Map; 027 028import javax.faces.component.UIOutput; 029import javax.faces.context.FacesContext; 030import javax.faces.context.ResponseWriter; 031 032import org.nuxeo.theme.html.ui.MVCElement; 033 034public abstract class UIBaseMVC extends UIOutput { 035 036 private String resource; 037 038 private String url; 039 040 public abstract String getClassName(); 041 042 @Override 043 public void encodeBegin(final FacesContext context) throws IOException { 044 final ResponseWriter writer = context.getResponseWriter(); 045 046 final Map<String, Object> attributes = getAttributes(); 047 final Map<String, String> params = new HashMap<String, String>(); 048 params.put("className", getClassName()); 049 params.put("resource", (String) attributes.get("resource")); 050 params.put("url", (String) attributes.get("url")); 051 writer.write(MVCElement.render(params)); 052 } 053 054 public String getResource() { 055 return resource; 056 } 057 058 public void setResource(final String resource) { 059 this.resource = resource; 060 } 061 062 public String getUrl() { 063 return url; 064 } 065 066 public void setUrl(final String url) { 067 this.url = url; 068 } 069 070}