Primefaces Form值未显示



我有一个素数面dataTable,我想编辑它的行。我确实提交了行的Id,并在要编辑的面板中显示值。使用相同的对象,如果我使用h:outputText打印出值,我就会看到这些值。p: inputText不显示该值。如果我使用浏览器重新加载按钮刷新页面,表单值显示得很好。下面是我的代码的浓缩版本。

型号

@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>

为什么<h:outputText value="#{ticketBean.comment.comment1}"/>会打印出该值,但是<p:inputTextarea value="#{ticketBean.comment.comment1}"/>不显示值?

谢谢你的帮助。

似乎我不小心删除了commandLink 中的porgess="@this"

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

相关内容

  • 没有找到相关文章

最新更新