001/*
002 * (C) Copyright 2006-2013 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 *     <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
018 *
019 * $Id: WidgetTypeHandler.java 27477 2007-11-20 19:55:44Z jcarsique $
020 */
021
022package org.nuxeo.ecm.platform.forms.layout.facelets;
023
024import java.io.IOException;
025import java.util.Map;
026
027import javax.faces.component.UIComponent;
028import javax.faces.view.facelets.FaceletContext;
029import javax.faces.view.facelets.FaceletHandler;
030import javax.faces.view.facelets.TagConfig;
031import javax.faces.view.facelets.TagHandler;
032
033import org.nuxeo.ecm.platform.forms.layout.api.Widget;
034import org.nuxeo.ecm.platform.forms.layout.api.exceptions.WidgetException;
035
036/**
037 * Widget type handler interface.
038 *
039 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
040 */
041public abstract class WidgetTypeHandler extends TagHandler {
042
043    public WidgetTypeHandler(TagConfig config) {
044        super(config);
045    }
046
047    /**
048     * Returns the facelet handler that will be applied for given widget and template in this context.
049     *
050     * @param ctx the facelet context in which this handler will be applied.
051     * @param parent parent component in the JSF tree
052     * @param widget the widget giving properties the handler will take into account.
053     * @throws WidgetException
054     * @throws IOException
055     */
056    public abstract void apply(FaceletContext ctx, UIComponent parent, Widget widget) throws WidgetException,
057            IOException;
058
059    /**
060     * Returns the facelet handler used for dev mode.
061     *
062     * @since 6.0
063     */
064    public abstract FaceletHandler getDevFaceletHandler(TagConfig tagConfig, Widget widget) throws WidgetException;
065
066    /**
067     * Returns a property value given its name.
068     *
069     * @return property with this name.
070     */
071    public abstract String getProperty(String name);
072
073    /**
074     * Set properties
075     */
076    public abstract void setProperties(Map<String, String> properties);
077
078    public abstract void setWidget(Widget widget);
079
080}