Component identification parameters

Name | Value
--- | ---
component-type | org.ajax4jsf.MediaOutput
component-family | org.ajax4jsf.Resource
component-class | org.ajax4jsf.component.html.MediaOutput
renderer-type | org.ajax4jsf.MediaOutputRenderer

## Creating on a page

To use the component it's necessary to define it on a page and set Java methods for data keeping and data transmission to output stream.

Component definition on a page for graphical data output

Example:

    ...
    <a4j:mediaOutput element="img" cacheable="false" session="true"
        createContent="#{paintBean.paint}" value="#{paintData}"
        mimeType="image/jpeg"/>
    ...

Here is the content of paintData that is a bean containing output data

Example:

    package demo;

    public class PaintData implements Serializable{
            private static final long serialVersionUID = 1L;
            Integer width=100;
            Integer weight=50;
    ...

The Paint method of the paintBean class is a method transmitting graphical data into output stream.

Example:

    public void paint(OutputStream out, Object data) throws IOException{
    	<!--...Some code that puts binary data to "out" Stream-->
            }

## Dynamical creation of a component from Java code

Example:

    import org.ajax4jsf.component.html.MediaOutput;
    ...
    MediaOutput myMedia = new MediaOutput ();
    ...

## Key attributes and ways of usage

As it was shown in the example above there are two main components:

- "createContent" specifies a method accepting 2 parameters. The first (of java.io.OutputStream type) defines a stream, where any binary data is output. The second (of java.lang.Object type) contains deserialized object with data specified in the "value" attribute.
- Value specifies a bean class keeping data for transmitting into a method that transmits it into a stream.

Note:

A bean class transmitted into value should implement Serializable interface.

Hence, when using the component it's possible to output your data of any type on a page with Ajax requests.

## Relevant resources links

Here you can see the example of <a4j:mediaOutput > usage and sources for the given example.