2012-12-02 5 views
0

다른 클라이언트가 변경 작업을 수행 할 때 Mojarra, PF 3.5 SNAPSHOT, Tomcat 7.0.32를 사용하여 데이터 테이블을 업데이트하려고합니다. 또한 MyCODI, @ViewAccessScoped와 함께 CDF 빈을 사용하고 있습니다.Primefaces 3.5 SNAPSHOT datatable push (websocket) update

내가 3.4, in-row 편집 (in-cell editing 대신) 및 표준 @ConversationScoped를 사용하고있을 때 작동했습니다.

<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:fn="http://java.sun.com/jsp/jstl/functions" 
    xmlns:ui="http://java.sun.com/jsf/facelets" 
    xmlns:p="http://primefaces.org/ui" 
    xmlns:pe="http://primefaces.org/ui/extensions" 
    xmlns:c="http://java.sun.com/jsp/jstl/core" 
    xmlns:t="http://myfaces.apache.org/tomahawk"> 

<ui:composition template="commonLayout.xhtml">      

    <ui:define name="content"> 

     <p:growl id="growlmessage" showDetail="false" autoUpdate="true"/> 

     <p:contextMenu for="staffTable"> 
      <p:menuitem value="Open" update="staffTable" icon="ui-icon-close" actionListener="#{staffbean.onOpen}" /> 
      <p:menuitem value="Delete" update="staffTable" icon="ui-icon-close" onclick="confirmation.show()" /> 
     </p:contextMenu> 

     <p:confirmDialog id="confirmDialog" message="#{text['viewedit.delete.confirm']}" 
         header="#{text['viewedit.delete.header']}" severity="alert" widgetVar="confirmation" appendToBody="true" closable="false" visible="false" > 
      <p:commandButton action="#{staffbean.onDelete}" ajax="true" value="Yes" oncomplete="confirmation.hide()" icon="ui-icon-check" /> 
      <p:commandButton value="No" onclick="confirmation.hide()" type="button" icon="ui-icon-closethick" /> 
     </p:confirmDialog>    

      <p:dataTable id="staffTable" var="staff" widgetVar="staffList" value="#{staffbean.objectList}" paginator="true" rows="15" paginatorPosition="bottom" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" currentPageReportTemplate="#{text['table.staff.filter.count']}" rowsPerPageTemplate="15,25,50,100" emptyMessage="#{text['table.staff.filter.notfound']}" filteredValue="#{staffbean.filteredObject}" editable="true" editMode="cell" draggableColumns="true" rowKey="#{staff.id}" selection="#{staffbean.selectedObject}" selectionMode="single"> 

       <f:facet name="header">      
        <p:columnGroup type="header"> 
         <p:row> 
          <p:column colspan="4"> 
           <h:outputText value="#{text['table.staff.header']}" />  
          </p:column> 
         </p:row> 
         <p:separator/> 
         <p:row> 
          <p:panelGrid columns="5" styleClass="headerGrid"> 
           <p:column colspan="2"> 
            <h:outputText value="#{text['table.filter.global']}" />          
            <p:inputText id="globalFilter" onkeyup="staffList.filter()" style="width:150px" />                
           </p:column> 
           <p:column colspan="2"> 
            <p:selectOneMenu id="pageonly" value="#{staffbean.pageOnly}" >           
             <f:selectItem itemLabel="#{text['dataexporter.pageonly']}" itemValue="true" /> 
             <f:selectItem itemLabel="#{text['dataexporter.entirepage']}" itemValue="false" /> 
             <p:ajax event="change" listener="#{staffbean.exportXLS}" update="@form" immediate="true" /> 
            </p:selectOneMenu>              
            <h:commandLink> 
             <p:graphicImage id="exportPage" value="/resources/img/excel.png" /> 
             <p:dataExporter type="xls" target="staffTable" fileName="staff" pageOnly="#{staffbean.pageOnly}"/> 
             <p:tooltip for="exportPage" value="#{text['dataexporter.tooltip']}" showEffect="fade" hideEffect="fade" /> 
            </h:commandLink>        
           </p:column> 
          </p:panelGrid> 
         </p:row> 
        </p:columnGroup>     
       </f:facet> 

       <p:column id="nameColumn" headerText="#{text['label.name']}" sortBy="#{staff.name}" filterBy="#{staff.name}" filterMatchMode="contains"> 
        <p:cellEditor> 
         <f:facet id="nameoutput" name="output"> 
          <h:outputText value="#{staff.name}" /> 
         </f:facet> 
         <f:facet name="input"> 
          <p:inputText value="#{staff.name}" style="width:100%" required="true" requiredMessage="#{text['validation.error.required.name']}"/> 
         </f:facet> 
        </p:cellEditor> 
       </p:column> 

       <p:column id="staffnoColumn" headerText="#{text['label.staffno']}" sortBy="#{staff.staffno}" filterBy="#{staff.staffno}" filterMatchMode="contains"> 
        <p:cellEditor> 
         <f:facet name="output"> 
          <h:outputText value="#{staff.staffno}" /> 
         </f:facet> 
         <f:facet id="staffliststaffno" name="input"> 
          <p:inputText value="#{staff.staffno}" style="width:100%" required="true" requiredMessage="#{text['validation.error.required.staffno']}">        
           <pe:keyFilter regEx="/^\d+$/" preventPaste="false"/>        
           <f:validator validatorId="staffnoValidator" /> 
           <f:validator validatorId="numericValidator" /> 
          </p:inputText> 
         </f:facet> 
        </p:cellEditor> 
       </p:column>   

       <f:facet name="footer" id="footer"> 
        There are #{fn:length(staffbean.objectList)} staff in total. 
       </f:facet>      

       <p:ajax event="cellEdit" listener="#{staffbean.onEdit}" update="@form" />     

      </p:dataTable> 

    </ui:define> 
    <ui:define name="socket"> 
     <p:socket channel="/ba" > 
      <p:ajax event="message" update="ba_staffTable" /> 
     </p:socket>       
    </ui:define>  
</ui:composition> 

콩 :

 public void update(Object object) { 
    if (!getEm().getTransaction().isActive()) { 
     getEm().getTransaction().begin(); 
    } 
    try { 
     get().merge(object); 
     get().getTransaction().commit(); 
    } catch (PersistenceException e) { 
     if (ExceptionUtil.is(e, ConstraintViolationException.class) || ExceptionUtil.is(e, RollbackException.class)) { 
      e.printStackTrace(); 
      FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, ResourceLoader.MESSAGES.getProperty("staff.error.dbconstraint"), null)); 
      if (getEm().getTransaction().isActive()) { 
       getEm().getTransaction().rollback(); 
      } 
     } 
    } 
    PushContextFactory.getDefault().getPushContext().push("/ba", ""); 
} 

답변

0

테이블의 ID가 staffTable하지 ba_staffTable

입니다

는 XHTML이다
관련 문제