0

Visual Force:

<apex:component controller="MemberClaimsRelatedListController">

<apex:pageBlock title="Claims" id="related-page-block">
    <apex:pageblockTable value="{!selectedClaims}" var="each">
        <apex:column headerValue="Add To Case" width="5">
            <apex:commandButton value="Add to Case" action="{!addToCase}" reRender="related-page-block">
                <apex:param assignTo="{!clickedClaim}" value="{!each.ClaimId__c}"/>
            </apex:commandButton>
        </apex:column>
    </apex:pageblockTable>
</apex:pageBlock>

</apex:component>

Controller method:

public String clickedClaim { get; set; }

public PageReference addToCase() {
    System.debug('This claim was clicked: ' + clickedClaim);
    return null;
}

Debug:

USER_DEBUG|[118]|DEBUG|This claim was clicked: null

ClaimId__c is set

USER_DEBUG|[53]|DEBUG|claims: (ClaimSummary__x:{claimId__c=123456, ...}

Why would my value be null?

2

If you really need a button (and not something that looks like a button), use an actionFunction:

<apex:actionFunction name="callAddToCase" action="{!addToCase}" reRender="related-page-block">
    <apex:param name="clickedClaimId" assignTo="{!clickedClaim}" value=""/>
</apex:actionFunction>

<apex:pageBlock title="Claims" id="related-page-block">
    <apex:pageblockTable value="{!selectedClaims}" var="each">
        <apex:column headerValue="Add To Case" width="5">
            <apex:commandButton value="Add to Case" onclick="callAddToCase('{!each.ClaimId__c}'); return false" />
        </apex:column>
    </apex:pageblockTable>
</apex:pageBlock>

</apex:component>
| improve this answer | |
1

Documentation for apex:param doesn't state it can be a child of apex:commandButton

Instead try using an apex:CommandLink and style it like a button.

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