0

I am trying to find a method to query a certain dynamic value and make the results visible in the standardController. Background: we want to display all leads who have the same date field as the actual shown lead. Can someone please tell me how the logic is called so I can make further research.

This is my code so far but I am not sure if this is the right thought.

public with sharing class e2 {

public e2(Lead controller) {
}
public e2(ApexPages.StandardSetController controller) {

}

public Id currentId = null;

public e2(ApexPages.StandardController controller) {
 currentId = controller.getRecord().Id;

}

  List<Lead> eL = [SELECT Datum_Event__c FROM Lead WHERE Id = :currentId];

 List<Lead> geteL(){
     return eL;
 }
}
0

You can remove all of this code:

public e2(Lead controller) {
}
public e2(ApexPages.StandardSetController controller) {
}

You don't need it.

This code:

List<Lead> eL = [SELECT Datum_Event__c FROM Lead WHERE Id = :currentId];

is in the wrong place, and you do not need

List<Lead> geteL(){
     return eL;
 }

if you use Visualforce getter/setter syntax:

public List<Lead> eL { get; set; }

which will make the property available to your page.

You should initialize your list inside the constructor after you acquire the record Id. currentId is null at the point during the class initialization process when that member variable assignment is executed, because the constructor hasn't gone off yet.

The relevant documentation for building custom Visualforce controllers is located in the Visualforce Developer Guide.

  • @ David Reed Hello and thank you again. May I actualize the code in here or should I start a new question? It is still the same question I think. – Con May 6 at 10:48
  • @Con I'm not totally sure what you mean by "actualize"; I would request that you not change the contents of your question in a way that would make this answer irrelevant or nonsense, because that diminishes the value of questions to the broader community. Does that make sense? – David Reed May 6 at 11:13
  • @ David Reed If I apply the changes in the code as you suggested, should I do this by an answer, so the community has a final code that works? By the way, I am far away from that :) – Con May 6 at 11:41
  • @Con You don't need to post "final product" as an answer. You may answer your own question if you discover a solution or it is has not been covered already. The way you can indicate to the community that your question is resolved is to mark an answer as accepted, whether your own or someone else's. – David Reed May 6 at 14:11
  • @ David Reed I tried out your code correction. I could save it.. but the visual force page doesn´t show the results. It is empty. There might be something missing. Maybe I did not exactly understand the structure. Just for understanding. You suggested to put all the logic into one custom controller and an extension is not needed. So all the neccessary code is written in the controller. I couldn't find a source that explains the cunstructor as a filter. A blueprint would help me a lot to understand the whole logic. I am totallly done -_- I am sitting on this for days now I practised a lot... – Con May 6 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.