001/*
002 * (C) Copyright 2006-2007 Nuxeo SAS <http://nuxeo.com> and others
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Jean-Marc Orliaguet, Chalmers
011 *
012 * $Id$
013 */
014
015package org.nuxeo.theme.jsf.component;
016
017import java.io.IOException;
018import java.util.HashMap;
019import java.util.Map;
020
021import javax.faces.component.UIOutput;
022import javax.faces.context.FacesContext;
023import javax.faces.context.ResponseWriter;
024
025import org.nuxeo.theme.html.ui.MVCElement;
026
027public abstract class UIBaseMVC extends UIOutput {
028
029    private String resource;
030
031    private String url;
032
033    public abstract String getClassName();
034
035    @Override
036    public void encodeBegin(final FacesContext context) throws IOException {
037        final ResponseWriter writer = context.getResponseWriter();
038
039        final Map<String, Object> attributes = getAttributes();
040        final Map<String, String> params = new HashMap<String, String>();
041        params.put("className", getClassName());
042        params.put("resource", (String) attributes.get("resource"));
043        params.put("url", (String) attributes.get("url"));
044        writer.write(MVCElement.render(params));
045    }
046
047    public String getResource() {
048        return resource;
049    }
050
051    public void setResource(final String resource) {
052        this.resource = resource;
053    }
054
055    public String getUrl() {
056        return url;
057    }
058
059    public void setUrl(final String url) {
060        this.url = url;
061    }
062
063}