4

So I have commandButtons being displayed through a apex:repeat and being given a variable value in the repeat. When the button it clicked, I have it going to the controller and assigning the values that it is assigned to some inputText fields and reRendering the inputText fields. When the page loads, it works fine on the first click, but it will not work again after the first click. I have system.debug inside of the function in the controller, and it is not hitting the function after the first click.

This is the front end:

    <ul>
        <legend>Endorsement Settings:</legend>
        <apex:outputPanel id="endorsementSettings">
        <apex:repeat value="{!approvals}" var="approve" rows="1">
            <li class="clear-left"><label>Endorsement Type</label><br />
                <apex:inputField value="{!approve.Endorsement_Approval_Type__c}">
                </apex:inputField>
            </li>
            <li><label>Endorsement Option:</label><br />
                <apex:inputField value="{!approve.Setting__c}">
                </apex:inputField>
            </li>
        </apex:repeat>
        <li class="clear-left"><label>Status:</label><br />
            <apex:selectList styleClass="addresstype" size="1" value="{!chapApproval.Status__c}">
                <apex:selectOptions value="{!endorsementStatus}" />
            </apex:selectList>
        </li>
        <li class="clear-left"><label>Employ Date:</label><br />
            <apex:inputText styleClass="datepicker" value="{!chapApproval.Employment_Date__c}">
            </apex:inputText>
        </li>
        <li><label>Endorse-Approve Date:</label><br />
            <apex:inputText styleClass="datepicker" value="{!chapApproval.Endorsement_Approval_Date__c}">
            </apex:inputText>
        </li>
        <li class="clear-left"><label>Term Date:</label><br />
            <apex:inputText styleClass="datepicker" value="{!chapApproval.Endorsement_Approval_Withdrawn_Date__c}">
            </apex:inputText>
        </li>
        <li><label>Term Reason:</label><br />
            <apex:inputText value="{!chapApproval.Withdrawn_Reason__c}">
            </apex:inputText>
        </li>
        </apex:outputPanel>
        <li class="clear-left">
            <label>Add New Endorsement</label><br />
            <apex:commandButton value="Add/Edit" action="addEditEndorsement" reRender="endorsements" styleClass="btn-small no-margin-top" />
        </li>
        <li>
        <apex:outputPanel id="endorsements">
            <table class="light-table">
            <tbody>
            <tr>
                <th>Edit</th>
                <th>Setting - Status</th>
                <th>Endorsement/Approval</th>
                <th>Employ Date</th>
                <th>Endorse-Approve Date</th>
                <th>Term Date</th>
                <th>Term Reason</th>
            </tr>
            <apex:outputPanel layout="none" id="endorsementList">
            <apex:repeat var="approval" value="{!approvals}">
            <tr>
                <td class="t-1of8">
/*******************************
 This is the button in question
*******************************/
                <apex:commandButton value="Edit" styleClass="btn-small" action="{!editEndorsement}" reRender="endorsementSettings">
                    <apex:param name="endorseIds"
                        value="{!approval.Id}"
                        assignTo="{!endorseIds}" />
                </apex:commandButton></td>
                <td class="t-1of8">{!approval.Setting__c} - {!approval.Status__c} : {!approval.Id}</td>
                <td class="t-1of8">{!approval.Endorsement_Approval_Type__c}</td>
                <td class="t-1of8">{!approval.Employment_Date__c}</td>
                <td class="t-1of8">{!approval.Endorsement_Approval_Date__c}</td>
                <td class="t-1of8">{!approval.Endorsement_Approval_Withdrawn_Date__c}</td>
                <td class="t-1of8">{!approval.Withdrawn_Reason__c}</td>
            </tr>
            </apex:repeat>
            </apex:outputPanel>
            </tbody>
            </table>
        </apex:outputPanel>
        </li>
    </ul>

controller:

public void editEndorsement() {
    system.debug('editEndorse'); 
    for (Chaplain_Endorsement_Approval__c e: approvals) {
        system.debug('editEndorse: in the for');
        if (e.Id == endorseIds) {
            system.debug('editEndorse: in the if');
            chapApproval.Employment_Date__c = e.Employment_Date__c;
            chapApproval.Withdrawn_Reason__c = e.Withdrawn_Reason__c;
            chapApproval.Endorsement_Approval_Withdrawn_Date__c = e.Endorsement_Approval_Withdrawn_Date__c;
            chapApproval.Endorsement_Approval_Date__c = e.Endorsement_Approval_Date__c;
            chapApproval.Endorsement_Approval_Type__c = e.Endorsement_Approval_Type__c;
            chapApproval.Setting__c = e.Setting__c;
            chapApproval.Status__c = e.Status__c;
            break;
        }
    }
}

Any help would be greatly appreciated!!!

  • what and where is the endorsementSettings item? – Caspar Harmer Sep 8 '14 at 23:26
  • 1
    any chance you are getting a javascript error somewhere else on the page? (Use firebug or equivalent to see) – cropredy Sep 9 '14 at 0:13
  • @crop1645 There is a js error on some field validations that I have using a plugin. however, there is another commandbutton and reRender on the page which is working perfectly fine, until I click the one in question. – huntonas Sep 9 '14 at 20:09
5

Pretty sure it is related to this issue/bug re Command Buttons and Action Regions.

I just tried a short version of your code with the button wrapped in an actionregion, and it then worked for me.

| improve this answer | |

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.