apex code - row from datatable does not updated in salesforce -


i have 1 data table no. of records available.

i using actionpollar , action updatelist latest list display on view on given time interval below code

<apex:actionpoller action="{!updatelist}" rerender="thepageblock" interval="5"/> 

now, updating row using below code.

<apex:commandbutton action="{!quicksave}" value="save" id="savebutton" rerender="thepageblock"/> 

but, not change. , not update record.

if remove code of actionpollar , remove method updatelist controller ..it updates data..but, after putting it, not work.

can tell how can ?

thanks

interesting, keeping same copy of dataset, been refreshed every 5 seconds , displayed, means viewstate been refreshed every 5 seconds, looks me might submitting same values last received not containing changes, i'll go 1 of 2 routes:

  1. stop poller when edit mode or making changes blocking record editing no 1 else overwrite changes.
  2. split viewstate 2 separate viewstates, 1 going load records, second 1 going used editing selected record, when saved first viewstate going refreshed last changes made on second viewstate, can accomplish using multiple forms , syncing mechanism.

proposed solution using option (1), poller stays active not interfering record, still missing lock mechanism record when selected

visualforce page

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

controller

public class multipleactionregionsctrl {  public map<id, contact> cmap {get;set;} public contact editablerecord {get;set;}  // using lazy load test purposes public list<contact> clist { get{ if(cmap == null){ cmap = new map<id, contact>([select id, firstname, lastname 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 @ start cmap = new map<id, contact>([select id, firstname, lastname contact 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; // don't save 2 times same record return reloadcontacts(); //instantly update current list not wait poller }  } 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -