/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see
tag.
*
* @author Arseny Kovalchuk
*
* @see org.alfresco.web.bean.wcm.CreateWebsiteWizard
* @see org.alfresco.web.bean.wcm.CreateFormWizard
*/
public class DescriptionAttributeHelper
{
static final String BLANK = "";
static final String TABLE_BEGIN = "
Localised field name: Field value
*/
public static String getTableLine(FacesContext fc, String fieldName, String fieldValue)
{
return getTableLine(fc, fieldName, fieldValue, true);
}
/**
*
* @param fc Current FacesContext
* @param fieldName Field name
* @param fieldValue Field value
* @param encode Whether to encode the given value or not
* @return Returns a table line Localised field name: Field value
*/
public static String getTableLine(FacesContext fc, String fieldName, String fieldValue, boolean encode)
{
StringBuilder line = new StringBuilder(128);
line.append(TRTD_BEGIN).append(Application.getMessage(fc, fieldName)).append(TD_TD);
if (encode)
{
line.append(Utils.encode(fieldValue));
}
else
{
line.append(fieldValue);
}
line.append(TDTR_END);
return line.toString();
}
/**
*
* @return Returns an ending HTML table tags
*/
public static String getTableEnd()
{
return TABLE_END;
}
/**
*
* @param fc Current FacesContext
* @param fieldValue Field value
* @return Returns localised "description_not_set" message if fieldValue is empty.
*/
public static String getDescriptionNotEmpty(FacesContext fc, String fieldValue)
{
return StringUtils.isEmpty(fieldValue) ?
SPAN_ITALIC_BEGIN + Application.getMessage(fc, "description_not_set") + SPAN_END :
Utils.encode(fieldValue);
}
}