2013-10-02 3 views
1

primeface의 dataTable을 사용하여 이상한 동작이 발생합니다. 목록에 새 행을 추가하고 dataTable이 새로 고침되면 헤더가 복제됩니다. 따라서 첫 번째 행이 추가 된 후 머리글은 두 번 표시되고 두 번째 행은 네 번 표시됩니다. 필터링 옵션을 제거하려고했지만 여전히 동일한 동작이 발생합니다. 누군가 동일한 문제가 발생 했습니까? Tomcat 7에서 Primefaces 4.0을 사용하고 있습니다.새 행을 추가 할 때 Primefaces datatable 헤더가 중복됩니다.

불쌍한 영어를 도와 주실 수있는 분들께 미리 감사드립니다. 이것은 내 코드 http://i.imgur.com/tb57ahJ.png


이다 : 여기서

의 동작을 보여주는 이미지이다

index.html을

일 : index.xhtml 페이지는 데이터 테이블을 포함하는 제 movementList.xhtml 페이지를 포함
<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:h="http://java.sun.com/jsf/html" 
    xmlns:f="http://java.sun.com/jsf/core" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:p="http://primefaces.org/ui" 
    xmlns:c="http://java.sun.com/jstl/core"> 

<h:head> 
    <link href="/#{COREWEB_MODULE_URL}/css/jsf.css" rel="stylesheet" type="text/css"></link> 
</h:head> 

<ui:include src="/jsp/faces/common/varImages.xhtml"/> 

<h:body style="background-color:grey;"> 

<p:growl id="messages"/> 

<p:dock position="top" halign="center" > 
    <p:menuitem value="Home" icon="#{imgHome64}" url="index.xhtml"/> 
    <p:menuitem value="Movimenti" icon="#{imgNoteBook64}" url="/movement/list.xhtml"/> 
    <p:menuitem value="Mutuo" icon="#{imgEuro64}" url="/bankLoan/list.xhtml"/> 
    <p:menuitem value="Grafici" icon="#{imgChart64}" url="/graph/list.xhtml"/> 
    <p:menuitem value="Dizionario" icon="#{imgBook64}" url="/dictionary/list.xhtml"/> 
</p:dock> 

<p:stack icon="/images/stack/stack.png"> 
    <p:menuitem value="Home" icon="#{imgHome64}" url="index.xhtml"/> 
    <p:menuitem value="Movimenti" icon="#{imgNoteBook64}" url="/movement/list.xhtml"/> 
    <p:menuitem value="Mutuo" icon="#{imgEuro64}" url="/bankLoan/list.xhtml"/> 
    <p:menuitem value="Grafici" icon="#{imgChart64}" url="/graph/list.xhtml"/> 
    <p:menuitem value="Dizionario" icon="#{imgBook64}" url="/dictionary/list.xhtml"/> 
</p:stack> 

<div style="display:block;width:1300px;height:50px;"> 
    <div style="float:left;width:1120px;" id="menuTopDiv"> 

    </div> 
    <div style="float:left;width:180px;height:50px;" id="themeSwitcherDiv"> 
     <h:panelGrid columns="2" cellpadding="10"> 
      <p:themeSwitcher value="#{guestPreferences.theme}" style="width:165px" effect="fade" id="statefulSwitcher"> 
       <f:selectItem itemLabel="Choose Theme" itemValue="" /> 
       <f:selectItems value="#{themeSwitcherBean.themes}" /> 
       <p:ajax listener="#{themeSwitcherBean.saveTheme}" /> 
      </p:themeSwitcher> 
     </h:panelGrid> 
    </div> 
</div> 

<div style="display:block;width:1300px;height:220px;"> 
    <div id="menuTopLeftDiv" style="float:left;width:300px;height:220px;"> 
     <ui:include src="/jsp/faces/menu/menuLeft.xhtml"/> 
    </div> 
    <div id="latestIncomeDiv" style="float:left;width:490px;height:220px;margin-left:0.3em;"> 
     <ui:include src="/jsp/faces/latestIncomeWidget.xhtml"/> 
    </div> 
    <div id="latestOutcomeDiv" style="float:left;width:496px;height:220px;margin-left:0.3em;"> 
     <ui:include src="/jsp/faces/latestOutcomeWidget.xhtml"/> 
    </div> 
</div> 

<div style="float:left;display:block;width:1300px;"> 
    <ui:include src="/jsp/faces/movement/movementList.xhtml"/> 
</div> 

</h:body> 
</html> 

movementList.xhtml

012 317,351,132,527,796,353,210

MovementJsf.java

package it.fronte.account.jsf; 

import it.fronte.account.command.search.MovementSearchCommand; 
import it.fronte.account.model.Movement; 
import it.fronte.account.service.AccountService; 
import it.fronte.dictionary.model.Dictionary; 
import it.fronte.dictionary.service.DictionaryService; 

import java.math.BigDecimal; 
import java.util.ArrayList; 
import java.util.Date; 
import java.util.List; 

import javax.faces.application.FacesMessage; 
import javax.faces.bean.ManagedBean; 
import javax.faces.bean.RequestScoped; 
import javax.faces.context.FacesContext; 

import org.springframework.web.jsf.FacesContextUtils; 

@RequestScoped 
@ManagedBean(name = "movementJsf") 
public class MovementJsf { 

    protected AccountService accountService = (AccountService) FacesContextUtils.getWebApplicationContext(
      FacesContext.getCurrentInstance()).getBean("accountService"); 
    protected DictionaryService dictionaryService = (DictionaryService) FacesContextUtils.getWebApplicationContext(
      FacesContext.getCurrentInstance()).getBean("dictionaryService"); 

    // Properties 

    public BigDecimal amount; 
    public Integer estimatedId; 
    public Date operationDate = new Date(); 
    public Integer typeId; 

    public List<Movement> movementList = new ArrayList<Movement>(); 

    public List<Movement> getMovementList() { 
     MovementSearchCommand searchCommand = new MovementSearchCommand(); 
     searchCommand.setAccountId(1); 
     searchCommand.setSort("operationDate"); 
     searchCommand.setSortDirection("desc"); 
     searchCommand.setPage(1); 
     searchCommand.setPageSize(99999999); 
     this.movementList = accountService.searchMovement(searchCommand); 
     return movementList; 
    } 

    // Getters & Setters 

    public Integer getTypeId() { 
     return typeId; 
    } 

    public void setTypeId(Integer typeId) { 
     this.typeId = typeId; 
    } 

    public BigDecimal getAmount() { 
     return amount; 
    } 

    public void setAmount(BigDecimal amount) { 
     this.amount = amount; 
    } 

    public Integer getEstimatedId() { 
     return estimatedId; 
    } 

    public void setEstimatedId(Integer estimatedId) { 
     this.estimatedId = estimatedId; 
    } 

    public Date getOperationDate() { 
     return operationDate; 
    } 

    public void setOperationDate(Date operationDate) { 
     this.operationDate = operationDate; 
    } 

    // Constructors 

    public MovementJsf() { 

    } 

    public MovementJsf(Integer typeId, BigDecimal amount, Date operationDate, Integer estimatedId) { 
     this.typeId = typeId; 
     this.amount = amount; 
     this.operationDate = operationDate; 
     this.estimatedId = estimatedId; 
    } 

    // CRUD methods 

    public String addMovement() { 
     Movement movement = new Movement(); 
     movement.setAccountId(1); 
     movement.setCreationDate(new Date()); 
     movement.setLastModifiedDate(new Date()); 
     movement.setTypeId(this.typeId); 
     Dictionary type = dictionaryService.getDictionary(this.typeId); 
     movement.setDirectionId(getDirection(type)); 
     movement.setAmount(this.amount); 
     movement.setEstimatedId(this.estimatedId); 
     movement.setOperationDate(this.operationDate); 
     accountService.saveOrUpdate(movement); 

     movementList.add(0, movement); 

     FacesMessage msg = new FacesMessage("Movimento aggiunto", "Movimento aggiunto"); 
     FacesContext.getCurrentInstance().addMessage(null, msg); 

     return null; 
    } 

    private Integer getDirection(Dictionary dictionary) { 
     if (dictionary.getParentDictionaryId() != null) 
      return getDirection(dictionary.getParentDictionary()); 
     else 
      return dictionary.getId(); 
    } 

} 
+0

나는 모든 지금 PrimeFaces 3.5에 PrimeFaces 4에서 내 jar 파일을 다운 그레이드하려 = "거짓" 잘 작동합니다. 버전 4.0의 버그 일 수도 있습니다 – GreyStar

+0

PrimeFaces 녀석에게보고하여 고칠 수 있도록하십시오. – BalusC

+0

이 문제는 p : dataTable의 "stickyHeader"속성 사용과 관련이 있으며 Primefaces 4에서는 지원되지 않습니다. 그래서 그것을 제거하는 행동은 사라졌습니다. – GreyStar

답변

-1

가 스크롤 = "true"또는 변경을 제거 해결하기 스크롤

+1

왜? 어떤 버전입니까? 최신 버전? 제발 좀 더 구체화하십시오 – Kukeltje

+0

나는 primefaces 5.2 에서이 버그를 참조하십시오. 마지막 버전에서 수정 된 사항은 알 수 없습니다 : 5.2.13. 이유를 모르겠다. 누군가 더 많은 테스트를 할 수 있습니다. – asdrubal

관련 문제