You need to sign in to do that
Don't have an account?
Terry411
Unknown Constructor
Gosh guys/gals... sometimes I just don't get it... I've seen scores of other post with this same issues and feel like I've tried most of them and still can't resolve this error. I must be missing something but I'm new enough to not know what it is. Thanks for any help.
error: Unknown constructor 'conQuickEmail.conQuickEmail(ApexPages.StandardController controller)'
Here's my VF page's controller line:
<apex:page standardController="lead" extensions="conQuickEmail" id="page" tabStyle="lead">
Here's my latest try for the controller:
public with sharing class conQuickEmail { private final ApexPages.StandardSetController stdController; public conQuickEmail(ApexPages.StandardSetController controller) { this.stdController = (Lead)stdcontroller.getRecord(); // <-- this is line 23 // rest of the code }
Here's my test class which gives me this error: error: Variable does not exist: ApexPages.StandardSetController
private static testmethod void quickEmailTests() { Lead l = [select id from Lead where EmailBouncedDate = null and email != null limit 1]; PageReference testPage = Page.Quick_Email; testPage.getParameters().put('rec',l.id); testPage.getParameters().put('retURL','/home/home.jsp'); Test.setCurrentPage(testPage); conQuickEmail controller = new conQuickEmail(ApexPages.StandardSetController(l)); controller.send(); Lead l2 = [select id from Lead where EmailBouncedDate = null and email != null limit 1]; testPage = Page.Quick_Email; testPage.getParameters().put('rec',l2.id); testPage.getParameters().put('retURL','/home/home.jsp'); Test.setCurrentPage(testPage); controller = new conQuickEmail(ApexPages.StandardSetController(l)); controller.send(); controller.cancel();
You need to actually create a standard controller object to pass to your extension controller constructor:
Something like
I made the change you recommended. (see updated code above). I now have the following errors:
error: Illegal assignment from SOBJECT:Lead to ApexPages.StandardSetController line 23
error: Unknown constructor 'conQuickEmail.conQuickEmail(ApexPages.StandardController controller)' Quick_Email.page line 0
I really appreciate any help. Been trying to correct this for hours.
Use this it should work for you
The mistake was that StandardSetController should always take a list of object. In your test emthod you were passing only object instance of lead. I updated it to pass list of lead.
I hope it will help you.
I don't know yet your requirements but please try these suggestions :)
Change your constructor to ApexPages.StandardController instead of ApexPages.StandardSetController.
Next, create a variable for ApexPages.StandardController that will hold the value that is passed in the constructor
If you need to get a record for a lead record.. you should create a variable container for it.
so your final code should look like this:
I just code it here and haven't tested it in a compiler.. maybe a little error might come up but I think you can handle it now. Also, I don't know why you need an ApexPages.StandardSetController for. I'm new to Salesforce development as well so I don't know much about such syntax yet haha.
error: Unknown constructor 'conQuickEmail.conQuickEmail(ApexPages.StandardController controller)' <-- based on this error, the final code that I suggested should work. I didn't look into your test method any further for I haven't made at least one yet hahaha :)
Hope this could help you.
Best Regards,
Pat
@Pat,
Thanks for your response. So far none of the suggestions have worked. Maybe I'm simply going down the wrong path. What I have is a VF page that I'm trying to call with a custom List Button from the Lead tab. The basic issue I was originally trying to solve was the issue of my VF Page not displaying as an Option in the New custom Button or Link page. When looking for solutions for this everything was pointing to syntax using a Standard Controller and the ApexPages.Standard (Set) Controller format when calling the controller. Technially, I don't believe I even need the standard controller in my code unless that is the key to setting up the custom button.
The actual code is very similar to the standard code Salesforce used for their Mail Merge. The unique part of my code is that it automatically loads a specific email template. There's nothing spectacular going on. Does that help?
Did you tried this
Please let me know if any issue comes. I think this should work.
I think my issue is a data problem... I just realized the dev environment I'm in doesn't have valid data so the tests are returning no records. Sorry everyone. I'll get that corrected and hopefully the problems will be eliminated as well. I'm getting good as not seeing the tress for the forest.