function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Laura KeetonLaura Keeton 

Obtain Account ID using ApexPages getparameters

I'm a newbie to Salesforce and Apex.  I have a requirement to create a dynamic banner for Account pages based on criteria from another object where the options are entered by the user.  So I'm adding a new visualforce page (which will be the banner) to the Account object.  I'm can't seem to retrieve the current account ID from the account page.

Visualforce:
<apex:page standardcontroller="Account" extensions="clsPartnerBanner">
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/11.1/connection.js"></script>
<style>
.banner
{
    text-align:center;
    font-weight:bold;
    font-size:150%;
    padding:17px;
    width:80%;
    height:80x;
}
</style>

    <apex:repeat value="{!lstPB}" var="pb" >
    <apex:repeat value="{!acct}" var="a" >
        <div render="!if(!a.Id == !pb.Organization__c, true, false)" style="background-color : {!pb.Banner_Background__c};" class="banner">
            <apex:outputPanel >
                <apex:outputText value="{!a.Industry}"></apex:outputText><br/>
                <apex:outputText value="{!a.Phone}"></apex:outputText><br/>
                <apex:outputText value="{!pb.Message__c}"></apex:outputText><br/>
                <apex:outputText value="{!pb.Contact_Email__c}"></apex:outputText><br/>
                <apex:outputText value="{!pb.Contact_Phone__c}"></apex:outputText>
                <apex:outputText value="{!a.Id}"></apex:outputText>
            </apex:outputPanel>
         </div>
    </apex:repeat>
    </apex:repeat>
</apex:page>

Apex:
<apex:page standardcontroller="Account" extensions="clsPartnerBanner">
<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/11.1/connection.js"></script>
<style>
.banner
{
    text-align:center;
    font-weight:bold;
    font-size:150%;
    padding:17px;
    width:80%;
    height:80x;
}
</style>

    <apex:repeat value="{!lstPB}" var="pb" >
    <apex:repeat value="{!acct}" var="a" >
        <div render="!if(!a.Id == !pb.Organization__c, true, false)" style="background-color : {!pb.Banner_Background__c};" class="banner">
            <apex:outputPanel >
                <apex:outputText value="{!a.Industry}"></apex:outputText><br/>
                <apex:outputText value="{!a.Phone}"></apex:outputText><br/>
                <apex:outputText value="{!pb.Message__c}"></apex:outputText><br/>
                <apex:outputText value="{!pb.Contact_Email__c}"></apex:outputText><br/>
                <apex:outputText value="{!pb.Contact_Phone__c}"></apex:outputText>
                <apex:outputText value="{!a.Id}"></apex:outputText>
            </apex:outputPanel>
         </div>
    </apex:repeat>
    </apex:repeat>
</apex:page>
Daniel Zeidler (DZ)Daniel Zeidler (DZ)
It looks like you resposted your visualforce page instead of posting your controller.

Anyway, there is a better way to get the Id then using ApexPages' getParameters method.

You can get the Id from the standard controller passed in to the controller externsion's constructor.

For example:
 
public Id accountId {get; set;}

public clsPartnerBanner(ApexPages.StandardController stdController) {
        this.accountId= stdController.getId();
}