Salesforce-在具有内联编辑的页面块表中更改后无法更新记录

时间:2012-01-31 21:44:27

标签: salesforce apex-code visualforce rerender

我创建了一个搜索查询,它返回表中的记录。我在返回的记录中使用了命令,以便我可以编辑它们并仅将它们保存在表中。但是在更改表中的记录并单击SAVE按钮后,我无法更新表中的记录。如何使用“rerender”显示更新的数据?我正在使用的页面代码和控制器操作如下:

<!-- Page -->
<apex:pageBlock id="pb1">
  <apex:outputPanel id="pan">
    <apex:pageBlockTable value="{!l1}" var="k" rendered="{!flag}" id="pb">
      <apex:column value="{!k.First_Name__c}"/>
      <apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
      <apex:column value="{!k.Last_Name__c}"/>
      <apex:inlineEditSupport event="ondblclick" showOnEdit="save"/>
      <apex:column value="{!k.E_mail__c}"/>
      <apex:inlineEditSupport event="ondblclick" showOnEdit="save"/>
      <apex:column value="{!k.Employee_ID__c}"/>
      <apex:commandButton action="{!save}" id="saveButton" value="Save" />
    </apex:pageBlockTable>
  </apex:outputPanel>

  <apex:commandButton action="{!edit}" id="editButton" value="Edit"/>
  <apex:commandButton action="{!save}" id="saveButton" value="Save"/>
  <apex:actionSupport event="onclick" rerender="pan" status="refreshstatus"/>
  <apex:commandButton onclick="resetInlineEdit()" id="cancelButton" value="Cancel"/>
  <apex:actionStatus id="refreshstatus" startstyle="color:green;" startText="Saving....">
  </apex:actionStatus>
</apex:pageBlock> 

// controller action
public pagereference save(){update l1;return null;}}

1 个答案:

答案 0 :(得分:1)

在这里发布一些代码会有很长的路要走,但它的长短是:

<!-- put your table in a panel with an ID -->
<apex:outputPanel id="thePanel:>
  <!-- put your table here -->
</apex:outputPanel>

<!-- specify the panel's ID as the rerender target for the action -->
<apex:commandButton value="Save" action="{!TheSaveAction}" rerender="thePanel"/>

然后确保您的控制器返回Pagereference,其值为null

public Pagereference TheSaveAction()
{
  // save
  return null;
}

如果你在这样做之后还在苦苦挣扎,请输入页面代码(或相关部分),这样我就可以看到发生了什么。