Create dynamically 'p:graphicImage & p:galleria'

UI Components for JSF
Post Reply
NOTiFY
Posts: 272
Joined: 25 May 2016, 22:57
Location: Cambridge, UK
Contact:

21 Jan 2021, 14:11

My test with 'Galleria' & 'GraphicImage' works fine, using a 'static' URL of the location of all my PNG are deployed in my EAR (JAR + WAR):

Code: Select all

webapp/resources/images/MotoGuzzi/2021/gu9k32808euh01-01-m.png

Code: Select all

<p:galleria value="#{imagesController.images}" var="image" panelWidth="1500" panelHeight="1000" showCaption="true">
    <p:graphicImage name="images/MotoGuzzi/2021/#{image}" alt="Image Description for #{image}" title="#{image}"/>
</p:galleria>

Code: Select all

@PostConstruct
public void init() {
    images = new ArrayList<String>();

    images.add("gu9032272eul01-01-m.png");
    images.add("gu9k32117euk05-01-m.png");
    images.add("gu9k32117euk06-01-m.png");
    
    ... etc.

    LOGGER.info(">>>>> ImagesController init images = {}", images.size());
}

public List<String> getImages() {
    LOGGER.info("***** ImagesController List images = {}", images);

    return images;
}
I now want to deploy 1,000s of PNGs/JPEGs within my database (MongoDB/GridFS) which can be used by a CRUD tool.

Can PF GraphicImage be used with dynamic images rather than hard coded in the 'webapp'?

TIA
Last edited by NOTiFY on 06 Apr 2021, 14:18, edited 7 times in total.
PrimeFace (Elite) 10.0.6
Mojarra JSF 2.3.14.SP04 & OmniFaces 3.11.1

WildFly 24.0.1.Final Weld 4.0.1 (Final) & CDI 3.0
Java OpenJDK 17, Kotlin 1.5.30, Gradle (Kotlin) 7.1.1, MongoDB 5.0.2
IntelliJ IDEA 2021.2.1, macOS Big Sur 11.6

tandraschko
PrimeFaces Core Developer
Posts: 3855
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

21 Jan 2021, 15:55

Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

NOTiFY
Posts: 272
Joined: 25 May 2016, 22:57
Location: Cambridge, UK
Contact:

29 Jan 2021, 14:19

tandraschko wrote:
21 Jan 2021, 15:55
This may help you: https://primefaces.github.io/primefaces ... nt-support
Thanks for pointing towards 'Iterating component support' & 'Pass parameters to the resource request'. I'm unable to get my x PNGs displayed on using: p:galleria, p:graphicImage, f:param or ui:repeat.

It works fine if I have all my PNGs in 'webapp' as I mentioned @:

Code: Select all

webapp/resources/images/MotoGuzzi/2021/gu9k32808euh01-01-m.png
Do you have an example similar to:

https://www.primefaces.org/showcase/ui/ ... fwid=dd615

but using: say 'x number of PNGs' located at an URL.
PrimeFace (Elite) 10.0.6
Mojarra JSF 2.3.14.SP04 & OmniFaces 3.11.1

WildFly 24.0.1.Final Weld 4.0.1 (Final) & CDI 3.0
Java OpenJDK 17, Kotlin 1.5.30, Gradle (Kotlin) 7.1.1, MongoDB 5.0.2
IntelliJ IDEA 2021.2.1, macOS Big Sur 11.6

NOTiFY
Posts: 272
Joined: 25 May 2016, 22:57
Location: Cambridge, UK
Contact:

07 Feb 2021, 17:24

Have tried to use the (various) examples listed on 'Stack Overflow' &:

https://primefaces.github.io/primefaces ... nt-support

https://stackoverflow.com/questions/820 ... es#tab-top

I can't get it to display my 'png' on:

Code: Select all

<h3>Galleria 3</h3>
<p:galleria value="#{imagesStreamedContentController.streamedContent}" var="streamedContent" panelWidth="1500" panelHeight="1000" showCaption="true">
   <p:graphicImage value="/Users/NOTiFY/IdeaProjects/GoStopHandle/images/MotoGuzzi/2021/#{streamedContent}" title="#{bufferedImages}" alt="Image Description = #{streamedContent}"/>
</p:galleria>
on:

Code: Select all

public StreamedContent getStreamedContent() {
   streamedContent = DefaultStreamedContent.builder()
       .contentType("image/png")
       .stream(() -> {
          FacesContext context = FacesContext.getCurrentInstance();
          String bufferedImages = context.getExternalContext().getRequestParameterMap().get("/Users/NOTiFY/IdeaProjects/GoStopHandle/images/MotoGuzzi/2021/");
          return this.getClass().getResourceAsStream("/Users/NOTiFY/IdeaProjects/GoStopHandle/images/MotoGuzzi/2021/" + bufferedImages + ".png");
         })
       build();

       return streamedContent;
 }
Relates to an issue with: 'because of underlying class loading error: Type org.primefaces.model.StreamedContent'

Code: Select all

15:14:22,226 INFO  [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 15) WELD-000119: Not generating any bean definitions from com.gostophandle.controller.ImagesStreamedContentController because of underlying class loading error: Type org.primefaces.model.StreamedContent from [Module "deployment.GoStopHandle.ear.GoStopHandleJAR.jar" from Service Module Loader] not found.  If this is unexpected, enable DEBUG logging to see the full error.
TIA?
PrimeFace (Elite) 10.0.6
Mojarra JSF 2.3.14.SP04 & OmniFaces 3.11.1

WildFly 24.0.1.Final Weld 4.0.1 (Final) & CDI 3.0
Java OpenJDK 17, Kotlin 1.5.30, Gradle (Kotlin) 7.1.1, MongoDB 5.0.2
IntelliJ IDEA 2021.2.1, macOS Big Sur 11.6

NOTiFY
Posts: 272
Joined: 25 May 2016, 22:57
Location: Cambridge, UK
Contact:

10 Feb 2021, 14:19

If I create the 24 x PNGs start with:

Code: Select all

private static final String PNG = "/Users/NOTiFY/IdeaProjects/GoStopHandle/images/MotoGuzzi/2021/";

Code: Select all

bufferedImages.add(ImageIO.read(new File(PNG + "gu9032272eul01-01-m.png")));
And display @ my 'Galleria 2 & 3':

Code: Select all

public List<BufferedImage> getBufferedImages() {
   LOGGER.info(">>>>> ImagesStreamedContentController bufferedImages = {}", bufferedImages);

   return bufferedImages;
}

Code: Select all

<h3>Galleria 2</h3>
<p:galleria value="#{imagesStreamedContentController.bufferedImages}" var="bufferedImages" panelWidth="1500" panelHeight="1000" showCaption="true">
   <p:graphicImage value="/Users/NOTiFY/IdeaProjects/GoStopHandle/images/MotoGuzzi/2021/#{bufferedImages}" title="#{bufferedImages}" alt="Image Description = #{bufferedImages}">

   </p:graphicImage>
</p:galleria>
In 'Galleria 2' - This lets to 'move' & display 'p:galleria' & 'p:graphicImage' but can't display the actual PNG. Any pointers to what I'm doing incorrectly?

Image
Image
PrimeFace (Elite) 10.0.6
Mojarra JSF 2.3.14.SP04 & OmniFaces 3.11.1

WildFly 24.0.1.Final Weld 4.0.1 (Final) & CDI 3.0
Java OpenJDK 17, Kotlin 1.5.30, Gradle (Kotlin) 7.1.1, MongoDB 5.0.2
IntelliJ IDEA 2021.2.1, macOS Big Sur 11.6

NOTiFY
Posts: 272
Joined: 25 May 2016, 22:57
Location: Cambridge, UK
Contact:

15 Feb 2021, 19:54

The only way I could get an URL 'graphicImage' work was to switch 'p:graphicImage' to Omnifaces: 'o:graphicImage' (@balusc)

Maybe another instance of PF on WildFly with Mojarra JSF 2.3.14.SP02 etc.

Code: Select all

<o:graphicImage value="#{imagesStreamedContentController.image}" dataURI="true" style="width:100%;height:100%" cache="false" />

Code: Select all

public InputStream getImage() throws FileNotFoundException {
   return new FileInputStream(new File("/Users/NOTiFY/IdeaProjects/GoStopHandle/images/MotoGuzzi/2021/gu9032272eul01-01-m.png"));
}
PrimeFace (Elite) 10.0.6
Mojarra JSF 2.3.14.SP04 & OmniFaces 3.11.1

WildFly 24.0.1.Final Weld 4.0.1 (Final) & CDI 3.0
Java OpenJDK 17, Kotlin 1.5.30, Gradle (Kotlin) 7.1.1, MongoDB 5.0.2
IntelliJ IDEA 2021.2.1, macOS Big Sur 11.6

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests