Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <p:panelGrid columns="2" styleClass="ui-panelgrid-blank">
- <p:outputLabel value="#{msg.image}: " for="image" />
- <p:graphicImage id="image" value="#{mbImageStreamer.initialInspectionImage}"
- width="200">
- <f:param name="id" value="#{initialInspectionController.initialInspectionCurrent.initialInspectionImage.id}" />
- </p:graphicImage>
- </p:panelGrid>
- @ManagedBean(name = "mbImageStreamer")
- @ApplicationScoped
- public class ImageStreamer {
- @EJB
- private ImageService service;
- public StreamedContent getInitialInspectionImage() throws IOException {
- FacesContext context = FacesContext.getCurrentInstance();
- if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
- return new DefaultStreamedContent();
- } else {
- String imageId = context.getExternalContext().getRequestParameterMap().get("id");
- InitialInspectionImage image = service.findInitialInspectionImage(Integer.valueOf(imageId));
- return new DefaultStreamedContent(new ByteArrayInputStream(image.getImage()));
- }
- }
- }
Add Comment
Please, Sign In to add comment