0

I’m having some trouble getting the primefaces dyanmic graphic image to display for a certain scenario where I’m trying to display an image on a facelet page (retrieved from a database) and the page is invoked by a URL (not h:commandLink). It works on other pages with requests processed through h:commandButton. However all the data but the image appears for the following scenario...

  1. fundraiseView.xml (facelet page) html ... p:graphicImage value="#{fundraisePage.picture}"/ ... /html

  2. FundraisePage (request scoped backing bean with request param)

    @ManagedBean @RequestScoped public class FundraisePage extends BackingBean { @EJB DataSBLocal dataSB; StreamedContent picture; @ManagedProperty(value="#{param.id}") private int id; @PostConstruct public void init() { this.fundRaiseEO = dataSB.getFundRaiseIndividual(id); InputStream inputStream = new ByteArrayInputStream(this.fundRaiseEO.getPicture()); this.setPicture(new DefaultStreamedContent(inputStream, "image/jpeg")); } 
  3. When I invoke the page via http://...../faces/fundraiseView.xml?id=1 the page returns displaying all the data for id 1 but without displaying the picture. I’m sure it has to do with how I’m calling the page (since I have it working else where) however I need it to be a request initiated outside a JSF wrapped tag.

Any insight or suggestions very much appreciated.

Thanks, Johnathan

1 Answer 1

1

Found the answer in another thread.

Loading a set of images with primefaces

I needed to use tag f:parm name="id" value="#{fundraisePage.id}" within the p:graphicImage tag so it accepts the id as a lookup param. As well change the value on image tag to this method in property...

public StreamedContent getImage () {

 FundRaise fundRaiseEO = new FundRaise(); fundRaiseEO = dataSB.getFundRaiseIndividual(id); return new DefaultStreamedContent(new ByteArrayInputStream(fundRaiseEO.getPicture()), "image/jpeg"); \\ or whatever your image mime type. 

}

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.