简体   繁体   中英

AJAX not rendering in JSF

Sorry for my english.

Method delete from TestMB :

public String delete(Post post) {
    getDao().delete(post);
    return "success";
}

test.xhtml :

<h:form id="form1">
    <ui:repeat value="#{TestMB.entityList}" var="entityList">
        <p>
            #{entityList.name}

            <h:commandLink action="#{TestMB.delete(entityList)}">
                del
                <f:ajax render=":form1"/>
            </h:commandLink>
        </p>
    </ui:repeat>
</h:form>

Page does not refresh when I clicked the link "del". If I click again, the page will refresh. Why?

if I use new method delete from TestMB :

private String txt1="test";

public String delete() {

    try{
        Thread.sleep(Long.valueOf("10000"));
    }catch(Exception ex){}

    txt1="";

    return "";
}

And new test.xhtml :

<h:form id="form1">

    #{testMB.txt1}

    <h:commandLink action="#{testMB.delete}">
        del
        <f:ajax render=":form1"/>
    </h:commandLink>
</h:form>

I click the link "del" and the page refresh in 10 seconds.

Why not work in the first case?

I found the problem.

public List<Entity> getEntityList() {

    //if(entityList == null){
        entityList=getDao().findAll(getPageRequest());
    //}

    return entityList;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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