Skip to main content

Salesforce Visualforce Apex - Getter and Setter methods – How to use them

Getter and setter methods are used to pass data from your visualforce page to your controller and vice versa.

Get accessor : The "get" accessor is used to pass data from your Apex code to your Visualforce page. The code in a get accessor executes when the property is read.

public string getuserinput()
{ return userinput; }

Set accessor : The "set" accessor is used to pass values from your visualforce page to the controller. The code in a set accessor executes when the property is assigned a new value.

public void setuserinput(String userinput)
{ this.userinput=userinput; }

In our example what we see is, the variable "userinput" is declared as string data type. Apex is strongly typed language and when you declare a variable you need to specify its data type.

The value entered in visualforce page via inputfield : userinput , is passed to the Apex code ( setuserinput ) . The value is stored in declared variable - userinput .The value is returned back to Visualforce page via Get accessor getuserinput , hence you are able to see the entered value back on the visualforce page. .

Custom Controller Apex Code :



Visualforce page Code :



The output when previewed on salesforce lightning platform :


Comments

Popular posts from this blog

TrackWise Digital - DMS Application - How to Override and make changes to locked EFFECTIVE Document using Flows and Invocable method.

Document management systems (DMS)   is one of the known solutions pharma organization use to manage their internal quality processes and store/ track all documentation related to quality. By using cloud-based product we have advantages over documents getting lost, outdated version rendered to stakeholders, irregular audit tracking like who made the changes and when. These qualities are necessary for good quality software as part of internal adulting process. The document are uploaded into the DMS system by DMS administrators. The document must go through a pre-defined workflow review process before it is made EFFECTIVE and made available for end users for training reference. The workflow lifecycle for DMS workflow approval cycle includes a) Draft, b) In Review, c)Under Approval and d) EFFECTIVE. Once the document is EFFECTIVE, the document is locked for further editing. The document is later used for internal training and can be printed and shared with internal users for performing...

Salesforce Rebate Management Tool – Streamline Your Rebate Process

Salesforce Rebate Management tool is a powerful tool for businesses to streamline their rebate process. It helps businesses to manage their rebate program more efficiently by automating the entire process. The tool helps businesses to provide rebates to their customers based on their purchases, which ultimately helps businesses to increase their sales and revenue. In this article, we will discuss the benefits of using Salesforce Rebate Management tool and how to set up benefit mapping. Benefits of using Salesforce Rebate Management Tool 1. Automate your rebate process – The tool automates the entire rebate process, from creating rebate offers to calculating payouts, which saves time and eliminates manual errors. 2. Increase customer loyalty – By offering rebates to your customers, you can increase their loyalty and encourage repeat purchases. 3. Improve sales performance – The tool helps businesses to increase their sales performance by incentivizing their sales team to sell more pro...

TrackWise : E-Signature doesn't work

If you are on Trackwise Digital [TWD] Platform Summer 23 or highier and come across an error ' E-Signature doesn't work ' for username / password with OAuth connected app . Check the Login History of the user and confirm you see the error ' Username-Password Flow Disabled ' . If this happens then you need to enbale the ' OAuth Username-Password Flows ' which will be disabled by default for Summer 23 platform or highier . Steps to enable : 1. Setup ==> search ==> OAuth and OpenID Connect Settings 2. Enable - Allow OAuth Username-Password Flows Reference https://lnkd.in/giVuzGbs

Salesforce flow validation to check if a record has file attached in files related list

Flow is part of salesforce flows which collects data via user screens from business users inside your salesforce organization or we call as ORG hereafter .  Salesforce flows comes in two flavors  a) Screen flows  b) Auto launched flows  Screen flows are used in business scenario where data is collected from users screens. Auto-launched flows runs in background which are triggered or launched automatically based on certain system conditions . That is a bit of basis check  on flows .