All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ajax4jsf.framework.resource.LogfileRenderer Maven / Gradle / Ivy

Go to download

Ajax4jsf is an open source extension to the JavaServer Faces standard that adds AJAX capability to JSF applications without requiring the writing of any JavaScript.

The newest version!
/**
 * 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;

import java.io.IOException;
import java.io.InputStream;

import javax.faces.context.FacesContext;

/**
 * @author shura (latest modification by $Author: sergeysmirnov $)
 * @version $Revision: 1.1 $ $Date: 2006/04/28 02:03:20 $
 *
 */
public class LogfileRenderer extends BaseResourceRenderer {

	/* (non-Javadoc)
	 * @see org.ajax4jsf.framework.resource.BaseResourceRenderer#getTag()
	 */
	protected String getTag() {
		// TODO Auto-generated method stub
		return "pre";
	}

	/* (non-Javadoc)
	 * @see org.ajax4jsf.framework.resource.BaseResourceRenderer#getHrefAttr()
	 */
	protected String getHrefAttr() {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see org.ajax4jsf.framework.resource.BaseResourceRenderer#getCommonAttrs()
	 */
	protected String[][] getCommonAttrs() {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see org.ajax4jsf.framework.resource.ResourceRenderer#getContentType()
	 */
	public String getContentType() {
		// TODO Auto-generated method stub
		return "text/plain";
	}
	/* (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());
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy