2014-04-10 3 views
1

저는 편집 할 행이있는 primeface dataTable을 가지고 있습니다. 난 행에 대한 ID를 제출하고 편집 할 패널에 값을 표시합니다. 동일한 객체를 사용하여 h : outputText를 사용하여 값을 인쇄하면 값이 표시됩니다. p : inputText는 값을 표시하지 않습니다. 브라우저 재로드 버튼을 사용하여 페이지를 새로 고치면 양식 값이 올바르게 표시됩니다. 아래는 압축 된 버전의 코드입니다.Primefaces 형식 값이 표시되지 않습니다.

모델

@Entity 
@Table(name = "TICKET") 
public class Ticket extends AuditTrail implements Serializable 
{ 
    private static final long serialVersionUID = 1L; 

    private static Logger log = Logger.getLogger(Ticket.class); 

    @Id 
    @SequenceGenerator(name = "TICKET_TICKETID_GENERATOR", sequenceName = "TICKET_SEQ") 
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "TICKET_TICKETID_GENERATOR") 
    @Column(name = "TICKET_ID", unique = true, nullable = false, precision = 0) 
    private Long ticketId; 

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "ticket") 
    @OrderBy(clause = "createdBy") 
    private Set<Comment> comments = new LinkedHashSet<Comment>(0); 
} 

@Entity 
@Table(name = "COMMENT_LOG") 
public class Comment extends AuditTrail implements java.io.Serializable { 

    // Fields 

    private static final long serialVersionUID = 1L; 

    @Id 
    @Column(name = "COMMENT_LOG_ID", unique = true, nullable = false, precision = 0) 
    @SequenceGenerator(name = "COMMENT_COMMENTID_GENERATOR", sequenceName = "COMMENT_SEQ") 
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "COMMENT_COMMENTID_GENERATOR") 
    private Long commentId; 

    @ManyToOne(fetch = FetchType.LAZY) 
    @JoinColumn(name = "TICKET_ID") 
    private Ticket ticket; 

    @Column(name = "COMMENT1", nullable = false, length = 300) 
    private String comment1; 

} 

컨트롤러

@Named("ticketBean") 
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS) 
public class TicketBean implements Serializable 
{ 
private Ticket ticket = new Ticket(); 
private Comment comment = new Comment(); 
/** 
    * getters & setters 
     */ 
    public void editComment(long commentId) 
    { 
     for (Comment editComment: ticket.getComment()) 
     { 
      if (editComment.getCommentId().longValue() == commentId) 
      { 
       this.comment = editComment; 
       changeButtonValue("tabView:commentForm1:submitAddComment", "Save");    
       break; 
      } 
     } 
    } 
} 

XHTML

<h:form prependId="false" id="commentForm1"> 
    <p:panel id="panelComment"> 
    <h:outputText value="#{ticketBean.comment.comment1}"/> 
    <p:inputTextarea styleClass="textarea" value="#{ticketBean.comment.comment1}" 
         rows="4" 
        cols="60" 
        maxlength="255" 
        counter="counter2" 
        counterTemplate="{0} characters remaining." 
        id="comment1" 
        required="true" 
        requiredMessage="Comment is required"/> 
<br /> 
<h:outputText id="counter2" style="font-size:8pt;" /> 
<p:commandButton id="submitAddComment" value="Add" 
actionListener="#{ticketBean.addComment()}" 
             ajax="true" 
             style="font-size:11pt;" process="panelComment" 
             update=":tabView:commentForm1" /> 

<p:dataTable id="ticketCommentsList" var="com" 
     value="#{ticketBean.ticket.comments.toArray()}" 
     paginator="true" dynamic="true" rows="10" 
     paginatorPosition="bottom" lazy="true" 
     paginatorAlwaysVisible="false" widgetVar="projTable" 
     paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}" 
           rowsPerPageTemplate="10,15,20" styleClass="prime-datatable"> 

    <p:column id="comment1" headerText="Comment"> 
      <h:outputText value="#{com.comment1}" /> 
     </p:column>        
    <p:column> 
     <f:facet name="header">Edit</f:facet> 
    <p:commandLink action="#{ticketBean.editComment(com.commentId)}"            
         ajax="true" value="Edit" 
         update=":tabView:commentForm1" 
         immediate="true"/> 
     </p:column> 
    </p:dataTable> 
</p:panel> 
</h:form> 

이유을 것 10 값을 출력하지만 <p:inputTextarea value="#{ticketBean.comment.comment1}"/> 값을 표시하지 않습니까?

도움 주셔서 감사합니다.

+1

왜 사실 = 거짓 = 아약스 즉시? – Leo

+0

사실 나는 그것을 ajax = true로 가지고있었습니다. 나는 ajax = false가 어떤 차이를 만들지 알아보기 위해 노력했다. – user3520171

+0

나는 내 자신의 질문에 대답 할 것이다. 내가 commandLink에서 가지고 있던 프로세스 = "@ this"를 우연히 삭제 한 것처럼 보입니다. "편집" process = "@ this"update = ": tabView : commentForm1" '

' – user3520171

답변

1

내가 실수로 "@이"= porcess을 삭제 한 것 같다 나는 CommandLink는에 있었다

<p:commandLink action="#ticketBean.editComment(com.commentId)}"                     
      ajax="true" 
      value="Edit"        
      process="@this" 
      update=":tabView:commentForm1" 
      immediate="true"/> 
관련 문제