org.ajax4jsf.framework.resource.StyleRenderer Maven / Gradle / Ivy
/**
* Licensed under the Common Development and Distribution License,
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.sun.com/cddl/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package org.ajax4jsf.framework.resource;
/**
* Render style element with content in page. Warning - not use for head link element,
* it must be rendered separate.
* @author [email protected] (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.4 $ $Date: 2006/07/29 11:49:05 $
*
*/
public class StyleRenderer extends OneTimeRenderer {
/* (non-Javadoc)
* @see org.ajax4jsf.framework.resource.BaseResourceRenderer#getTag()
*/
protected String getTag() {
// TODO Auto-generated method stub
return "link";
}
/* (non-Javadoc)
* @see org.ajax4jsf.framework.resource.BaseResourceRenderer#getHrefAttr()
*/
protected String getHrefAttr() {
// TODO Auto-generated method stub
return "href";
}
/* (non-Javadoc)
* @see org.ajax4jsf.framework.resource.BaseResourceRenderer#getCommonAttrs()
*/
protected String[][] getCommonAttrs() {
// TODO Auto-generated method stub
return new String[][]{{"type","text/css"},{"rel","stylesheet"}};
}
/* (non-Javadoc)
* @see org.ajax4jsf.framework.resource.ResourceRenderer#getContentType()
*/
public String getContentType() {
// TODO use configurable encoding ?
return "text/css";
}
/* (non-Javadoc)
* @see org.ajax4jsf.framework.resource.BaseResourceRenderer#customEncode(org.ajax4jsf.framework.resource.InternetResource, javax.faces.context.FacesContext, java.lang.Object)
*/
/*
protected void customEncode(InternetResource resource, FacesContext context, Object data) throws IOException {
// Encode style in page - read from resource.
ResourceContext resourceContext = new FacesResourceContext(context);
InputStream in = resource.getResourceAsStream(resourceContext);
StringBuffer buff = new StringBuffer();
int input;
while((input = in.read())>0){
buff.append((char)input);
}
in.close();
// MyFaces & RI have different beahvior for style element, in RI best use writeComment ?
// TODO - detect page content type ?
context.getResponseWriter().writeText(buff,resource.getKey());
}
*/
}