Guest User

Untitled

a guest
Oct 19th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <p:panelGrid columns="2" styleClass="ui-panelgrid-blank">
  2. <p:outputLabel value="#{msg.image}: " for="image" />
  3. <p:graphicImage id="image" value="#{mbImageStreamer.initialInspectionImage}"
  4. width="200">
  5. <f:param name="id" value="#{initialInspectionController.initialInspectionCurrent.initialInspectionImage.id}" />
  6. </p:graphicImage>
  7. </p:panelGrid>
  8.  
  9. @ManagedBean(name = "mbImageStreamer")
  10. @ApplicationScoped
  11. public class ImageStreamer {
  12.  
  13. @EJB
  14. private ImageService service;
  15.  
  16. public StreamedContent getInitialInspectionImage() throws IOException {
  17. FacesContext context = FacesContext.getCurrentInstance();
  18.  
  19. if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
  20. return new DefaultStreamedContent();
  21. } else {
  22. String imageId = context.getExternalContext().getRequestParameterMap().get("id");
  23. InitialInspectionImage image = service.findInitialInspectionImage(Integer.valueOf(imageId));
  24. return new DefaultStreamedContent(new ByteArrayInputStream(image.getImage()));
  25. }
  26. }
  27. }
Add Comment
Please, Sign In to add comment