3

I have this page

<apex:page standardController="contact" recordSetVar="c">
    <apex:form>
        <apex:dataTable value="{!c}" var="var">
            <apex:column>
                <apex:facet name="header">Name</apex:facet>
                <apex:commandLink reRender="det">{!var.name}
                    <apex:param name="cid" value="{!var.id}" />
                </apex:commandLink>
            </apex:column>
        </apex:dataTable>
        <apex:outputpanel id="det">
            <apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false" />
        </apex:outputpanel>
    </apex:form>
</apex:page>

It works fine when i call page like

https://c.na15.visual.force.com/apex/testpage5

But when i call page like this it doesnt

https://c.na15.visual.force.com/apex/testpage5?cid=003i000000m6n5GAAQ

which means if i give a cid parameter already on page load,then when i select a contact value doesn't get updated in apex:detail

Whats happening here?

2
  • I'd hazard a guess that it involves the rerender. What happens if you remove the rerender?
    – sfdcfox
    May 23, 2014 at 0:42
  • tried removing re-render..doesnt make any difference
    – sfdc99999
    May 23, 2014 at 11:11

2 Answers 2

2

Not sure why it doesn't update the parameter, but could you perhaps use a different ID in the URL when loading the page?

<apex:detail subject="{!IF($CurrentPage.parameters.cid != null, $CurrentPage.parameters.cid, $CurrentPage.parameters.contactId)}" relatedList="false" title="false" />

So you'd use contactId when calling the page from elsewhere and just cid in the page as before. Seems weird that the parameter can be recycled within the page but not when it's used in the original URL.

1

The only way I was able to get this to work was when I changed your <apex:commandLink /> to an <apex:outputLink /> tag and specified the page name for the value of the link, which creates the appropriate URL on the hyperlinks with the cid parameter - and the page works great.

Using the commandLink markup with or without a rerender attribute made no difference here, the detail always showed the Contact details that were initially loaded.

<apex:page standardController="contact" recordSetVar="c">
    <apex:form>
        <apex:dataTable value="{!c}" var="var">
            <apex:column>
                <apex:facet name="header">Name</apex:facet>
                <apex:outputLink value="{!$Page.ThisPageName}">{!var.name}
                    <apex:param name="cid" value="{!var.id}" />
                </apex:outputLink>
            </apex:column>
        </apex:dataTable>
        <apex:outputpanel id="det">
            <apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false" />
        </apex:outputpanel>
    </apex:form>
</apex:page>
2
  • whats the reason why you think we have to explicity pass the page name to outputlink...it also works as laceysnr suggested if you specify a different parameter name from what it is on orginal page load.any reason you can think of?
    – sfdc99999
    May 23, 2014 at 11:17
  • 1
    If it works without the pagename in the outputLink, that's fine. I did not test that. As for the two parameter name mechanism working: during the commandlink's operation you'll have two parameters being sent to the page controller with the same key, cid, one with the value contained in the URL and one from the commandLink's parameter value, and apparently the one from the URL 'wins' in this situation. Both of these values end up in the page parameters collection and multiple values for the same key results in an overwriting "last one wins" situation.
    – Mark Pond
    May 23, 2014 at 16:33

You must log in to answer this question.

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