How to add 'binaries' to Galleria using Jakarta 10 & Faces 4.0?

UI Components for JSF
NOTiFY
Posts: 393
Joined: 25 May 2016, 22:57

12 Mar 2023, 22:05

Using: GraphicImage I could add a single binary image by:

Code: Select all

public InputStream getGraphicImage() throws IOException {

   ...
   
   return Files.newInputStream(Paths.get(stringBuffer.toString()));
}

Code: Select all

<p:graphicImage value="#{nOTiFYMotorcycleController.graphicImage}" stream="false"/>
I can't see how to add a "InputStream/byte[] array)" in "Galleria - Basic". I want to display a number of "Images" within a <List>?

The Doc doesn't show a 'binary' in: https://primefaces.github.io/primefaces ... s/galleria

TIA
Last edited by NOTiFY on 14 Apr 2023, 17:16, edited 9 times in total.
PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

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

13 Mar 2023, 10:21

if you combine this:
https://primefaces.github.io/primefaces ... collection

and

https://primefaces.github.io/primefaces ... ce-request

it should work (didnt try and no time to create a example)
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: 393
Joined: 25 May 2016, 22:57

13 Mar 2023, 10:52

The PF demo of Galleria shows using "galleriaView.photos":

Code: Select all

<p:galleria value="#{galleriaView.photos}" var="photo" numVisible="5" style="max-width: 640px">
In a Array List:

Code: Select all

private List<Photo> photos;
The "photo`' is just a Strings for "Galleria":

Code: Select all

private String itemImageSrc;
private String thumbnailImageSrc;
private String alt;
private String title;
To add "InputStream/byte[] array)" to "Galleria - Basic" I believe I really need something like:

Code: Select all

private InputStream itemImageSrc;
private InputStream thumbnailImageSrc;
private String alt;
private String title;
Added to an "ArrayList".

The two examples you've posted, I don't understand how to add a <List> of 'x' "p:galleria" (byte). Have you a demo of the "Dynamic Collection" -"galleriaBean.images"
PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

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

13 Mar 2023, 11:49

you have to understand what happens in my second link, thats the key.
In general you should completely read the whole page to understand: https://primefaces.github.io/primefaces ... miccontent
everything is explained there, why your apporach doesnt work.
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: 393
Joined: 25 May 2016, 22:57

13 Mar 2023, 15:49

Where/How do I store/add the URLs of the Images or the Image as a InputStream/StreamedContent?

Where in 'Galleria' hardcoded demo has a number of Images in a ArrayList.

IMO - I find the PF Documentation re GraphicImage/Galleria a little too terse for me. TIA.
PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

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

13 Mar 2023, 18:57

if you read my links carefully, you should be able to combine it. You can also check it: https://stackoverflow.com/questions/804 ... pdatatable
Doenst matter if ui:repeat and p:galleria

we just dont have enough time to create a example for everything. feel free to help to improve our samples or docs.
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: 393
Joined: 25 May 2016, 22:57

16 Mar 2023, 12:23

Doesn't matter if ui:repeat and p:galleria
Still confused.

Should/Can I use "ui:repeat" or with JSF 4.0 "<c:forEach>" with "p:galleria" ?

The example you referenced: https://stackoverflow.com/questions/804 ... pdatatable

Does't use "p:galleria" it has:

Code: Select all

private List<StreamedContent> allImages = new ArrayList <>();
So can I create my 1-999 'Images' be added to a 'List' and display them with <u:report> (<c:forEach>):

Code: Select all

<ui:repeat value="#{ImageLoader.allImages}" var="img"> 


When worked i'm happy to provide: "feel free to help to improve our samples or docs.".
PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

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

16 Mar 2023, 15:25

check the answer in stackoverflow, not the question.
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: 393
Joined: 25 May 2016, 22:57

17 Mar 2023, 11:54

Had a good look at "check the answer in stackoverflow, not the question" for:

https://stackoverflow.com/questions/804 ... pdatatable

JSF:

Code: Select all

<ui:repeat value="#{bean.images}" var="imageID">
    <p:graphicImage value="#{bean.image}">
         <f:param name="imageID" value="#{imageID}" />
    </p:graphicImage>
 </ui:repeat>
Managed Bean:

Code: Select all

public List<String> getImages() {
    List<String> l = new ArrayList<String>();
    for (Theme t : themeFacade.findAll())
        l.add(t.getId().toString());
    return l;
}

Code: Select all

public StreamedContent getImage() {
      FacesContext context = FacesContext.getCurrentInstance();
      HttpServletRequest myRequest = (HttpServletRequest) context.getExternalContext().getRequest();
      String imageID = (String) myRequest.getParameter("imageID");
      return new DefaultStreamedContent(new ByteArrayInputStream(themeFacade.find(Long.parseLong(imageID)).getImage()));
}
Do you know/suggest what "Theme (themeFacade)" should be?:

Code: Select all

Theme t:themeFacade
it should work (didnt try and no time to create a example)
Any chance of a simple sample that shows a "List" of 'images' on "Galleria"? TIA
PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

NOTiFY
Posts: 393
Joined: 25 May 2016, 22:57

22 Mar 2023, 16:16

@stackoverflow: https://stackoverflow.com/questions/757 ... f-galleria

"is EXACTLY your case but i had some minutes and ported this example to the primefaces showcase.... github.com/primefaces/primefaces/issues/9948 and no, i can't deploy it, that's up to primetek"

Thanks.
PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests