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.Panel;
033
034public class UIPanel extends UIOutput {
035
036    private String identifier;
037
038    private String url;
039
040    private String loading;
041
042    private String stylesheet;
043
044    private String javascript;
045
046    private String subviews;
047
048    private String visibleInPerspectives;
049
050    private String controlledBy;
051
052    private String filter;
053
054    @Override
055    public void encodeAll(final FacesContext context) throws IOException {
056        final ResponseWriter writer = context.getResponseWriter();
057        Map<String, String> params = new HashMap<String, String>();
058        String applicationPath = context.getExternalContext().getRequestParameterMap().get(
059                "org.nuxeo.theme.application.path");
060        if (applicationPath == null) {
061            applicationPath = context.getExternalContext().getRequestContextPath();
062        }
063        params.put("org.nuxeo.theme.application.path", applicationPath);
064        params.put("org.nuxeo.theme.application.name", "");
065        Map<String, Object> attributes = getAttributes();
066        params.put("identifier", (String) attributes.get("identifier"));
067        params.put("url", (String) attributes.get("url"));
068        params.put("loading", (String) attributes.get("loading"));
069        params.put("stylesheet", (String) attributes.get("stylesheet"));
070        params.put("javascript", (String) attributes.get("javascript"));
071        params.put("subviews", (String) attributes.get("subviews"));
072        params.put("visibleInPerspectives", (String) attributes.get("visibleInPerspectives"));
073        params.put("controlledBy", (String) attributes.get("controlledBy"));
074        params.put("filter", (String) attributes.get("filter"));
075        writer.write(Panel.render(params));
076    }
077
078    public String getControlledBy() {
079        return controlledBy;
080    }
081
082    public void setControlledBy(final String controlledBy) {
083        this.controlledBy = controlledBy;
084    }
085
086    public String getIdentifier() {
087        return identifier;
088    }
089
090    public void setIdentifier(final String identifier) {
091        this.identifier = identifier;
092    }
093
094    public String getJavascript() {
095        return javascript;
096    }
097
098    public void setJavascript(final String javascript) {
099        this.javascript = javascript;
100    }
101
102    public String getStylesheet() {
103        return stylesheet;
104    }
105
106    public void setStylesheet(final String stylesheet) {
107        this.stylesheet = stylesheet;
108    }
109
110    public String getSubviews() {
111        return subviews;
112    }
113
114    public void setSubviews(final String subviews) {
115        this.subviews = subviews;
116    }
117
118    public String getUrl() {
119        return url;
120    }
121
122    public void setUrl(final String url) {
123        this.url = url;
124    }
125
126    public String getVisibleInPerspectives() {
127        return visibleInPerspectives;
128    }
129
130    public void setVisibleInPerspectives(final String visibleInPerspectives) {
131        this.visibleInPerspectives = visibleInPerspectives;
132    }
133
134    public String getLoading() {
135        return loading;
136    }
137
138    public void setLoading(String loading) {
139        this.loading = loading;
140    }
141
142    public String getFilter() {
143        return filter;
144    }
145
146    public void setFilter(String filter) {
147        this.filter = filter;
148    }
149
150}