I do not understand how the get;set; and get(); flow together. I am trying to gather values from a url. I keep getting the Compile Error: Unexpected Token: '='. Furthermore, how would I even test the get;set;? I am lost.

public class tablestagingfieldsController {

    public ApexPages.StandardController controller;

    public tablestagingfieldsController(ApexPages.StandardController controller) {
    this.controller = controller;

    public table_staging__c i{get;set;}

    i.name = ApexPages.currentPage().getParameters().get('name');
    i.Reservation__c = ApexPages.currentPage().getParameters().get('resid');

    public PageReference saveanddirect() {
    PageReference a = new PageReference('google.com');
    return a;


The i.name = ... and i.Reservation__c = ... need to be inside a method or the constructor.


public table_staging__c i{get;set;}

just automatically provides a geti() method and a seti(...) method which Visualforce expects to use to access Apex data. See the Apex Properties documentation for a full description.

In a test you can just assign to i or from i just like you would any other field in the class.

(Better to choose a more meaningful name than i.)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.