function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nikki_tcsNikki_tcs 

How to display custom text field in a site thro visualforce

Hi,

 

I have a ideas site, and i would like to display a custom text field (Test_Tags__c) which i created in salesforce on the site. 

 

Here is my apex controller for this particular peace.

 

 

 public static string TestTeg()
    {
      
        idea myidea = [select Test_Tags__c,Id from idea where Status <> null];
        return myidea.Test_Tags__c ;
    }     

 

 public static string TestTeg()    {            

 idea myidea = [select Test_Tags__c,Id from idea where Status <> null];      

 return myidea.Test_Tags__c ;  

 }     

 

The above query returns the expected text output in eclipse.

 

Now i am just trying to display the above returned output on the site using my visualforce page, and in my visualforce page i wrote, (apart from rest of the page)

 

Test Tags : {!TestTeg}

 

Now i see the Test Tags heading in my site, but it doesn't display the above returned output (from apex controller). How can i make the output appear on my site? What am i missing here?

 

Thanks.

 

 

Ispita_NavatarIspita_Navatar

Have you coded the Getter  method for  "TestTeg" - you need to code the getter method to be able to read the value.

 

//Variable

String TestTeg;

 

// Getter method

public String  getTestTeg()

{

return TestTeg;

}

 

//setter method

public void  setTestTeg(String str)

{

TestTeg=str;

}

//

 

 public static string TestTeg()    {            

 idea myidea = [select Test_Tags__c,Id from idea where Status <> null];      

TestTeg=(string)myidea.Test_Tags__c

 return TestTeg;  

 }    

 

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

 

 

Edwin VijayEdwin Vijay

Have you granted access to the field for your site USER.?

 

Also, your function should be

 

 

 public static string getTestTeg()    {            

idea myidea = [select Test_Tags__c,Id from idea where Status <> null];

return myidea.Test_Tags__c ;

}

 Check this article, may be helpful Force.com Sites - A sneak peak

 

Nikki_tcsNikki_tcs

Hi Edwin,

 

I have made the Test_tags Field visible to site users in the profile, also changed the code to getTestTeg().

 

Also, when i try to acess my visualforce tab which is a direct link to the above page, i get visualforce errror on the tab and this one line is being dispalyed in the page :   setTestTeg(NULL).

 

I ve tried the below code, when i do this code, it doesnt show any error, also its not displaying the required text , still the field on the page is blank like this. Test Tags :                      

 

 

String TestTeg;
    
    public String  getTestTeg()
    {
      return TestTeg;
    }
    
    public void  setTestTeg(String str)
    {
       TestTeg=str;
    }
    
    
    public static string getTestTeg(String TestTeg)
    {
        idea myidea = [select Test_Tags__c,Id from idea where Status <> null];
        TestTeg = myidea.Test_Tags__c;
        return TestTeg; 
    }     

 

String TestTeg;        

public String  getTestTeg()    {    

 return TestTeg;    }        

public void  setTestTeg(String str)    {      

TestTeg=str;    }            

public static string getTestTeg(String TestTeg)    {      

 idea myidea = [select Test_Tags__c,Id from idea where Status <> null];      

 TestTeg = myidea.Test_Tags__c;      

 return TestTeg;     }     

 

Any clue?

 

Thanks.

Nikki_tcsNikki_tcs

Hi Ispita,

 

Even for this code it says Varibale TestTeg does not exist.

 

 

public String TestTeg;
    
    public String  getTestTeg()
    {
       return TestTeg;
    }
    
    public void  setTestTeg(String str)
    {
       TestTeg=str;
    }
    
    public static string TestTeg()
    {
        idea myidea = [select Test_Tags__c,Id from idea where Status <> null];
        TestTeg=(string)myidea.Test_Tags__c;
        return TestTeg;  
    }     

 

public String TestTeg;      

 public String  getTestTeg()    {      

return TestTeg;    }        

 

public void  setTestTeg(String str)    {      

TestTeg=str;    }      

 

 public static string TestTeg()    {        

idea myidea = [select Test_Tags__c,Id from idea where Status <> null];      

 TestTeg=(string)myidea.Test_Tags__c;      

 return TestTeg;      }