11

See the code below, when I click Agree I woudld expcet doSave to be called on the controller, but when I debug, I do not see the log message and I only stay on the same page.

Things I have tried: - removing disabled=true - adding/removing immediate=true - adding/removing all javascript (not shown here, since I removed) - adding a visualforce element to the form (since it might be trying to outsmart me)

None of these worked.

Here is my controller:

public with sharing class TandCAgreeController {

public _Operating_Terms_And_Condition__c tAndC {get; set;}
public TLD__c tld {get; set;}

public TandCAgreeController() 
{
    System.debug('got to contstructor');
    tAndC = [select terms_and_condition_text__c from _Operating_Terms_And_Condition__c where is_active__c = true];
    tld = new TLD__c();
}

public PageReference doSave() { 
    // save the ref to the agrement they agreed to

    System.debug('got to save method on tandcagree');

    PageReference pageRedirect = Page.StartPage;

    return pageRedirect;
}

}

Here is my page:

<apex:page controller="TandCAgreeController" id="TandCAgreePage" docType="html-5.0" showHeader="false">
<apex:composition template="{!$Site.Template}">

<apex:define name="body">

<div class="container">

<h2>Please review and agree to the terms and conditions. There is an agree check box at the bottom that will allow you to agree and continue when you check it.</h2>
<br></br>

<br></br>
    <apex:pageMessages />   

            <apex:form >

                <div class="control-group">
                    <label class="control-label">Subject:</label>
                    <div class="controls">
                      <div id="" style="overflow-y: auto; height:100px; border: 1px solid #DDDDDD;">
                            <apex:outputtext value="{!tAndC.terms_and_condition_text__c}" escape="false"></apex:outputtext>
                            <br/>
                            <div ><span style="font-weight:bold;">Check to Agree:</span>&nbsp;<input type="checkbox" name="agree" value="agree" id="agreement-checkbox"/> </div>
                      </div>
                    </div>                              
                </div>
            <div class="control-group">
                <apex:commandButton action="{!doSave}" value="Agree" disabled="true" Styleclass="btn btn-small" immediate="true"/>
            </div>
    </apex:form>
    </div>
</apex:define>
</apex:composition>
</apex:page>
1
  • Things I have tried:
    – Joelio
    Nov 15, 2013 at 18:49

2 Answers 2

8
<apex:commandButton action="{!doSave}" value="Agree" disabled="true" Styleclass="btn btn-small" immediate="true"/>

I see from the above code you have disabled=true and hence the issue .Please remove and retry .Once a button is disabled the form wont be submitted

Update:

Another reason is since it has a template i fear you have two forms and that may have caused the issue of method not calling

7
  • tried that, didnt help
    – Joelio
    Nov 15, 2013 at 18:31
  • I tried getting rid of all the js as well and having it default to not disabled, but still no luck.
    – Joelio
    Nov 15, 2013 at 18:32
  • i doubt on composition and define tags .Just remove and see if that works and debug from there on Nov 15, 2013 at 18:36
  • yes I removed it, it didn't help, I also added and removed "immediate=true", no help.
    – Joelio
    Nov 15, 2013 at 18:47
  • you mean to say command button in sfdc dont work? Nov 15, 2013 at 18:49
1

Try removing immediate = true.

Try calling action method using action function

<apex:actionFunction name="doUnlink" action="{!performUnlinkContact}" rerender="refresh" status="myStatus"/>

<input type="button" value="Yes, this is the wrong contact" onclick="doUnlink();" />
1
  • that was added for debugging, same problem without it.
    – Joelio
    Nov 15, 2013 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.