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?

3

2 Answers 2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .