为什么在这种特殊情况下部分渲染失败?

时间:2016-05-09 07:11:17

标签: ajax jsf-2

我正在使用Mojarra 2.2

这里是片段:

    <h:head>
        <title></title>          
    </h:head> 
    <h:body> 
        <h:form id="playersFormId">                        
            <h:dataTable id="playersTableId" 
                         value="#{ajaxBean.myMap.entrySet()}" var="t">
                <h:column>
                    <f:facet name="header">
                        Delete
                    </f:facet>
                    <h:commandLink id="commandDeleteId" 
                                   immediate="true" 
                                   action="#{ajaxBean.deletePlayerAction(t.key)}">

                        <f:ajax  render=":playersFormId:playersTableId"/>

                        <h:graphicImage value="/resources/default/imgs/delete.png"/>                            
                    </h:commandLink>     
                </h:column> 
                <h:column>
                    <f:facet name="header">
                        Nr
                    </f:facet>
                    #{t.key}             
                </h:column> 
                <h:column>
                    <f:facet name="header">
                        Name
                    </f:facet>
                    #{t.value}
                </h:column>                
            </h:dataTable>
        </h:form>            
    </h:body>

@Named
@ViewScoped
public class AjaxBean implements Serializable {

    private Map<Integer, String> myMap = new HashMap<>();

    @PostConstruct
    public void init() {
        myMap.put(1, "Nadal Rafael");
        myMap.put(2, "Federer Roger");
        myMap.put(3, "Ferer David");
        myMap.put(4, "Murray Andy");
        myMap.put(5, "Djokovic Novak");
        myMap.put(6, "Berdych Tomas");
        myMap.put(7, "Haas Tommy");
        myMap.put(8, "Isner John");
        myMap.put(9, "Fognini Fabio");
        myMap.put(10, "Robredo Tommy");
    }

    public Map<Integer, String> getMyMap() {
        return myMap;
    }

    public void setMyMap(Map<Integer, String> myMap) {
        this.myMap = myMap;
    }

    public void deletePlayerAction(String nr) {  
        FacesContext facesContext = FacesContext.getCurrentInstance();
          ExternalContext externalContext = facesContext.getExternalContext();
          Map<String, String> headers = externalContext.getRequestHeaderMap();


          //determination method 1       
          PartialViewContext partialViewContext =    
                            facesContext.getPartialViewContext();
          if (partialViewContext != null) {
            if (partialViewContext.isAjaxRequest()) {
                 System.out.println("THIS IS AN AJAX REQUEST (DETERMINATION 1) ...");
            } else {
                  System.out.println("THIS IS A NON-AJAX REQUEST(DETERMINATION 1)...");
            }
          }
        System.out.println("nr: "+nr);
        if(nr!=null){               
            myMap.remove(Integer.valueOf(nr));
        }
    }

}

我看到当我点击图片链接时,服务器端操作方法正在获取c / d并且记录将从地图中删除。 我已经指定需要刷新数据表,但它没有得到。

我在哪里弄错了?

当我点击第一条记录时,在网络标签下,我看到 - enter image description here

&安培;在控制台选项卡下 -

enter image description here

0 个答案:

没有答案