1

I have a entity attribute String for input a link_logo in my form , i want just to know what can i write on the view for input the logo.

The Attribute on entity (agency):

 @Column(name = "Logo")
     private String link_logo;

My save method it worked and the bean too. I searched in the showcase but no result.

there is my view code now :

 <div class="ui-sm-12 ui-md-2 ui-lg-1">
                           <p:outputLabel value="Upload image:" for="img" />
                        </div>
                          <div class="ui-sm-12 ui-md-4 ui-lg-5" >
                        <p:graphicImage id="img" value="#{agenceFormBean.agence.link_logo}" style="width:100%" />

                         </div>

any solutions please ?

Jasper de Vries
  • 13,693
  • 6
  • 54
  • 86
laziale8
  • 39
  • 5
  • 1
    Confusing. Are you concretely asking how to upload a file or are you asking how to generate a HTML element and/or how to generate a HTML element? – BalusC Sep 27 '19 at 10:29
  • thank you for answer ,I just precised that I use SpringBoot, i just know how to insert a image on form in prmefaces. I said i have a StringAtrribut for this image ! – laziale8 Sep 27 '19 at 10:36
  • 1
    So your `private String link_logo` property contains an URL (e.g. `https://example.com/foo/bar.png`) and you ask how to display this in the browser using JSF? – Selaron Sep 27 '19 at 10:40
  • no @Selaron , i have a image on my desktop,and i want to insert it on a from view(primefaces) with the another field ,this image will be setting on a String attribut(link_logo), thank you ! – laziale8 Sep 27 '19 at 12:13
  • Read https://stackoverflow.com/questions/10073905/display-database-blob-images-in-pgraphicimage-inside-uirepeat or even better: https://stackoverflow.com/questions/8207325/display-dynamic-image-from-database-with-pgraphicimage-and-streamedcontent/12452144#12452144 – Kukeltje Sep 27 '19 at 16:59
  • 2
    You need to tell which value exactly the `link_logo` variable contains. You also need to tell where exactly the physical image file is stored. Then we can help you. Ultimately, the generated HTML `` element must have a `src` attribute which represents an URL to the image. That's how images work in basic HTML. If you already can't use a `` then you also can't do much with JSF because this is in the context of this problem merely a HTML code generator. – BalusC Sep 27 '19 at 17:21
  • thank you @BalusC for answer, link-logo its a String Value on the entity class,and the image is stocked on a folder in my desktop . now i want just insert it in the database . thank you so much – laziale8 Sep 30 '19 at 09:30
  • You did not understand me. I asked for the **exact** value and **exact** location. You still haven't answered this. Now still nobody can explain you how to do the math. I'll can only give you an advice: take a step back and learn how basic HTML `` works. Once you understand it, it will be much easier to understand how to use JSF to generate a HTML `` element. – BalusC Sep 30 '19 at 09:55
  • thank you so much @BalusC. now i upload the image correctly in a folder : public void handleFileUpload(FileUploadEvent event){ ExternalContext extContext = FacesContext.getCurrentInstance().getExternalContext(); File result = new File(extContext.getRealPath("//WEB-INF//images//"+event.getFile().getFileName())); my problem now its i have another method save() in my Form bean,and i want to upload this image with the form id . – laziale8 Sep 30 '19 at 12:14
  • Wow. You actually wanted to ask how to upload an image. You didn't want to ask how to display an image. – BalusC Sep 30 '19 at 12:18
  • yeah sorry if i wasn't clear before ! – laziale8 Sep 30 '19 at 12:18
  • thank you @BalusC, but i want to upload an image with form , i mean when i click on save the image will be saved on the id of this form object – laziale8 Sep 30 '19 at 12:44

1 Answers1

0

You can use this the show image with url

<p:graphicImage id="img" value="#{yourView.link_logo}" style="width:100%" />
Black
  • 5
  • 5