Questions tagged [setter]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
127 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
0 votes
2 answers
60 views

How to Combine Setter Methods together with redundant code?

I'm thinking there is a lot of redundant code in my setter methods, and I'm wondering if there is an effective way to combine them to get rid of some of the redundancies. How should I go about doing ...
user avatar
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
1 vote
1 answer
63 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
3 votes
1 answer
1k views

@api setter invalid reassignment of public property

I am using @api setter to update variable and I receive "invalid reassignment of public property". How can I fix it? I thought problem with my logic and removed everything and nothing is ...
ravipo's user avatar
  • 43
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
781 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
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
4 votes
2 answers
3k 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 &...
Raja's user avatar
  • 53
-4 votes
1 answer
607 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
0 votes
2 answers
2k 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. ...
Sudhir Balijepalli's user avatar
3 votes
1 answer
523 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 ...
Oleh Berehovskyi'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
5 votes
1 answer
1k 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 ...
Krish's user avatar
  • 53
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
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
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
-1 votes
1 answer
52 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 ...
lemdev's user avatar
  • 427
2 votes
2 answers
937 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
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
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,897
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
975 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
0 votes
1 answer
409 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 ...
devop7's user avatar
  • 3
-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
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
1 answer
462 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 ...
hlopetz's user avatar
  • 247
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
0 votes
1 answer
276 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 ...
Swarna Kumari's user avatar
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
0 votes
2 answers
387 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(...
Testing_SFDC's user avatar
  • 2,940
0 votes
1 answer
75 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 ...
rmarq423's user avatar
  • 957
8 votes
1 answer
7k 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 ...
Bonny's user avatar
  • 367
0 votes
1 answer
169 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 ...
Bonny's user avatar
  • 367
1 vote
1 answer
72 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 ...
Derek F's user avatar
  • 59.3k
6 votes
1 answer
3k 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 ...
Mossi's user avatar
  • 3,906