0

하나의 데이터 테이블이 있습니다. 기록을 사용할 수 있습니다. 내가 actionPollar 내 조치를 사용하고salesforce에서 datatable의 행이 업데이트되지 않았습니다.

, 나는 코드 아래 사용하는 모든 행을 업데이트하고 이제 아래 코드

<apex:actionPoller action="{!updateList}" reRender="thePageBlock" interval="5"/> 

으로 주어진 시간 간격으로 내보기에 표시 할 최신 목록을 가져 updateList입니다.

<apex:commandButton action="{!quicksave}" value="Save" id="saveButton" reRender="thePageBlock"/> 

그러나 변경되지 않습니다. 레코드를 갱신하지 않습니다.

actionPollar의 코드를 제거하고 controller ..it에서 updateList 메소드를 제거하면 데이터가 업데이트되지만 삽입 한 후에는 작동하지 않습니다.

아무에게도 어떻게 알 수 있습니까?

감사

답변

1

재미있는, 그래서 항상 5 초마다 갱신되어 표시되어 귀하의 데이터 집합의 동일한 복사본을 유지하고있다, 그건 당신이 수도 나에게 보이는, 당신의 ViewState는 5 초마다 새로 고쳐 의미 마지막으로 변경 사항을 포함하지 않는 수신 같은 값을 제출할, 나는 두 경로 중 하나 갈 것이다 :

  1. 편집 모드 또는 변경 작업도 다른 사람이 변경 사항을 덮어 쓸 수 없었다 편집 기록을 차단 폴러를 중지합니다.
  2. ViewState를 두 개의 개별 ViewState로 분할합니다. 하나는 레코드를로드하고 두 번째는 선택한 레코드를 편집하는 데 사용되며, 처음 저장하면 ViewState는 두 번째 ViewState에서 마지막으로 변경된 내용으로 새로 고침됩니다. 이것은 여러 양식과 동기화 메커니즘을 사용하여.
  3. 없이 VisualForce 페이지

    <apex:page controller="MultipleActionRegionsCtrl"> 
    
    <!-- SINGLE FORM --> 
    
    <apex:form > 
    
    <apex:pageBlock title="Master Detail Record Selection/Edition"> 
    
    <!-- MASTER LIST --> 
    <apex:pageBlockSection title="Available Records"> 
    <apex:actionRegion > 
    
    <!-- TABLE--> 
    <apex:outputPanel id="recordsPanel"> 
    <apex:PageBlockTable value="{!cList}" var="c"> 
    <apex:column value="{!c.FirstName}"/> 
    <apex:column value="{!c.LastName}"/> 
    <apex:actionSupport event="onRowClick" action="{!editSelectedRecord}" rerender="recDetail" status="dataUpdateStatus"> 
    <apex:param name="cid" value="{!c.Id}" /> 
    </apex:actionSupport> 
    </apex:PageBlockTable> 
    </apex:outputPanel>   
    <apex:actionStatus id="dataRefreshStatus"> 
    <apex:facet name="start">Refreshing...</apex:facet> 
    <apex:facet name="stop">Data Loaded</apex:facet> 
    </apex:actionStatus> 
    
    <!-- RELOAD TABLE--> 
    <apex:actionPoller action="{!reloadContacts}" reRender="recordsPanel" interval="5" status="dataRefreshStatus"/> 
    
    </apex:actionRegion> 
    </apex:pageBlockSection> 
    
    <!-- DETAIL --> 
    <apex:pageBlockSection title="Record Details" id="recDetail" columns="2"> 
    <apex:actionRegion rendered="{!IF(editableRecord=null,false,true)}"> 
    <table> 
    <tr> 
    <td colSpan="2"> 
    &nbsp; 
    <apex:actionStatus id="dataUpdateStatus" > 
    <apex:facet name="start">Loading...</apex:facet> 
    <apex:facet name="stop"> </apex:facet> 
    </apex:actionStatus> 
    </td> 
    </tr> 
    <tr> 
    <td>First Name </td> 
    <td><apex:inputField value="{!editableRecord.FirstName}"/></td> 
    </tr> 
    <tr> 
    <td>Last Name </td> 
    <td><apex:inputField value="{!editableRecord.LastName}"/></td> 
    </tr>     
    <tr> 
    <td><apex:commandButton action="{!saveRecord}" value="Save" reRender="recordsPanel,recDetail"/></td> 
    </tr> 
    </table> 
    </apex:actionRegion>  
    </apex:pageBlockSection> 
    
    </apex:pageBlock>  
    
    </apex:form> 
    
    </apex:page> 
    
    를 선택하면, 여전히 기록하기위한 로크기구를 누락 레코드 방해되지 않고 활성화 옵션을 사용

    제안 된 해결책은 (1), 폴러 스테이

컨트롤러

public class MultipleActionRegionsCtrl { 

public Map<ID, Contact> cMap {get;set;} 
public Contact editableRecord {get;set;} 

// Using lazy load for test purposes 
public List<Contact> cList { 
get{ 
if(cMap == null){ 
cMap = new Map<ID, Contact>([SELECT Id, FirstName, LastName From Contact limit 10]); 
} 
return cMap.values(); 
} 
} 

public MultipleActionRegionsCtrl(){ } 

public PageReference reloadContacts(){ 
if(cMap!=null && !cMap.isEmpty()){ 
Set<Id> myIds = cMap.keySet(); 
// reload same records loaded at the start 
cMap = new Map<ID, Contact>([SELECT Id, FirstName, LastName From Contact WHERE Id IN :myIds]); 
} 
return null; 
} 

public PageReference editSelectedRecord() { 
String cID = ApexPages.currentPage().getParameters().get('cid'); 
if(cMap!=null && !cMap.isEmpty() && cMap.containsKey(cID)){ 
editableRecord = cMap.get(cID); 
} 
return null; 
} 

public PageReference saveRecord(){ 
update editableRecord; 
editableRecord = null; // so we don't save two times same record 
return reloadContacts(); //instantly update current list do not wait for poller 
} 

} 
+1

답장을 보내 주셔서 감사합니다. 당신이 1 포인트에서 언급했듯이 : 편집을 위해 레코드를 블로킹하지 않도록 아무도 당신의 변경 사항을 덮어 쓸 수 없었습니다. 어떻게 차단할 수 있고 2 가지 폼을 분리했습니다. 그것은 사실입니까? ' --data 테이블 outputfield-- '' <정점 : actionPoller 조치 = "{!} updateList"다시 쓰게 = "thePageBlock (상기 소정의 데이터 테이블의 ID)"간격 = "5 "/> ' –

+0

구현하려는 경우에 대해 ActionRegion의 존재를 언급하는 것을 잊어 버렸습니다. 자세한 내용은 여기를 참조하십시오. http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionRegion.htm . 폼을 분할하여 뷰 상태를 조각화 할 수 있습니다. 조건부 렌더링을 사용하여 이전에 관찰 한 동작입니다. 모두 요구 사항에 따라 다르지만 별도의 actionRegions를 사용하여 솔루션 # 1을 위해 곧바로 진행하는 것이 좋습니다. – magdiel

관련 문제