简体   繁体   English

为什么不刷新jsf页面

[英]why not refresh jsf page

I create a bean as 我创建了一个bean作为

@ManagedBean
@RequestScoped
public class KhachHangMB implements Serializable {
@PersistenceContext(unitName = "XoSoWebPU")
private EntityManager em;
private List<KhachHang> l;

public KhachHangMB() {
    l = new ArrayList<KhachHang>();
}
@PostConstruct
public void init() {
    l = new ArrayList<KhachHang>();
    l = em.createNamedQuery("KhachHang.findAll").getResultList();
    MsgShow.showMsg("", "Init " + Math.random());
}

public List<KhachHang> retriveAllKhachHang() {
    return l;
}

} }

And my jsf page: 而我的jsf页面:

<h:form>
            <h1><h:outputText value="List"/></h1>
            <h:dataTable value="#{khachHangMB.retriveAllKhachHang()}" var="item">
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="Idkh"/>
                    </f:facet>
                    <h:outputText value="#{item.idkh}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="TenKH"/>
                    </f:facet>
                    <h:outputText value="#{item.tenKH}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="Cmnd"/>
                    </f:facet>
                    <h:outputText value="#{item.cmnd}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="DiaChi"/>
                    </f:facet>
                    <h:outputText value="#{item.diaChi}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="SoDT"/>
                    </f:facet>
                    <h:outputText value="#{item.soDT}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="Email"/>
                    </f:facet>
                    <h:outputText value="#{item.email}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="MaDuThuong"/>
                    </f:facet>
                    <h:outputText value="#{item.maDuThuong}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="GhiChu"/>
                    </f:facet>
                    <h:outputText value="#{item.ghiChu}"/>
                </h:column>
                <h:column>
                    <f:facet name="header">
                        <h:outputText value="MatKhau"/>
                    </f:facet>
                    <h:outputText value="#{item.matKhau}"/>
                </h:column>
            </h:dataTable>
            <h:commandLink value="Click" action="home" />
        </h:form>

And my faces-config 而我的脸,配置

<navigation-rule>
    <navigation-case>
        <from-outcome>trungthuong_list</from-outcome>
        <to-view-id>/f_trungthuong/trungthuong_list.xhtml</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>
<navigation-rule>
    <navigation-case>
        <from-outcome>home</from-outcome>
        <to-view-id>index.xhtml</to-view-id>
        <redirect/>
    </navigation-case>
</navigation-rule>

I click on command link the random was called but the data on page was not change although i have been edited data on database. 我单击了命令链接,但调用了随机链接,但页面上的数据没有更改,尽管我已经在数据库中编辑了数据。 Another case, i navigate to other page after that i return but the data is old (not using back of web browser, i'm using command link)! 另一种情况是,返回后我导航到其他页面,但是数据很旧(未使用Web浏览器的背面,我正在使用命令链接)! Please help me! 请帮我!

I think you should try setting the option Shared Cache Mode in the file persistence.xml to None . 我认为您应该尝试将文件persistence.xml中的Shared Cache Mode选项设置为None This helped me to solve a problem similar to yours some time ago. 帮我解决了问题 ,前一段时间与你相似。 :) :)

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

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