重新呈现一个上传的图片(A4J:mediaOutput) [英] ReRender an uploaded image (a4j:mediaOutput)

查看:375
本文介绍了重新呈现一个上传的图片(A4J:mediaOutput)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示通过AJAX上传的图像(在A4J:mediaOuput标签)上载后,但我不能重新呈现在A4J:mediaOutput标签:

I would like to display an uploaded image via ajax (in a a4j:mediaOuput tag) after uploading but I can't rerender the a4j:mediaOutput tag:

< H:表单的enctype =的multipart / form-data的>     < A4J:jsFunction名=refreshPic重新呈现=picHolder/>     <电话号码:文件上传模式=高级fileLimit =1多重=假         allowTypes =/(\ | \ /)(GIF |?JPE G | PNG)$ /自动=真         fileUploadListener =#{createSopController.fileChanged}         的onComplete =refreshPic()/>     &所述; A4J:outputPanel的id =picHolder>         < A4J:mediaOutput ID =PIC元素=IMG缓存=假             createContent中=#{sessionImageBean.paint}             值=#{createSopBean.imageId}             MIMETYPE =#{createSopBean.sop.mimeType}WIDTH =672HEIGHT =1005/>     < / A4J:outputPanel> < /小时:形式GT;

<h:form enctype="multipart/form-data"> <a4j:jsFunction name="refreshPic" reRender="picHolder" /> <p:fileUpload mode="advanced" fileLimit="1" multiple="false" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" auto="true" fileUploadListener="#{createSopController.fileChanged}" oncomplete="refreshPic()" /> <a4j:outputPanel id="picHolder"> <a4j:mediaOutput id="pic" element="img" cacheable="false" createContent="#{sessionImageBean.paint}" value="#{createSopBean.imageId}" mimeType="#{createSopBean.sop.mimeType}" width="672" height="1005"/> </a4j:outputPanel> </h:form>

任何想法?

推荐答案

A4J:mediaOutput 需要一个不同的请求参数,为了不被缓存。为了这个目的,我preFER使用了最新的时间戳从范围管理的bean的应用程序。这就好比克服浏览器的缓存js和css文件,通过附加时间戳参数的URL。

a4j:mediaOutput requires a varying request parameter, in order not to be cached. for this purpose, i prefer to use up-to-date timestamp from an application scoped managed bean. this is just like overcoming browser cache for js and css files, by appending timestamp parameter to their url.

顺便说一句,你不渲染图像时需要使用此参数来任何东西。

btw, you don't need to to anything with this parameter when rendering the image.

<a4j:mediaOutput ... >
    <f:param value="#{appMB.timeStamp}" name="time" />
</a4j:mediaOutput>

这篇关于重新呈现一个上传的图片(A4J:mediaOutput)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆