:?: Dyanmic Image not work in portlet

UI Components for JSF
Post Reply
ericmacau
Posts: 17
Joined: 09 Jun 2010, 06:22

06 Jan 2012, 09:13

Hello,

I tried to use the same code of Dynamic Image in the showcase to the Liferay portlet.
But no image can be displayed.

Code: Select all

Primefaces 3.0
Portletfaces-portletbridge-2.0.1
Liferay 6.0.6
Java 6

Code: Select all

<p:graphicImage value="#{imageController.graphicText}" cache="false"/>  

Code: Select all

@ManagedBean(name="imageController")
@RequestScoped
public class ImageStreamController {
	
	private StreamedContent graphicText;
	
	public ImageStreamController() {
		try {
			BufferedImage bufferedImg = new BufferedImage(100, 25, BufferedImage.TYPE_INT_RGB);  
	               Graphics2D g2 = bufferedImg.createGraphics();  
	               g2.drawString("This is a text", 0, 10);  
	              ByteArrayOutputStream os = new ByteArrayOutputStream();  
	              ImageIO.write(bufferedImg, "jpg", os);  
	              graphicText = new DefaultStreamedContent(new ByteArrayInputStream(os.toByteArray()), "image/jpeg");  	        					        
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
		
	
	
		
	
	public StreamedContent getGraphicText() {
		System.out.println("...........YEAH");
		return graphicText;
	}





	public void setGraphicText(StreamedContent graphicText) {
		this.graphicText = graphicText;
	}
}

:?: :?: :?:

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 62 guests