---
schema_version: "1"
id: 331105dbedfd6db64c19ca26f7408036d6bac2759f9cc73c365eace7322b258f
title: Getting and Setting Query String Parameters on a Single Page
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/quick-start/pages-quick-start-query-params-getting-setting.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-quick-start-query-params-getting-setting.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 11ebff387121497e2a9fc9ea9649da50f7fe73bcad680c7f4d5055e4cfc98548
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# 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.

This is possible by:

-   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.

<!-- otherprops: apex_page set_clipboard -->
```markup
<apex:page standardController="Account">
    <apex:pageBlock title="Hello {!$User.FirstName}!">
        You are displaying contacts from the {!account.name} account. 
        Click a contact's name to view his or her details.
    </apex:pageBlock>
    <apex:pageBlock title="Contacts">
        <apex:form>
            <apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4" 
                               border="1">
              <apex:column>
               <apex:facet name="header">Name</apex:facet>
               <apex:commandLink>
                 {!contact.Name}
                 <apex:param name="cid" value="{!contact.id}"/>
               </apex:commandLink> 
              </apex:column>
              <apex:column>
               <apex:facet name="header">Phone</apex:facet>
               {!contact.Phone}
              </apex:column>
            </apex:dataTable>
        </apex:form>
    </apex:pageBlock>
    <apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="false" title="false"/>
</apex:page>
```

After saving this markup, refresh your browser with the `id` query string parameter but without the `cid` parameter in the URL For example,

```nolang
https://MyDomain_login_URL/apex/MyFirstPage?id=001D000000IRt53
```

Initially the contact detail page is not rendered, but when you click a contact name the page renders the appropriate detail view.

**note:** If you use the `id` parameter in a URL, it must refer to the same entity referred to in the standard controller.

**See Also**  


-   [Controller Methods](https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/controller/pages-controller-methods.md)

