/*
* xulfaces : bring XUL power to Java
*
* Copyright (C) 2005 Olivier SCHMITT
* This library 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 2.1 of the License, or (at your option) any later version.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.xulfaces.renderer.output;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xulfaces.renderer.XULRenderer;
public class OutputRenderer extends XULRenderer {
private static final Log log = LogFactory.getLog(OutputRenderer.class);
protected String getValueAsString(FacesContext facesContext,
UIOutput uiOutput) {
String value = null;
Converter converter = uiOutput.getConverter();
Object rawValue = uiOutput.getValue();
if (converter == null) {
if (rawValue != null) {
value = rawValue.toString();
}
} else {
value = converter.getAsString(facesContext, uiOutput, rawValue);
}
if (log.isDebugEnabled()) {
String mesg = "Component " + uiOutput.getClass().getName()
+ " " + uiOutput.getId();
log.debug(mesg + " ,converted value is " + value);
}
return value;
}
}