Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Getting and Setting Query String Parameters on a Single Page
Having seen examples of both getting and setting query string parameters, this example shows how the two actions can be combined on a single page to produce a more interesting result. Based on the example from Getting Query String Parameters, the following page makes the name of each contact in the list a hyperlink that controls the context of the detail component below it.
- Wrapping the data table in an <apex:form> tag
- Turning each contact name into an <apex:commandLink> that sets the cid parameter appropriately with an <apex:param> tag
When used with a standard controller, command links always entirely refresh the current page with the new information added to the page—in this case, an updated cid that updates the contact detail component.
1<apex:page standardController="Account">
2 <apex:pageBlock title="Hello {!$User.FirstName}!">
3 You are displaying contacts from the {!account.name} account.
4 Click a contact's name to view his or her details.
5 </apex:pageBlock>
6 <apex:pageBlock title="Contacts">
7 <apex:form>
8 <apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4"
9 border="1">
10 <apex:column>
11 <apex:facet name="header">Name</apex:facet>
12 <apex:commandLink>
13 {!contact.Name}
14 <apex:param name="cid" value="{!contact.id}"/>
15 </apex:commandLink>
16 </apex:column>
17 <apex:column>
18 <apex:facet name="header">Phone</apex:facet>
19 {!contact.Phone}
20 </apex:column>
21 </apex:dataTable>
22 </apex:form>
23 </apex:pageBlock>
24 <apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false"/>
25</apex:page>1https://MyDomain_login_URL/apex/MyFirstPage?id=001D000000IRt53