我很想要一张图解和一张图片。默认情况下,不显示图形图像。如果用户单击按钮,则显示图形图像(呈现= true)。
我可以这样做,但我必须刷新页面以查看所显示的图形图像。
我认为当单击按钮时,我必须使用ajax组件直接进行显示,但我无法正确地使用它。你能指引我吗?
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>管理豆:
@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;
}
}发布于 2013-10-13 15:04:47
我发现了这个问题:我用一个面板组件包围了我的graphicImage组件,使用了id=" panel“;并将我的update属性修改为update="panel”。现在,图片是直接显示。
发布于 2013-10-10 20:41:57
将graphicImage放在commandButton之外,并在按钮中声明update = 'photoGenerique'。如下所示:
<h:form>
<p:commandButton value="Prendre la photo générique" update="photoGenerique"
id="boutonPhotoGenerique" icon="ui-icon-image"
actionListener="#{defaultCommandBean.affichePhotoGenerique}">
</p:commandButton>
<p:graphicImage id="photoGenerique"
rendered="#{defaultCommandBean.rendered}"
value="photos/photo_generique.jpg" />
</h:form>https://stackoverflow.com/questions/19305719
复制相似问题