You need to sign in to do that
Don't have an account?
srinivas pulipati
hi,i am writing apex code but i got error please solve this error ,vf page also execute but apex code have error
Apexcode:
public with sharing class relatedcontacts {
public relatedcontacts(){
AccountData();
}
list<Account> lstacc = new list<Account>();
list<accountwrapclass> lstAccwrap = new list<accountwrapclass>();//[Error] Error: Compile Error: Invalid type: accountwrapclass at line 6 column 47
public list<accountwrapclass> getAccounts() {
// lstacc=[select id,name,phone,website,taxable__c from Account];
return lstAccwrap ;
}
public void AccountData(){
for(Account acc:[select id,name,phone,website from Account]){
accountwrapclass objacc = new accountwrapclass();
objacc.Name = acc.Name;
objacc.accid = acc.id;
objacc.phone = acc.phone;
objacc.website = acc.website;
/*if(acc.taxable__C == true){
objacc.taxable ='yes';
}else{
objacc.taxable ='NO';
}*/
lstAccwrap.add(objAcc);
}
}
}
Vfcode:
<apex:page controller="relatedcontacts">
<script>
function showModal(val){
//window.showModalDialog('/apex/secondpage?id='+val);
window.showModalDialog('/apex/contactswithcheckbox?id='+val);
}
</script>
<apex:form >
<apex:pageblock >
<apex:pageBlockSection title="Records">
<apex:pageBlockTable value="{!Accounts}" var="a">
<apex:column headerValue="Name">
<apex:commandlink value="{!a.Name}" onclick="showModal('{!a.accid}')" />
</apex:column>
<apex:column headerValue="phone" >
{!a.phone}
</apex:column>
<apex:column headerValue="website" >
{!a.website}
</apex:column>
<apex:column headerValue="taxable" >
{!a.taxable}
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
public with sharing class relatedcontacts {
public relatedcontacts(){
AccountData();
}
list<Account> lstacc = new list<Account>();
list<accountwrapclass> lstAccwrap = new list<accountwrapclass>();//[Error] Error: Compile Error: Invalid type: accountwrapclass at line 6 column 47
public list<accountwrapclass> getAccounts() {
// lstacc=[select id,name,phone,website,taxable__c from Account];
return lstAccwrap ;
}
public void AccountData(){
for(Account acc:[select id,name,phone,website from Account]){
accountwrapclass objacc = new accountwrapclass();
objacc.Name = acc.Name;
objacc.accid = acc.id;
objacc.phone = acc.phone;
objacc.website = acc.website;
/*if(acc.taxable__C == true){
objacc.taxable ='yes';
}else{
objacc.taxable ='NO';
}*/
lstAccwrap.add(objAcc);
}
}
}
Vfcode:
<apex:page controller="relatedcontacts">
<script>
function showModal(val){
//window.showModalDialog('/apex/secondpage?id='+val);
window.showModalDialog('/apex/contactswithcheckbox?id='+val);
}
</script>
<apex:form >
<apex:pageblock >
<apex:pageBlockSection title="Records">
<apex:pageBlockTable value="{!Accounts}" var="a">
<apex:column headerValue="Name">
<apex:commandlink value="{!a.Name}" onclick="showModal('{!a.accid}')" />
</apex:column>
<apex:column headerValue="phone" >
{!a.phone}
</apex:column>
<apex:column headerValue="website" >
{!a.website}
</apex:column>
<apex:column headerValue="taxable" >
{!a.taxable}
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
In your apex class you have not defined the wrapper class, that is why you are getting error.
I have modified your controller class.
Please change class code with below code: Let me know if you have any issue.
Thanks,
Abhishek
All Answers
In your apex class you have not defined the wrapper class, that is why you are getting error.
I have modified your controller class.
Please change class code with below code: Let me know if you have any issue.
Thanks,
Abhishek