0

I have the following datatable:

<p:dataTable id="persons" styleClass="hide-column-names personTable"
            value="#{personListDisplayerBean.allPersonsModel}" var="person"
            paginator="true" rows="25"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
            rowsPerPageTemplate="5,10,25,50,100"
            selection="#{personDetailsDisplayerBean.selectedPerson}"
            filteredValue="#{personListDisplayerBean.filteredPersons}"
            selectionMode="single" widgetVar="personTable">

            ...
            ...

            <p:column styleClass="person-list-image-column">
                <p:graphicImage styleClass="thumbnail"
                    value="#{personListDisplayerBean.getImageForPerson(person)}" />

            </p:column>
           ...
           ...

</p:dataTable>

(Made it a little shorter)

Now to my problem: The Method getImageForPerson is invoked twice. The reason why is explained in this post here:

Display dynamic image from database with p:graphicImage and StreamedContent

The first time invoking everything is fine, but the second time it is invoke i only receive a null as Parameter...

The method itself looks something like this:

String fileName = person.getObjectGUID();
File f = new File(fileName + ".jpg");
FileInputStream inputStream;
try {
   inputStream = new FileInputStream(f);
} catch (FileNotFoundException e) {
   return new DefaultStreamedContent();
}
stream = new DefaultStreamedContent(inputStream,"image/jpg");
return stream;

Why does JSF give me a null as parameter the second time the Method is invoked? Can i overcome this problem somehow?

Thanks in advance :)

Community
  • 1
  • 1
Rittel
  • 519
  • 4
  • 19
  • This is a duplicate of http://stackoverflow.com/questions/16991143/dynamic-images-in-datatable-using-primefaces-images-not-showing-in-datatable/, but I can't vote for close with this duplicate because the stupid close system which doesn't take niche tags into account complains that this dupe doesn't have an upvoted answer. – BalusC Aug 21 '13 at 13:02
  • Summarized: your concrete problem is caused because you tried to do things differently from what's been mentioned in the solution you found. I'd suggest to not do that anymore in the future unless you really understand "under the covers" workings. – BalusC Aug 21 '13 at 13:03
  • wow that was fast :D Thanks Should i delete the question now? Am kinda new here... – Rittel Aug 21 '13 at 13:04

0 Answers0