1

My Value 'image_id' from a f:param tag returns null.

JSF SITE

    <p:dataGrid value="#{main.game.cards}" var="cad" columns="3"
                            rows="12" paginator="true"
                            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                            rowsPerPageTemplate="5,10,25, 50, 100"> 
                            <p:panel header="Nr. #{cad.id}">
                                    <f:param name="image_id" id="image_id" value="#{cad.id}"></f:param>
                                <p:graphicImage cache="true" value="#{main.fileContent}">

                                </p:graphicImage>    

                            </p:panel>
                        </p:dataGrid>  

</h:form>

Trying to read the Value:

ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    String photoId = externalContext.getRequestParameterMap().get("image_id");
Lukas Eichler
  • 5,689
  • 1
  • 24
  • 43

1 Answers1

3

The <f:param> has to go inside the <p:graphicImage>, but in your code you've placed it outside. Fix it accordingly.

It would by the way only be sent (and thus be non-null) when the webbrowser requests the image, not when JSF is about to generate the <img> element. So the #{main.fileContent} getter will be invoked twice for a single image: the first time when the HTML is to be generated and the second time when the webbrowser actually requests the image.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555