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: LayoutTagLibrary.java 28493 2008-01-04 19:51:30Z sfermigier $ 020 */ 021 022package org.nuxeo.ecm.platform.forms.layout.facelets.library; 023 024import java.util.List; 025 026import org.apache.commons.logging.Log; 027import org.apache.commons.logging.LogFactory; 028import org.nuxeo.ecm.platform.forms.layout.api.FieldDefinition; 029import org.nuxeo.ecm.platform.forms.layout.api.Layout; 030import org.nuxeo.ecm.platform.forms.layout.api.LayoutRow; 031import org.nuxeo.ecm.platform.forms.layout.api.WidgetTypeDefinition; 032import org.nuxeo.ecm.platform.forms.layout.functions.LayoutFunctions; 033import org.nuxeo.ecm.platform.forms.layout.service.WebLayoutManager; 034import org.nuxeo.ecm.platform.ui.web.tag.fn.Functions; 035import org.nuxeo.runtime.api.Framework; 036 037/** 038 * Layout tag library. 039 * <p> 040 * Since 7.4, only holds JSF functions for the nxl tag library. 041 * 042 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 043 */ 044public class LayoutTagLibrary { 045 046 private static final Log log = LogFactory.getLog(LayoutTagLibrary.class); 047 048 // JSF functions 049 050 public static WidgetTypeDefinition getWidgetTypeDefinition(String typeName) { 051 WebLayoutManager layoutService = Framework.getService(WebLayoutManager.class); 052 return layoutService.getWidgetTypeDefinition(typeName); 053 } 054 055 /** 056 * Returns a String representing each of the field definitions property name, separated by a space. 057 */ 058 public static String getFieldDefinitionsAsString(FieldDefinition[] defs) { 059 return LayoutFunctions.getFieldDefinitionsAsString(defs); 060 } 061 062 public static List<LayoutRow> getSelectedRows(Layout layout, List<String> selectedRowNames, 063 boolean showAlwaysSelected) { 064 return LayoutFunctions.getSelectedRows(layout, selectedRowNames, showAlwaysSelected); 065 } 066 067 public static List<LayoutRow> getNotSelectedRows(Layout layout, List<String> selectedRowNames) { 068 return LayoutFunctions.getNotSelectedRows(layout, selectedRowNames); 069 } 070 071 public static List<String> getDefaultSelectedRowNames(Layout layout, boolean showAlwaysSelected) { 072 return LayoutFunctions.getDefaultSelectedRowNames(layout, showAlwaysSelected); 073 } 074 075 /** 076 * Joins two strings to get a valid reRender attribute for ajax components. 077 * 078 * @since 5.7 079 * @deprecated since 6.0: use {@link #joinRender(String, String)} instead. 080 */ 081 @Deprecated 082 public static String joinReRender(String render1, String render2) { 083 log.warn("Method nxl:joinReRender is deprecated, use nxu:joinRender instead"); 084 return Functions.joinRender(render1, render2); 085 } 086 087}