+ Start a Discussion
dn6184dn6184 

VF Custom Object Question

Hi,

 

For the purposes of integration, we created overrides for pages related to our standard objects (i.e. Account) as shown below:

 

<apex:page id="page1" standardController="Account" extensions="IntegratedObjectController" >
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" />
<script>
var $j = jQuery.noConflict();
$j(function() {
    var saved = InlineEditData.prototype.handleResponse;
    InlineEditData.prototype.handleResponse = function(responseText) {
        saved.apply(this, arguments);
        actionSave();
    };
});

function saved() {
    var errorMessage = $j("#page1\\:form1\\:dynamicOutput").html();
    if (errorMessage.length > 0) {
        alert(errorMessage);
    }
}
</script>
<apex:form id="form1">
    <apex:actionFunction name="actionSave" action="{!actionSave}" oncomplete="saved();"
        rerender="dynamicOutput " />
    <apex:outputPanel id="dynamicOutput" layout="block" style="display:none">
    {!ErrorMessage}
    </apex:outputPanel>
    <apex:detail subject="{!account.Id}" relatedList="true" inlineEdit="true" relatedListHover="true"
        showChatter="true" title="true" />
</apex:form>
</apex:page>

 

This approach has worked well (using exact same markup/code) until we tried it for a custom object (Order__c) as shown below:

 

<apex:page id="page1" standardController="Order__c" extensions="IntegratedObjectController" >
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" />
<script>
var $j = jQuery.noConflict();
$j(function() {
    var saved = InlineEditData.prototype.handleResponse;
    InlineEditData.prototype.handleResponse = function(responseText) {    
        saved.apply(this, arguments);
        actionSave();
        alert('actionSave');
    };
});

function saved() {
    var errorMessage = $j("#page1\\:form1\\:dynamicOutput").html();
    if (errorMessage.length > 0) {
        alert(errorMessage);
    }
}
</script>
<apex:form id="form1">
    <apex:actionFunction name="actionSave" action="{!actionSave}" oncomplete="saved();"
        rerender="dynamicOutput" />
    <apex:outputPanel id="dynamicOutput" layout="block" style="display:none">
    {!ErrorMessage}
    </apex:outputPanel>
    <apex:detail subject="{!Order__c.Id}" relatedList="true" inlineEdit="true" relatedListHover="true"
        showChatter="true" title="true" />
</apex:form>
</apex:page>

 

We now get the order object saved but the base controller never returns control so the butten remains "Pressed" and our extension never executes to the system.debug('Running updateOrder') statement you see in the controller extension shown below:

 

public with sharing class IntegratedObjectController {

    private sObject theObject;
    private Schema.Sobjecttype sObjectType;
    public String ErrorMessage { get; set; }

    public IntegratedObjectController(ApexPages.StandardController controller) {
        theObject = controller.getRecord();
        sObjectType = theObject.getSObjectType();
        System.debug('Order constructor');
     
    }

    public PageReference actionSave() {
        AdminIntegration admin = DependencyManager.getAdminIntegration();
        try {
            if (sObjectType == Account.sObjectType) {
                admin.upsertAccount(theObject.Id);
            }
            else if (sObjectType == Contact.sObjectType) {
                admin.upsertContact(theObject.Id);
            }
            else if (sObjectType == Opportunity.sObjectType) {
                admin.upsertOpportunity(theObject.Id);
            }
            else if (sObjectType == Order__c.sObjectType) {
                System.debug('Running updateOrder');
                //admin.updateOrder(theObject.Id);
            }
            else {
                throw new ApplicationException('Unsupport object type: ' + sObjectType.getDescribe().getName());
            }
        }
        catch (Exception ex) {
            ErrorMessage = 'Integration Error: \r' + (ex.getMessage() != null ?
                ex.getMessage() : '');
        }
        return null;
    }
 
}

 

Is there a known issue with cloning a standard object (i.e. Account) detail page and then using the controller extension technique for a custom object?  This technique works fine for our standard objects.

 

Thanks, Dave

  

Best Answer chosen by Admin (Salesforce Developers) 
Cory CowgillCory Cowgill

Try wrapping your detail tag in a seperate <apex:form> tag and see if that solves it.

 

I had some similar issues (but maybe not the same) and resolved it by using two different <apex:forms> with inlineedit="true".

 

Here is my writeup about it.

 

http://corycowgill.blogspot.com/2011/04/visualforce-inline-editing-ie-error-fix.html