Create new RichFaces Documentation Jira issue

This will launch the RichFaces Jira page - to complete your feedback please login if needed, and submit the Jira.

JBoss.orgCommunity Documentation

6.10.2.  < rich:paint2D > available since 3.0.0

expand all Description Key Features Details of Usage Reference Data Relevant Resources Links

Create image by painting from a managed bean method, same as "paint" (Graphics2D) in "SWING" components.

The example shows two main attributes of the component:

The "format" attribute of the component defines a format of visual data passing to the server.

Generated data can be used as a cacheable or non-cacheable resource. It's defined with "cacheable" attribute. If cache support is turned on, a key is created in URI with a mix of size (width/height), "paint" method, "format" and "data" attributes.


public void paint(Graphics2D g2, Object obj) {
        // code that gets data from the data Bean (PaintData)
       PaintData data = (PaintData) obj;
        // a code drawing a rectangle
        g2.drawRect(0, 0, data.Width, data.Height);
        // some more code placing graphical data into g2 stream below
public class PaintData implements Serializable{
        private static final long serialVersionUID = 1L;
        Integer Width=100;
        Integer Height=50;
&lt;rich:paint2D paint="#{paint2D.paint}" data="#{}"/&gt;

Table of <rich:paint2D> attributes.

On the component LiveDemo page you can see the example of <rich:paint2D> usage and sources for the given example.