Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
datatable中的行未在salesforce中更新_Salesforce_Apex Code_Visualforce_Salesforce Service Cloud - Fatal编程技术网

datatable中的行未在salesforce中更新

datatable中的行未在salesforce中更新,salesforce,apex-code,visualforce,salesforce-service-cloud,Salesforce,Apex Code,Visualforce,Salesforce Service Cloud,我有一个数据表,其中记录数可用 我正在使用actionPollar,我的操作是updateList,以获取在给定时间间隔内显示在视图上的最新列表,代码如下 <apex:actionPoller action="{!updateList}" reRender="thePageBlock" interval="5"/> 现在,我正在使用下面的代码更新任何行 <apex:commandButton action="{!quicksave}" value="Save" id="sav

我有一个数据表,其中记录数可用

我正在使用actionPollar,我的操作是updateList,以获取在给定时间间隔内显示在视图上的最新列表,代码如下

<apex:actionPoller action="{!updateList}" reRender="thePageBlock" interval="5"/>
现在,我正在使用下面的代码更新任何行

<apex:commandButton action="{!quicksave}" value="Save" id="saveButton" reRender="thePageBlock"/>
但是,这并没有改变。并且不会更新记录

如果我删除actionPollar的代码并从控制器中删除方法updateList,它会更新数据,但是,在放入之后,它就不起作用了

谁能告诉我怎么做


谢谢

有趣的是,它总是保持数据集的相同副本,每5秒刷新一次并显示一次,这意味着您的ViewState也每5秒刷新一次,在我看来,您可能提交了上次收到的相同值,但不包含任何更改,我将采用以下两种方法之一:

在编辑模式或进行更改时停止轮询器也会阻止记录进行编辑,以便其他人无法覆盖您的更改。 将viewState拆分为两个单独的viewState,一个用于加载记录,另一个用于编辑所选记录,当保存的第一个viewState将与第二个viewState上的最后更改一起刷新时,可以使用多个窗体和同步机制来完成此操作。 使用选项1的建议解决方案,轮询器保持活动状态,但不会干扰记录,选中时仍缺少记录的锁定机制

视觉力页

控制器


谢谢你的回复。正如您在第1点中提到的:阻止记录进行编辑,这样就没有其他人可以覆盖您的更改。如何阻止,我已经分离了两个表单。这是真的吗-data table and outputfield-忘记提及您正在实施的此类案例中存在ActionRegion。请在此处查找更多详细信息:。通过拆分表单,您的视图状态也会变得支离破碎,这是我以前在条件渲染中观察到的行为,这完全取决于您的需求,但我强烈建议直接使用带有单独actionRegions的解决方案1。
<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>
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
}

}