I am adding the field value i.e number type with the apex:variable but getting the error
Incorrect parameter type for operator '+'. Expected Text, received Number
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityI am adding the field value i.e number type with the apex:variable but getting the error
Incorrect parameter type for operator '+'. Expected Text, received Number
I was able to get a very similar to piece of code to yours to work - but I found that I couldn't even compile the page using outputField
- You should only use outputField
for values that are directly tied to a sObject value.
Change to outputText
and also verify that wrapRec.T_Price__c
is in fact a number value.
Failing that, try wrapping the value to be added in a VALUE()
function.
EDIT Here is the code I used. I used a list of accounts in the controller.
<apex:pageBlock >
<apex:pageBlockSection columns="1" collapsible="false" >
<apex:pageBlockTable value="{!acctWrapper}" var="acct">
<apex:column value="{!acct.acctId}"/>
<apex:column value="{!acct.name}"/>
<apex:column >
<apex:variable var="total1" value="{!total1 + acct.num}" />
<apex:outputText value="{!total1}" />
</apex:column>
<apex:column >
<apex:variable var="total2" value="{!total2 + acct.num}" />
<apex:outputText value="{!total2}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
Here is the wrapper code:
public class Wrapper {
public String name {get; set;}
public Id acctId {get; set;}
public Integer num {get; set;}
public Wrapper(String name, Id acctId, Integer num) {
this.name = name;
this.acctId = acctId;
this.num = num;
}
}
And here is where I build the wrapper list:
//defined at top of class
public Wrapper[] acctWrapper {get; set;}
accounts = [SELECT Name, Id From Account LIMIT 20];
acctWrapper = new Wrapper[]{};
Integer count = 0;
for (Account a : accounts){
acctWrapper.add(new Wrapper(a.Name, a.Id, count));
count+=1;
}
apex:variable
- no errors.
– Caspar Harmer
May 4 '15 at 9:48