简体   繁体   English

f:param返回null?

[英]f:param returns null?

My Value 'image_id' from af:param tag returns null. 我的值'image_id'来自af:param标签返回null。

JSF SITE JSF网站

    <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");

The <f:param> has to go inside the <p:graphicImage> , but in your code you've placed it outside. <f:param>必须进入<p:graphicImage> ,但在你的代码中你已将它放在外面。 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. 顺便说一下,当webbrowser请求图像时,它不会被发送(因此是非null ),而不是在JSF即将生成<img>元素时。 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. 因此, #{main.fileContent} getter将针对单个图像调用两次:第一次生成HTML时,第二次是webbrowser实际请求图像。

See also: 也可以看看:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM