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

org.ajax4jsf.framework.ajax.xmlfilter.ResponsePrintWriter 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.ajax.xmlfilter;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;

import javax.faces.component.UIComponent;
import javax.faces.context.ResponseWriter;

/**
 * @author shura
 * 
 * Hacked Adapter for HttpServletResponse - handle SAX like events, do
 * unbuffered translation to CocoonResponseWriter
 *  
 */
public class ResponsePrintWriter extends PrintWriter {

    private SAXResponseWriter responseWriter;

    /**
     * @param out
     */
    public ResponsePrintWriter(SAXResponseWriter out) {
        super(out, true);
        this.responseWriter = out;
        // TODO Auto-generated constructor stub
    }

    /**
     * @param writer
     * @return
     */
    public ResponseWriter cloneWithWriter(Writer writer) {
        return this.responseWriter.cloneWithWriter(writer);
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.io.PrintWriter#close()
     */
    public void close() {
        try {
            this.responseWriter.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            // e.printStackTrace();
        }
    }

    /**
     * @throws java.io.IOException
     */
    public void endDocument() throws IOException {
        this.responseWriter.endDocument();
    }

    /**
     * @param name
     * @throws java.io.IOException
     */
    public void endElement(String name) throws IOException {
        this.responseWriter.endElement(name);
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.io.PrintWriter#flush()
     */
    public void flush() {
        try {
            this.responseWriter.flush();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            // e.printStackTrace();
        }
    }

    /**
     * @return
     */
    public String getCharacterEncoding() {
        return this.responseWriter.getCharacterEncoding();
    }

    /**
     * @return
     */
    public String getContentType() {
        return this.responseWriter.getContentType();
    }

    /**
     * @throws java.io.IOException
     */
    public void startDocument() throws IOException {
        this.responseWriter.startDocument();
    }

    /**
     * @param name
     * @param component
     * @throws java.io.IOException
     */
    public void startElement(String name, UIComponent component)
            throws IOException {
        this.responseWriter.startElement(name, component);
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.io.PrintWriter#write(char[])
     */
    public void write(char[] cbuf) {
        try {
            this.responseWriter.write(cbuf);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            // e.printStackTrace();
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.io.PrintWriter#write(char[], int, int)
     */
    public void write(char[] cbuf, int off, int len) {
        try {
            this.responseWriter.write(cbuf, off, len);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            // e.printStackTrace();
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.io.PrintWriter#write(int)
     */
    public void write(int c) {
        try {
            this.responseWriter.write(c);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            // e.printStackTrace();
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.io.PrintWriter#write(java.lang.String)
     */
    public void write(String str) {
        try {
            this.responseWriter.write(str);
        } catch (IOException e) {
            // e.printStackTrace();
        }
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.io.PrintWriter#write(java.lang.String, int, int)
     */
    public void write(String str, int off, int len) {
        try {
            this.responseWriter.write(str, off, len);
        } catch (IOException e) {
            //e.printStackTrace();
        }
    }

    /**
     * @param name
     * @param value
     * @param property
     * @throws java.io.IOException
     */
    public void writeAttribute(String name, Object value, String property)
            throws IOException {
        this.responseWriter.writeAttribute(name, value, property);
    }

    /**
     * @param comment
     * @throws java.io.IOException
     */
    public void writeComment(Object comment) throws IOException {
        this.responseWriter.writeComment(comment);
    }

    /**
     * @param text
     * @param off
     * @param len
     * @throws java.io.IOException
     */
    public void writeText(char[] text, int off, int len) throws IOException {
        this.responseWriter.writeText(text, off, len);
    }

    /**
     * @param text
     * @param property
     * @throws java.io.IOException
     */
    public void writeText(Object text, String property) throws IOException {
        this.responseWriter.writeText(text, property);
    }

    /**
     * @param name
     * @param value
     * @param property
     * @throws java.io.IOException
     */
    public void writeURIAttribute(String name, Object value, String property)
            throws IOException {
        this.responseWriter.writeURIAttribute(name, value, property);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy