I am trying to create a final
variable in apex controller which would store the value of a picklist field , example - 'Hello'.
I have a visualforce page where I need to use this final variable
to compare and see whether the apex custom link should be rendered or not.
VF Page piece of code looks like:
<apex:commandLink value="XYZ" rendered="{!AND( var.boolean__c && var.picklistfield__c!='Hello')}">
</apex:commandLink>
I am using the picklist value directly here which makes it like hardcoding. Is this ok to use it this way. The link should be rendered only if the picklist value has 'Hello'. I was wondering if it is ok to use 'Hello' directly in the VF page like above. If not I plan to use a final variable in apex controller to be used in VF page. But that final variable will also have a value hardcoded in apex controller.
Controller: Below is not the correct way of declaring a final variable in apex class. I use get, set to be able to access the pickVal
in VF page. I get an compile error - Description Resource Path Location Type
Save error: Methods are final by default, Use virtual to declare methods that can be overriden .cls
public class AController{
public final pickVal{
get{
return 'Hello';
}
private set;
}
What do you suggest. This picklist value check is not going to change in future(very less likely). It will be 'Hello' for long time and won't change.