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 * <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 018 * 019 * $Id: ListWidgetTypeHandler.java 26053 2007-10-16 01:45:43Z atchertchian $ 020 */ 021 022package org.nuxeo.ecm.platform.forms.layout.facelets.plugins; 023 024import javax.faces.view.facelets.TagConfig; 025 026import org.nuxeo.ecm.platform.forms.layout.api.Widget; 027import org.nuxeo.runtime.api.Framework; 028import org.nuxeo.runtime.services.config.ConfigurationService; 029 030/** 031 * List widget type, using a fixed template. 032 * 033 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 034 */ 035public class ListWidgetTypeHandler extends TemplateWidgetTypeHandler { 036 037 public static final String COMPAT_TEMPLATE_PROPERTY_NAME = "compatTemplate"; 038 039 public ListWidgetTypeHandler(TagConfig config) { 040 super(config); 041 } 042 043 @Override 044 protected String getTemplateValue(Widget widget) { 045 ConfigurationService configurationService = Framework.getService(ConfigurationService.class); 046 boolean useCompat = configurationService.isBooleanPropertyTrue("nuxeo.jsf.listWidget.compatEnabled"); 047 if (useCompat) { 048 return lookupProperty(COMPAT_TEMPLATE_PROPERTY_NAME, widget); 049 } else { 050 return super.getTemplateValue(widget); 051 } 052 } 053 054}