ajax - 素面 : GraphicImage does not refresh

标签 ajax primefaces

我想要一个按钮和一个图形图像。默认情况下,不显示图形图像。如果用户单击该按钮,则会显示图形图像(呈现 = 真)。

我可以做到,但我必须刷新页面才能看到显示的图形图像。

我想我必须使用 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>

托管 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"。现在,图片直接显示出来了。

关于ajax - 素面 : GraphicImage does not refresh,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19305719/

相关文章:

css - Primefaces 菜单栏垂直分隔符

java - 在 primefaces 时间表上每天显示可编辑的事件

jsf - java.lang.NoClassDefFoundError : org/atmosphere/cpr/AsyncSupportListenerAdapter 错误

php - PHP Ajax开发环境的建议

php - Ajax 自动完成 - 如何使其更快?

ajax - 计算属性的异步调用 - Vue.js

jsf-2 - 如何在primefaces的数据表中迭代Map<String,Collection>

css - 更改 primefaces Accordion 图标

ajax - Angular Datatables 使用源对象

jquery ajax加载图片在IE中不显示