Primefaces : GraphicImage 不刷新 [英] Primefaces : GraphicImage does not refresh
问题描述
我想要一个按钮和一个图形图像.默认情况下,不显示图形图像.如果用户单击按钮,则显示图形图像(rendered = true).
I waant to have abutton and a graphicimage. By default, the graphicimage is not displayed. If the user click on the button, the graphic image is displayed (rendered = true).
我可以做到,但我必须刷新页面才能看到显示的图形图像.
I can do it but I have to refresh the page to see the graphicimage displayed.
我想我必须使用ajax组件才能在单击按钮时直接显示,但我无法正确使用它.你能指导我吗?
I think I have to use ajax component to make the displaying directly when the button is clicked but I don't manage to use it corectly. Could you guide me?
xhtml:
<h:body>
<h:form>
<p:commandButton value="Prendre la photo générique"
id="boutonPhotoGenerique" icon="ui-icon-image"
action="#{defaultCommandBean.affichePhotoGenerique}">
<p:graphicImage id="photoGenerique"
rendered="#{defaultCommandBean.rendered}"
value="photos/photo_generique.jpg" />
</p:commandButton>
</h:form>
</h:body>
托管 Bean:
@ManagedBean(name = "defaultCommandBean")
@SessionScoped
public class DefaultCommandBean {
private boolean rendered;
public boolean isRendered() {
return rendered;
}
public void setRendered(boolean rendered) {
this.rendered = rendered;
}
public void affichePhotoGenerique() {
rendered = true;
}
}
推荐答案
我发现了问题:我用一个面板组件包围了我的graphicImage组件,带有 id="panel" ;并将我的更新属性修改为 update="panel" .现在,图片直接显示.
I found the problem : I surrounded my graphicImage component with a panel component, with id="panel" ; and modified my update attribute to update="panel" . Now, the picture is directy displayed.
这篇关于Primefaces : GraphicImage 不刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!