You need to sign in to do that
Don't have an account?
Access global class static variable directly on visualforce page like $User.CompanyName
Hi,
As having past java experience, we usually create separate file for CONSTANTS & their VALUES. Since we have "CUSTOM LABELS" in Salesforce to get String KEY & VALUE but we don't want these CONSTANTS to be change in future from SETUP. Also, Hard-Coding values are always bad practice and we have kept all this CONSTANTS in separate global class named "Global_Constants" where each constants is marked with static, final & assigned with value.
Also, I had created getter method to access this static constant variable but whenever we try to access this, we receive error message as "variable_name does not exist".
Can you please let us know, How can we create global page class like $User, $Label in Apex ?? OR
How can we access these CONSTANTS on VFPage without using these class as "Controller / Extensions" (Since I want to make it separate, global & to be accessible in every page)
Thanks.
As having past java experience, we usually create separate file for CONSTANTS & their VALUES. Since we have "CUSTOM LABELS" in Salesforce to get String KEY & VALUE but we don't want these CONSTANTS to be change in future from SETUP. Also, Hard-Coding values are always bad practice and we have kept all this CONSTANTS in separate global class named "Global_Constants" where each constants is marked with static, final & assigned with value.
Also, I had created getter method to access this static constant variable but whenever we try to access this, we receive error message as "variable_name does not exist".
Can you please let us know, How can we create global page class like $User, $Label in Apex ?? OR
How can we access these CONSTANTS on VFPage without using these class as "Controller / Extensions" (Since I want to make it separate, global & to be accessible in every page)
Thanks.
Kindly Refer below,
First of all you can't reference a variable from another class into your visualforce page. You can only reference variables from your controller.
If you're using a standard controller then you can do the following:
Utill Class which is used to get set variable only
And your VF page something like below, Alternatively, if you're having a custom controller, you can make your Util class virtual or abstract and then extend it into your custom controller:
and your page will looke like:
Hope this will help you,
Mark Best ANSWER if its works for you.
Thanks
karthik
Thanks for your quick reply.
Do you have any idea about creating global page variables like $User, $Page etc. ??
Thanks
I am not sure we can create Custom global variable like user or page, according to my understanding we can't create custom global variable. kinldy check the list of global variable avaliable in salesforce.
http://http://help.skuid.com/m/11720/l/187263-global-merge-variables-functions
Hope this will help you
Thanks
karthik
how to use global class method string variable in another class??
for example :
global class A{
public class C
{
public String id;
}
public static void B()
{
'id' is used here with some assignment
}
}
here Iwant use 'id' in another class :
I can use : A.B() // to call static method but how to 'id' in this class
Awaiting your reply.
Thanks