I have a custom visualforce page and controller extension that is working. There is one getter that I do not understand why it works. I was hoping someone could explain it to me. In the below code I do Public String merchantNumber{get;set;} and never give it a value. It is just an empty getter. And in my javascript I say sforce.console.openPrimaryTab(undefined, '/' + id, true, '{!merchantNumber}', 'Case On Tab');
The correct merchantNumber populates in the tabLabel when the page pops. How is this possible? Where is it getting the value from? It perplexes me because it is a variable I made up, it's not a custom field or object, and I don't define it. Any insight would be great!
VFP:
<apex:page id="casesOnCase" standardController="Case" extensions="casesOnCaseController">
<apex:includeScript value="/support/console/26.0/integration.js"/>
<script type="text/javascript">
function openPrimaryTabCase(){
var href = event.currentTarget.href;
console.log(href);
var arrayItem = href.split('.com/');
var endIndexOfSubstring = arrayItem[1].indexOf('/');
var id;
if (endIndexOfSubstring === -1) {
id = arrayItem[1];
console.log('this is href2: ' + id);
}
else {
id = arrayItem[1].substring(0, endIndexOfSubstring);
console.log('this is href: ' + id);
sforce.console.openPrimaryTab(undefined, '/' + id, true, **'{!merchantNumber}'**, 'Case On Tab');
}
}
</script>
<apex:pageBlock >
<apex:pageBlockTable value="{!caseOnCase}" var="item">
<apex:column headerValue="Merchant Number"><apex:outputLink value="{!URLFOR($Action.Case.View, item.Id)}" onclick="openPrimaryTabCase(); return false;">{!item.Merchant_Number__c}</apex:outputLink></apex:column>
<apex:column headerValue="Created Date" value="{!item.CreatedDate}"/>
<apex:column headerValue="Returned Payment Type" value="{!item.Returned_Payment_Type__c}"/>
<apex:column headerValue="Collections Status" value="{!item.Collections_Status__c}"/>
<apex:column headerValue="Status" value="{!item.Status}"/>
<apex:column headerValue="Owner Name" value="{!item.Owner.Name}"/>
<apex:column headerValue="Opportunity Name" value="{!item.Opportunity__r.Name}"/>-->
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Controller:
public with sharing class casesOnCaseController {
public List<Case> caseOnCase {get;set;}
public Id strAccountId;
public String currentPageId {get;set;}
public String bananass {get;}
**Public String merchantNumber{get;set;}**
public casesOnCaseController(ApexPages.StandardController controller) {
system.debug('this is the bananass: ' + bananass);
currentPageId = controller.getRecord().id;
system.debug('this is the currentpageid: ' + currentPageId);
if (currentPageId != NULL) {
List<Case> merchNumber = [SELECT AccountId FROM Case WHERE Id = :currentPageId LIMIT 1];
for (Case c : merchNumber) {
strAccountId = c.AccountId;
system.debug('this is the bananass in for loop: ' + bananass);
}
caseOnCase = [SELECT Merchant_Number__c, CreatedDate, Returned_Payment_Type__c, Collections_Status__c, Status, Owner.Name, Opportunity__r.Name, CaseNumber FROM Case Where AccountId = :strAccountId AND Id != :currentPageId ORDER BY CreatedDate DESC ];
system.debug('this is all of the cases: ' + caseOnCase);
}
}
}
UPDATE:
I should also mention, when I take out the merchantNumber getter, the page breaks as expected. When I add a value to merchantNumber, it is not dynamic and retains one value for all merchant numbers
UPDATE 2: Merchant Number is Null