Questions tagged [getter]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
123 views

Setter is not getting invoked ,Could anyone please help me understand the flow and how to get setter invoked?

Html File <template> <lightning-input label="Enter your First Name" onchange={captureFName}></lightning-input> <lightning-input label="Enter your Last Name&...
sfdcgv's user avatar
  • 29
2 votes
1 answer
213 views

If I use a { get; set; } on a field in a Global class, will that get/set be public or global?

If I have a class that is global and I use the getter setter implementation: Integer myInt { get; private set; } Will my variable myInt be a global or a public variable?
David's user avatar
  • 33
0 votes
1 answer
409 views

Unable to call child getter from parent getter

I'm trying to perform the following: calling from a parent getter to child getters to retrieve information at parent level. Each child is a complex object that can change, and I need to locally know ...
user3529582's user avatar
1 vote
1 answer
62 views

Unknown Property Error "Create Apex Property" when creating Visual Forcepage

I am attempting to save a Visual Force page that is accepting input values from a flow and passing them into an invocable method. It keeps saying the custom object I'm using in the invocable method is ...
user avatar
2 votes
1 answer
188 views

Accessing Private Setters Through Client Code

While reading the docs on apex properties I noticed that you can use access modifiers on class instance property getters / setters. While playing around with private setters and running a few examples ...
Ricky Viejo's user avatar
0 votes
1 answer
770 views

How can I set; a map<String,String> in one method and use it in another method?

I have two methods 1) getSiteIds and 2) fetchSession. In the first method getSideIds I want to populate an empty Map<String,String> siteIds = new Map<String,String(); with (name, id): Map<...
Stojchesky's user avatar
4 votes
1 answer
560 views

An alternative to reassigning objects and @track for providing reactivity of getters?

A change of a simple variable mentioned in a getter will trigger a re-render. Why is this not a common pattern to trigger re-rendering in case of object changes? Let me explain. LWC components ...
Felix van Hove's user avatar
0 votes
1 answer
1k views

LWC: setting child component width dynamically from parent

i'm doing this tutorial on "Parent To Child Component Communication Using LWC" (added with time markers: https://youtu.be/eiTPjZ5nL2w?t=3134 The issue is this error: As this is in the ...
Luis Aguiar's user avatar
1 vote
4 answers
3k views

getter vs setter in LWC

Can a getter do everything that a setter can do? For example, uppercaseItemName; @api get itemName() { return this.uppercaseItemName; } set itemName(value) { this.uppercaseItemName = value....
Suhasini's user avatar
  • 307
-1 votes
1 answer
395 views

SOQL statement inside a getter/setter - what benefits?

I've seen some SOQL done in a getter as such: public static Map<String, sObjectHere> methodName { get { someMapHere = new Map<String, sObjectHere>(); ...
erikvm's user avatar
  • 721
-4 votes
1 answer
606 views

Test class for setters & getters in virtual class [closed]

How to write test class to cover setters and getters in virtual class. Please help to get code coverage for the below class public virtual class TriggerHandlerExtension { public List<String&...
Chandrasekhar's user avatar
1 vote
1 answer
390 views

Understanding LWC without APEX?

I made a post under the title a few days ago called "Conditional Rendering of a Form Based on Case Status LWC (if:true)" In that post I talk about how I am trying to set an attribute to the ...
coinjar's user avatar
  • 23
0 votes
1 answer
22k views

Fetching record data from Apex in LWC

I am trying to display the account name in the HTML by fetching the data from apex controller. The getter method in the JS file is used to fetch the data from apex using the wire method and return the ...
Krishnamurthy's user avatar
11 votes
1 answer
4k views

LWC best practices: Getters for derived values vs. setters for controlling values

I'm aware of two separate ways to manage dynamic, derived values in Lightning Web Components, and I'd like to get a better idea of when to use each one. Here is a sample LWC: a repeatable row showing ...
Matthew Souther's user avatar
0 votes
1 answer
200 views

PageReference method not returning null

I have developed a Visualforce page that takes an input file from the user and does not let the user proceed to the next page only if they did not upload an attachment (attachment is null). However I ...
SpicyPat's user avatar
0 votes
1 answer
708 views

Variable is not visible - get set

I have a controller for a Visualforce page that uses a getter and setter method to initialize a custom object Application__c however it is throwing strange errors that I did not previously get when ...
SpicyPat's user avatar
0 votes
0 answers
185 views

Passing variable from apex class to vf page in lightning aura enabled class method

Can we pass a getter value from apex to VF page in lightning aura enabled classes? I have a class which has a variable defined public static Integer testvariable{get;set;} now I have an auraenabled ...
victor's user avatar
  • 5
1 vote
1 answer
309 views

FlowAttributeChangeEvent Data Overridden by getter method

I have a LWC component that exposes a variable called testData in lightning__FlowScreen. The testData property is used in screen to display text. <targetConfig targets="lightning__FlowScreen&...
lambad's user avatar
  • 385
1 vote
2 answers
2k views

Difference between getter ,connnectedcallback() in lwc .When to use Getter and when to use ConnectedCallback() in LWC

I need help in understanding the below issue. Looks like a bit weird one or might be i am not aware of basics of LWC. 3 ways to test and understand this :- Comment connectedCallback Code, In this ...
SFDC LWC's user avatar
3 votes
2 answers
24k views

When to use getter and setter instead of simple property (@api or @track) declaration in LWC?

For example, if I can use @track/@api xyz='stackexchange' and then access it later in the component directly, then why would I use something like this, get xyz { return 'stackexchange' }
Chaitanaya Sethi's user avatar
0 votes
1 answer
886 views

Use of getter and setter methods for each field in Wrapper classes

I understand that wrapper class is like a custom object that you can define in an Apex class but I am not sure why getter and setter methods are used for each field in a wrapper class. What is the ...
Krishnamurthy's user avatar
0 votes
0 answers
37 views

How to access a properties' get accessor of another instance within its class?

I have a simple class with a property and a parent that is of the same type. public class BasicProperty { private BasicProperty parentProp; private Integer myCounter = 0; public Integer ...
Semmel's user avatar
  • 2,272
2 votes
1 answer
1k views

template if:true with get variable is not working

I have a custom part of code that I want to be displayed based on a custom logic cmp: <template if:true={myvar}> <!-- custom code --> </template> js: @track data; get myvar(...
molinet's user avatar
  • 877
1 vote
1 answer
177 views

Custom component setter value being passed in to controller, but getter always returns null (or the initialized value)

The setup: I have a standard controller with two extensions on it. <apex:page standardController="Contact" showQuickActionVfHeader="false" extensions="ExtOne,ExtTwo"> <c:...
carnoldus's user avatar
0 votes
0 answers
296 views

Accessing variable from void method based on given argument

I need to take variable from my void method based on the given argument when calling the method in another class. template = //here I want to take variable "ExpiringContract" Below is the code; ...
Adnan Zahry's user avatar
2 votes
1 answer
2k views

LWC Conditional rendering: alternative for fetching the initial database value?

Looking for a conditional rendering solution in lwc, which uses the initial value of a field in the database to decide whether to render or not. I have found a way to get it working, but it seems like ...
Rut ger's user avatar
  • 33
2 votes
2 answers
5k views

LWC / Get fields values with getRecord and wire

I can't get fields values with getRecord adapter. Component shows passed recordId only. Where is the problem? Parent HTML: <template> <lightning-card title="My Trips"> ...
Ivan S.'s user avatar
  • 329
0 votes
2 answers
53 views

Problem with understanding way of work with VF page

So my task is to get two dates from user and based on that do some fancy logic which will result in creation of table with data requested. To begin with i wanted to create small VFpage with two ...
Marcin Trofiniak's user avatar
2 votes
2 answers
933 views

How to access Class members decorated using { get; set; }

I'm trying to save on boilerplate code so tried to use { get; set; } idiom, but the function will not resolve. This is the class with decorated properties. public class Counter { private static ...
Martin of Hessle's user avatar
2 votes
2 answers
46 views

Difference between using and not using get; set; in data passed from backend

What is the difference between using and not using get; set; in data passed from backend? I saw examples like this in Apex: using get; set; public with sharing class MyBackendController { ...
oobarbazanoo's user avatar
1 vote
1 answer
298 views

JQuery and Disabled Attributes

I am unable to get this bit of JS to work. I have a few questions: Am I not allowed to put the disabled attribute on the apex:inputField? Am I importing the JS url incorrectly? Is it possible that ...
Olivia's user avatar
  • 3,429
2 votes
1 answer
4k views

Need help to cover {get; set;} methods on a TestClass

i need some help on a TestClass as i said above, bellow i wil show you what the class looks like and the TestClass: APEX CLASS: public with sharing class DirectDebitController { public class ...
Nuno Carvalho's user avatar
1 vote
0 answers
335 views

Overloaded Getter Methods for Apex Property

I've a little confused by the order of execution in the following very useful class from Adrian Larson. If I call "get" with just an SObjectType, invoking the first method, the cache.containsKey(key) ...
Cleverlemming's user avatar
1 vote
2 answers
2k views

setting RecordType in Test Coverage

I am having trouble on a test that is setting a record type. I believe I am setting the record type the correct way, the test is passing, but my test coverage is telling me that no record type was set....
Olivia's user avatar
  • 3,429
1 vote
2 answers
594 views

Visualforce getters are called before setter when selecting a select option

I've noticed that when I have an <apex:selectList/> with a value attribute that calls a setter method to set a value in the controller all my getters get called before the initial set call ...
TemporaryFix's user avatar
  • 2,887
1 vote
2 answers
235 views

Setter value not arriving in apex class

I have a list that contains a collection of wrapper class instances called tacList. The wrapper class effectively contains a checkbox which relates to a case field and a string. The string is not ...
Jay's user avatar
  • 666
0 votes
0 answers
972 views

Getter and setter methods for wrapper class in salesforce

Please help me in clearing this doubt.. I have a wrapper class which I am using to store JSON values received from external system, on doing Json.deserialize it parses all the values as received. ...
Quddus's user avatar
  • 177
0 votes
0 answers
54 views

Why can't we use set(setter) without a get(getter)? [duplicate]

I need to just display the result of the user input field in following code: public class EX_1 { public Integer i1{set;} public Integer i2{set;} public Integer result=i1+i2; public Integer display(){ ...
Krishnan Mishra's user avatar
-5 votes
1 answer
974 views

Why is the setter method not working in the following code?

On running the following code in apex and visualforce respectively i am receiving following error: Error: Unknown property 'Setter_Method.Oportunities' Quick Fix Create Apex property '...
Krishnan Mishra's user avatar
5 votes
1 answer
2k views

Overriding Getters and Setters from Base Class

I'm trying to convert an old global class to be a virtual class so I can have some variations on its implementation. There is some existing behavior on the property Getters that I'd like to preserve ...
zeneto's user avatar
  • 107
-6 votes
1 answer
2k views

How to assign value for getter setter variable from Apex test class [closed]

Class A{ public object obj{get;set;} } Test Class Class A_Test{ //how to assign value fo obj variable }
Jayanth B's user avatar
0 votes
1 answer
2k views

How to get related object fields without the id in a query

I am working through a class that runs on before insert on the OpportunityLineItem object. Basically, I create a key on the OLI record, search for an existing custom object (Responsible Party) ...
Dan Wooding's user avatar
  • 3,478
4 votes
1 answer
2k views

get set method for value in class

I have a class with a getter and setter method. Could anyone explain how this works. If I am correct it is suppose to get and set a variable between a visualforce page and apex class. Is this also ...
Jenssen's user avatar
  • 419
1 vote
2 answers
639 views

Public Variable Returns Null

I am trying to return a JSON string to my controller for rendering on a Visualforce page. The query builds correctly and the JSON string builds locally within the method buildQuery. However my top ...
Steel Reserve 211's user avatar
1 vote
2 answers
737 views

Pull multiple fields from an object in get;set;

I have the following code linked to a vf page for a basic custom related list. I've figured out that it is not working due to not pulling the mr.Sample_ID__cbecause the get;set; at the top only pulls ...
user44478's user avatar
6 votes
2 answers
2k views

Need help understanding get/set methods, weird behavior

I came across this question somewhere which has been kept me engaged thinking why it is behaving this way. Lets say I have an apex class: public class TestController { public String myString{...
Santanu Halder's user avatar
1 vote
1 answer
189 views

Need clarification on a getter

I have a custom visualforce page and controller extension that is working. There is one getter that I do not understand why it works. I was hoping someone could explain it to me. In the below code I ...
Olivia's user avatar
  • 3,429
0 votes
1 answer
161 views

Getter Setter between two Visualforce pages

I am confused how to use to getter setter in the situation of two Visualforce pages having different extensions. 1 VF Page(Main Page): This page calls Opportunity as Standard Controller and having ...
user28452's user avatar
  • 431
13 votes
4 answers
29k views

why we use {get; set;} syntax in wrapper class or in controller class

public class Wrapper { public String fname{get; set;} //why we use get; set; syntax here public String lname{get; set;} public String uname{get; set;} } also here public class Controller{ ...
Saroj Dhabale's user avatar
3 votes
1 answer
909 views

How to test a class that contains no methods

I have a class that only contains one map. public with sharing class testController { public Map<String, User[]> mapName {get {.....return value;} set;} } I am unable to instantiate the ...
Olivia's user avatar
  • 3,429