You need to sign in to do that
Don't have an account?

Issue with wrapper class.
VF Page-
<!----------- Creating this page for dispaly Opportunity fields object in single table with check box ---------->
<apex:page controller="WrapperIntStringDisplayClass">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!lstwrapperIntString}" var="w">
<apex:column headervalue="click2Select">
<apex:inputcheckbox />
</apex:column>
<apex:column headervalue="Opportunity fields">
{!w.Id}
{!w.Name}
{!w.Amount}
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class-
public with sharing class WrapperIntStringDisplayClass {
public List<wrapper> lstwrapperIntString {get;set;}
public WrapperIntStringDisplayClass(){
lstwrapperIntString = new List<wrapper>();
for(opportunity opp : [select Id, Name,Amount from opportunity]){
lstwrapperIntString.add(new wrapper(opp.Id,opp.Name,opp.Amount));
}
}
//Wrapper Class Construction
public class wrapper{
public String Id{get;set;}
public String Name{get;set;}
public Double Amount{get;set;}
// Wrapper class constructor
public wrapper(String Id,String Name,Double Amount ){
this.Id=Id;
this.Name=Name;
this.Amount=Amount;
}
}
}
I am getting Below error-
[Error] Error: WrapperIntStringDisplayClass Compile Error: Constructor not defined: [WrapperIntStringDisplayClass.wrapper].<Constructor>(Id, String, Decimal) at line 7 column 37
Can anyone help in this.
<!----------- Creating this page for dispaly Opportunity fields object in single table with check box ---------->
<apex:page controller="WrapperIntStringDisplayClass">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!lstwrapperIntString}" var="w">
<apex:column headervalue="click2Select">
<apex:inputcheckbox />
</apex:column>
<apex:column headervalue="Opportunity fields">
{!w.Id}
{!w.Name}
{!w.Amount}
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class-
public with sharing class WrapperIntStringDisplayClass {
public List<wrapper> lstwrapperIntString {get;set;}
public WrapperIntStringDisplayClass(){
lstwrapperIntString = new List<wrapper>();
for(opportunity opp : [select Id, Name,Amount from opportunity]){
lstwrapperIntString.add(new wrapper(opp.Id,opp.Name,opp.Amount));
}
}
//Wrapper Class Construction
public class wrapper{
public String Id{get;set;}
public String Name{get;set;}
public Double Amount{get;set;}
// Wrapper class constructor
public wrapper(String Id,String Name,Double Amount ){
this.Id=Id;
this.Name=Name;
this.Amount=Amount;
}
}
}
I am getting Below error-
[Error] Error: WrapperIntStringDisplayClass Compile Error: Constructor not defined: [WrapperIntStringDisplayClass.wrapper].<Constructor>(Id, String, Decimal) at line 7 column 37
Can anyone help in this.
public wrapper(String Id,String Name,Decimal Amount )
public Decimal Amount{get;set;}
It works now.