I have problem showing my map value to the visualforce page, in my controller I populate the maps and create below method
public Map<String, Decimal> getmapTargetCurrentMonth(){
return mapTargetCurrentMonth;
}
that will be invoked in VF page in apex:repeat class.
public with sharing class SignedRevenueTargetController{
//Set up all getter and setter method
public transient List<User> liactiveusers {get;set;}
public Date thismonth {get;set;}
public Date lastmonth {get;set;}
public String selectedmonth {get;set;}
public String selectedyear {get;set;}
//
PageReference homepage = new PageReference('/home/home.jsp');
//Set up all class variables
String country_iso = [SELECT License_Country__c FROM User WHERE ID =: UserInfo.getUserId()].License_Country__c;
Id signedTargetRecordType = Contract__c.getSObjectType().getDescribe().getRecordTypeInfosByName().get('Signed Revenue Target').getRecordTypeId();
Id contractRecordType = Contract__c.getSObjectType().getDescribe().getRecordTypeInfosByName().get('Contract').getRecordTypeId();
String currency_iso = [SELECT DefaultCurrencyIsoCode FROM User WHERE ID =: UserInfo.getUserId()].DefaultCurrencyIsoCode;
public Map<String, Decimal> mapTargetCurrentMonth {get;set;}
public Map<String, Decimal> mapTargetLastMonth {get;set;}
public Map<String, Decimal> mapCollectedLastMonth {get;set;}
List<Contract__c> listcurrentsignedtargets = new List<Contract__c>();
List<Contract__c> listprevioussignedtargets = new List<Contract__c>();
List<Contract__c> listpreviousactualsigned = new List<Contract__c>();
public void updateMapValues(Date thismonth){
mapTargetCurrentMonth = new Map<String, Decimal>();
mapTargetLastMonth = new Map<String, Decimal>();
mapCollectedLastMonth = new Map<String, Decimal>();
liactiveusers = [SELECT Id, Name FROM User WHERE License_Country__c =: country_iso AND isActive = TRUE AND TargetAccount__c <> null AND TargetContract__c <> null ORDER BY Name ASC];
FOR(User u : liactiveusers){
mapUserNames.put(u.Name, u.Id);
}
system.debug(liactiveusers);
//Sum up total invoices from active contract within this month
listcurrentsignedtargets = [SELECT TotalInvoiced__c, Attributedto__r.Name, Attributedto__c FROM Contract__c
WHERE RecordTypeId =: contractRecordType AND Activation_Date__c =: thismonth AND Attributedto__c in: liactiveusers];
//query orevious month target
listprevioussignedtargets = [SELECT TotalInvoiced__c, Attributedto__r.Name, Attributedto__c FROM Contract__c
WHERE RecordTypeId =: signedTargetRecordType AND Activation_Date__c =: lastmonth AND Attributedto__c in: liactiveusers];
//Sum up total actual signed revenue from previous month
listpreviousactualsigned = [SELECT TotalInvoiced__c, Attributedto__r.Name, Attributedto__c FROM Contract__c
WHERE RecordTypeId =: contractRecordType AND Activation_Date__c >=: lastmonth AND Activation_Date__c <: thismonth AND Attributedto__c in: liactiveusers];
IF(listcurrentsignedtargets.size() > 0){
FOR(Contract__c sign :listcurrentsignedtargets ){
mapTargetCurrentMonth.put(sign.Attributedto__r.Name, sign.TotalInvoiced__c);
}
IF(listprevioussignedtargets.size() > 0){
FOR(Contract__c sign :listprevioussignedtargets ){
mapTargetLastMonth.put(sign.Attributedto__r.Name, sign.TotalInvoiced__c);
}
}
IF(listpreviousactualsigned.size() > 0){
FOR(User u : liactiveusers){
Decimal signedByUser = 0;
FOR(Contract__c sign :listpreviousactualsigned){
system.debug(sign.TotalInvoiced__c);
IF(u.Id == sign.Attributedto__c){
signedByUser = signedByUser + sign.TotalInvoiced__c;
}
}
mapCollectedLastMonth.put(u.Name,signedByUser);
}
}
FOR(User u : liactiveusers){
IF(!mapTargetCurrentMonth.containsKey(u.Name)){
mapTargetCurrentMonth.put(u.Name, 0);
}
IF(!mapTargetLastMonth.containsKey(u.Name)){
mapTargetLastMonth.put(u.Name, 0);
}
IF(!mapCollectedLastMonth.containsKey(u.Name)){
mapCollectedLastMonth.put(u.Name, 0);
}
}
}
}
}
I want to show value from the map
public Map<String, Decimal> mapTargetCurrentMonth {get;set;}
public Map<String, Decimal> mapTargetLastMonth {get;set;}
public Map<String, Decimal> mapCollectedLastMonth {get;set;}
and this is my visualforce page,
here the apex:repeat does not show the value I want and even <apex:inputText value="{!mapTargetCurrentMonth[person]}"/>
doesnt show the input field
<apex:page controller="SignedRevenueTargetController">
<apex:form >
<apex:pageBlock title="Target Setting for {!selectedmonth}.{!selectedyear}." mode="edit">
<!-- <apex:pageBlockButtons >
<apex:commandButton action="{!submitFieldData}" value="Submit" id="button" rerender="box"/>
</apex:pageBlockButtons>-->
<apex:outputPanel id="lalala" layout="block">
<apex:pageBlockSection columns="4">
<apex:pageBlockSectionItem >
<apex:outputtext value="User" style="font-weight:600; font-size:14px"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputtext value="Target {0, date, MMMM ',' yyyy}" style="font-weight:600; font-size:14px">
<apex:param value="{!lastmonth}" />
</apex:outputText>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputtext value="Actual Collected {0, date, MMMM ',' yyyy}" style="font-weight:600; font-size:14px">
<apex:param value="{!lastmonth}" />
</apex:outputText>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputtext value="Target {0, date, MMMM ',' yyyy} (Including Tax!)" style="font-weight:600; font-size:14px">
<apex:param value="{!thismonth}" />
</apex:outputText>
</apex:pageBlockSectionItem>
<apex:repeat value="{!mapTargetCurrentMonth}" var="person">
<apex:outputText value="{!person}" style="font-weight:600"/>
<apex:outputText value="{0,number,#,##0}">
<apex:param value="{!mapTargetLastMonth[person]}" />
</apex:outputText>
<apex:outputText value="{0,number,#,##0}">
<apex:param value="{!mapCollectedLastMonth[person]}" />
</apex:outputText>
<apex:inputText value="{!mapTargetCurrentMonth[person]}"/>
</apex:repeat>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>-->
</apex:page>
my maps do have some values as seen in developer console, so in theory I should be able to refer the map in visualforce but apparently its not working.