You need to sign in to do that
Don't have an account?
Using save action and apex:inputfield in lightning experience
I have a Visualforce page that's a table where the user can add or delete rows. The rows contain key value pairs of data that, when saved, are aggregated into a delimited string and updated. It's basically a way of input control for our users because the number of rows can be dynamic. Here is the page:
<apex:page standardController="Account" extensions="LegalIdController"> <apex:form > <apex:pageBlock title="Manage Legal Ids"> <apex:outputPanel id="legalIdHead"> <apex:variable value="{!0}" var="rowNum"/> <apex:pageBlockSection columns="1"> <apex:pageBlockTable value="{!legalIdRowList}" var="legalIdRow" > <apex:column headerValue="Id Type"> <apex:selectList size="1" id="countryList" value="{!legalIdRow['legalIdType']}" disabled="{!NOT(legalIdRow['doEdit'])}"> <apex:selectOptions value="{!legalIdTypes}"/> </apex:selectList> </apex:column> <apex:column headerValue="Id Value"> <apex:inputText value="{!legalIdRow['legalIdValue']}" disabled="{!NOT(legalIdRow['doEdit'])}"/> </apex:column> <apex:column headerValue="Action"> <apex:commandLink value="Edit" style="color:red" action="{!allowEditForLidRow}" reRender="legalIdHead" rendered="{!NOT(legalIdRow['doEdit'])}"> <apex:param value="{!rowNum}" name="rowToModify" assignTo="{!rowToModify}"/> </apex:commandLink> <apex:commandLink value="Ok" style="color:red" action="{!disAllowEditForLidRow}" reRender="legalIdHead" rendered="{!legalIdRow['doEdit']}"> <apex:param value="{!rowNum}" name="rowToModify" assignTo="{!rowToModify}"/> </apex:commandLink> | <apex:commandLink value="Remove" style="color:red" action="{!removeRowFromLidList}" reRender="legalIdHead" rendered="{!rowNum >= 0}"> <apex:param value="{!rowNum}" name="rowToModify" assignTo="{!rowToModify}"/> </apex:commandLink> <apex:variable var="rowNum" value="{!rowNum + 1}"/> </apex:column> </apex:pageBlockTable> <apex:outputPanel rendered="{! $User.UIThemeDisplayed == 'Theme3' }"> <apex:commandButton action="{!addNewRowToLidRowList}" value="New Row"/> <apex:commandLink value="Save" action="{!save}" oncomplete="" target="_parent" styleClass="btn" style="text-decoration:none;padding:4px;"/> </apex:outputPanel> <apex:outputPanel rendered="{! $User.UIThemeDisplayed == 'Theme4d' }"> <apex:commandButton action="{!addNewRowToLidRowList}" value="New Row"/> <apex:commandLink value="Lightning Save" action="{!saveLightning}" rerender="none" oncomplete="doLightningRefresh()" styleClass="btn" style="text-decoration:none;padding:4px;"/> </apex:outputPanel> </apex:pageBlockSection> </apex:outputPanel> </apex:pageBlock> </apex:form> </apex:page>
Here is the save method in the controller:
public PageReference save() { String legalIdString = ''; for( LegalIdRow row : legalIdRowList ) { if( ( row.legalIdType != null && !row.legalIdType.equals('') ) && ( row.legalIdValue != null && !row.legalIdValue.equals('') ) ) { legalIdString += row.legalIdType + ':' + row.legalIdValue + ';'; } } account.Legal_Identifiers__c = legalIdString; update account; return new PageReference( '/' + account.Id ); }
The problem is, this is not going to work if the user is using lightning experience, because LEX doesn't support PageReference and I'm having to use apex:inputvalue for my form. Is there a simple way to do this in both Classic and Lightning? I've been digging around all day and haven't found anything. I thought I could add an oncomplete attribute to the command link and then use the sforce.one object to redirect to the detail page, but it looks like the save action redirects automatically.