Questions tagged [setter]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
4 answers
62 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....
user avatar
  • 167
1 vote
1 answer
356 views

LWC - NavigationMixin.GenerateUrl promise returns JavaScript:void(0)

In my component, I have an api setter method for recordId and I am generating a URL based on the given recordId inside the setter. I am storing the generated URL and using it as href value like this &...
user avatar
  • 13
-4 votes
1 answer
52 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&...
user avatar
0 votes
2 answers
701 views

Unable to pass an array from parent LWC to child LWC setter method

Trying to pass a array value from parent component to child component using setter method in child LWC but empty value is being passed to child setter method. I am Using parent LWC as a quick action. ...
user avatar
3 votes
1 answer
234 views

Apex Final Property Behaves Like a Member Variable

Assume we have a simple class: public with sharing class SomeClass { public String property { get; set; } { property = 'Default Property Value'; } public ...
user avatar
8 votes
1 answer
1k 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 ...
user avatar
5 votes
1 answer
703 views

Loop in javascript setter takes 1 second per iteration

I have an array attribute in my LWC component which is set from the parent LWC. I have some logic that runs when the this attribute is set. I have used getter and setter for this. My array is a ...
user avatar
  • 53
3 votes
2 answers
10k views

When to use getter and setter instead of simple property (@apir 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' }
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 ...
user avatar
  • 33
0 votes
2 answers
47 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 ...
user avatar
-1 votes
1 answer
37 views

How to invoke controller setter method in trigger beforeInsert()?

That is my VF page: <apex:page standardController="Lead" extensions="LeadDuplicateController" tabStyle="Lead"> <apex:pageBlock > <apex:pageBlockSection title="Lead ...
user avatar
  • 397
2 votes
2 answers
396 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 ...
user avatar
2 votes
2 answers
41 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 { ...
user avatar
2 votes
1 answer
2k 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 ...
user avatar
1 vote
2 answers
335 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 ...
user avatar
  • 2,584
0 votes
0 answers
768 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. ...
user avatar
  • 165
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(){ ...
user avatar
-5 votes
1 answer
800 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 '...
user avatar
0 votes
1 answer
279 views

How to invoke Blob setter method?

I have a class with the following getter/setter: public Blob csvFileBody{get;set;} I have a test method from where I need to invoke the blob setter from the controller class. Please advise how to ...
user avatar
  • 3
-6 votes
1 answer
1k 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 }
user avatar
4 votes
1 answer
1k 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 ...
user avatar
  • 399
1 vote
2 answers
342 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 ...
user avatar
1 vote
1 answer
434 views

DML is NOT Recommended in APEX Property Setter

I just got a strange recommendation from SalesForce support which was related to inability of APEX controller class to save value from VisualForce component to a custom setting. The recommendation ...
user avatar
  • 227
0 votes
1 answer
142 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 ...
user avatar
  • 389
0 votes
1 answer
248 views

param value returns null

I have below VF page.I am passing value from data table.value="{!rlist.Id}" is coming as null.So on button click it is throwing me error for below soql as selectedresourceid =null ...
user avatar
12 votes
4 answers
24k 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{ ...
user avatar
0 votes
2 answers
216 views

Null Pointer exception for a set<ID>

I have below code in apex constructor of the controller where it shows null pointer exception. Can someone please let me know if I have issues with declaration and also the workaround. for(...
user avatar
  • 2,900
0 votes
1 answer
54 views

Problem with Rendered attribute behaving incorrectly. Seems to always return false when the page is loaded?

I must be doing something silly with my code, but cannot for the life of me figure out why neither the Boolean userNeedsVerify nor the method checkForVerify() are rendering when they should be. I've ...
user avatar
  • 879
8 votes
1 answer
6k views

Simple getter setter

How to pass value from user side or vf page side by using this type of getter setter is there any way to pass value using this type? Here is the Code public class simplegetset { public String ...
user avatar
  • 367
0 votes
1 answer
87 views

Different way to write getter and setter

Hi i have code that shows an error "Error: simplegetset Compile Error: Variable is not visible: userinput at line 14 column 15".I just want to know is this not right way to define get and set here is ...
user avatar
  • 367
1 vote
1 answer
60 views

What is the behavior of a class attribute setter defined inline?

This came up in my answer on this other question I'm actually not 100% certain of the exact behavior of defining a setter method (does it completely override the standard setter? or is it run ...
user avatar
  • 46.5k
5 votes
1 answer
2k views

Setter not running on List.add()

Calling the add() method on a list doesn't force the setter to be called. First off, why is the setter not running? Secondly, is there a way to somehow override List.add() and steal the action, or do ...
user avatar
  • 3,754