Questions tagged [constructor]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
53 views

Constructor Syntax in Batch Class

I'm new to the development side with no real development background in any language. So I wrote this batch class, and I can't quite figure out how to implement the proper syntax for the constructor. ...
0
votes
1answer
30 views

Variable remains empty after initialization

Simple Apex (Java actually) question, after I initialized the variable 'a' in a constructor, I tried to access it with a different method but it remains null. Class FirstClass{ String a; ...
-1
votes
1answer
20 views

Initializing an instance variable

What are the benefits of initializing an instance variable in an instance block rather than constructor of the class?
2
votes
1answer
51 views

How to disable constructors in custom exceptions?

There is a lot out there on how you can't override exception constructors and how to do custom exceptions, but I haven't been able to find anything on disabling a constructor for an extended class. I'...
-1
votes
1answer
61 views

Create a constructor for an outer class with inner classes that have constructors?

What would a constructor for the outer class of the following look like? public class outerClass { public Data data {get;set;} public class Attributes { public String symbol {get;...
0
votes
1answer
172 views

Batch Test class Constructor Not Defined problem [duplicate]

I have the following problem in a test class. Constructor not defined: [Soma_Dependentes_Update].<Constructor>() Test class of the batch process: @isTest public class ...
0
votes
1answer
100 views

Constructor not defined error on Event trigger

I'm fairly new to development but I'm currently trying to move some triggers into classes to follow the one trigger per object design pattern. I'm getting the following error in the trigger: ...
0
votes
1answer
178 views

Constructor not defined executeBatch trigger to pass ID to batch class

Ok...trying to write my first class and trigger and running into a wall that I can't seem to get over on my own. Use case: on a custom object called manufacturer__c, when a field goes to "in Process" ...
2
votes
1answer
651 views

Call Parametrized constructor using Type.newInstance()?

I am designing a solution where it should be flexible to add handlers using configuration. So I am saving the handler class name in the custom metadata record and then would be instantiating it using ...
2
votes
1answer
392 views

Return null instance when constructor parameter is null

So I want to have some sort of condition like this: public Foo( Id baz ){ if(baz == null){ return null; } else { this.entry.baz = baz; } } ...
-2
votes
1answer
370 views

String value from constructor to Apex methods

I have set a value to a static string variable in constructor and while I try to access that value in my apex methods , I always receives as NULL. public class Mycontroller { public static string ...
0
votes
3answers
507 views

Use Type class to call parameterized constructor

Using this to get below working: public class t12345 implements Database.Batchable<sObject> { String query; Boolean xyz; public t12345(String query){ ...
0
votes
1answer
20 views

(re)Scheduled class with count. Initialized to 0, increased to 2. Don't understand why

I have a schedulable class that will be rescheduled again. This class contains a count. Here is how it is supposed to work constructor set count to 0 a run method increase count then test condition ...
2
votes
1answer
747 views

Setting field value in sObject constructor vs after instantiation

My question: Why can you set a value of a field like ParentId on the CaseTeamTemplateRecord object in the constructor during instantiation, but receive an exception if you set the value after ...
0
votes
1answer
475 views

how to call the constructor of the apex controller in the test class

Below is my controller class. Public class VMSalesOrderUserEditpage{ public list<VM_Sales_Order__c> vmList{get;set;} public VM_Sales_Order__c VMSOrd {get;set;} public string vmId {get;set;} ...
0
votes
1answer
207 views

Pass public string value from constructor to apex page

I have been setting a public string from apex controller's constructor at the end. I can see that value in debug log. But when I pass that to Apex page it shows null. Can someone please let me know ...
2
votes
1answer
464 views

StandardSetController Test Class - 'Constructor not defined'

I am trying to write a test class for a StandardSetController with a very simple extension that processes a list of records that were selected from a related list. I am coming up short on how to get ...
4
votes
1answer
56 views

Why does this() in an if statement not throw compiler error

Using 'this();' inside an if statement in a constructor does not throw a compiler error. It should throw 'Call to 'this()' must be the first statement in a constructor'; If it is allowed then it ...
1
vote
0answers
391 views

VisualForce: Dynamic Page Headers based on Parameters works as expected until adding actions to page

Background: I am working on a VisualForce page to allow our customers to 'Add to Calendar' from an email alert that they receive when we book an Event. The Apex page takes 2 parameters right now, ...
0
votes
2answers
425 views

Defining Constructor [closed]

When I try to run my codes they keep on giving me an error saying Constructor not Define [testFBInt].<Constructor>(). I do not understand whats the problem and why it keep on giving me that ...
0
votes
2answers
175 views

What fields and syntax for constructor to create records to add to a list<object>

So I'm creating a list of child records for a parent using a loop. Is there a way I can create the child record as I add it to the list instead of creating the object and setting the variables? list&...
1
vote
1answer
448 views

Extension/Constructor on a Component

I have a Component inside of a Visualforce Page. I am not sure if this line of connection is causing a break but my issue is with my constructor. It is not taking in the params I am passing: Page: &...
0
votes
2answers
55 views

Class with a constructor that loads all sObjects given a user record

I'm trying to build a class that will gather user information across multiple sObjects. The class needs a constructor that loads all sObjects given a user record. This will be the current user logged ...
1
vote
1answer
162 views

Calling Controller of Apex Class

Below is my Apex Class. public class OptySaleTaxCalcController { public List<Account_Address__c> AccountaddressList; public AcctSeedERP__Sales_Order__c salesOrder; public ...
11
votes
3answers
4k views

Call to another constructor must be the first statement in constructor block

I am confused why the following pattern's call to the other constructor block does not count as the first statement in the constructor block: public class MyClass { final String someProperty; ...