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
Gino BassoGino Basso 

Error: Literal value is required for attribute

I have a component that accepts a Boolean attribute. Certain combinations of inline functions generate the error message shown in the subject line. See code below for details:


<!-- this produces the error --> <c:myComponent myBooleanValue="{!LEN(myObj__c.myField__c) == 0}" .../> <!-- this produces the error --> <c:myComponent myBooleanValue="{!LEN(myObj__c.myField__c) = 0}" .../> <!-- this works! --> <c:myComponent myBooleanValue="{!NOT(LEN(myObj__c.myField__c) > 0)}" .../>


Obviously I have a workaround (the last example) but I'm curious to know why the other two do not work.

Ron WildRon Wild

I ran into a similar situation and found that removing default='false' from the apex:attribute tag on the component fixed the problem.


NOTE: In my case, the error appeared no matter what formula was used.




I think that means that default values for Booleans in components are broken. I have the same problem.


I've just run into the same issue. 


I'm wondering if this is because the Default value is a literal thus the value being passed to the attribute must also be a literal.... 


Yes, it is because of the default value!!

I had the same issue when passing an Integer parameter to a component.


Thank you for this finding!!

Ralph CallawayRalph Callaway

Just ran into this problem, removing the default attribute took care of it.  Was able to make my own default value using BLANKVALUE.


<apex:component >

	<apex:attribute name="defaultNeeded"
		description="Needs a default value"
	<apex:variable value="{!BLANKVALUE(defaultNeeded, 'Default Value')}" var="innerValue"/>



Ami AssayagAmi Assayag

Another way to fix this is to create a property in the class:



<apex:attribute name="enabled" type="boolean" required="false" assignTo="{!controlEnabled}" />


public boolean controlEnabled { get { if(controlEnabled == null) controlEnabled = true; return controlEnabled; } set; }






This is really sounds like a bug in the component attribute behavior.  I've sucessfully used the combination of required=false with a default value without hitting the "Literal" error.  It doesn't seem to be consistent for a specific datatype either. 


This works fine:

<apex:attribute name="searchContacts" type="boolean" required="false" assignTo="{!includeContact}"
description="Search for matches in the Contact object?" 


But this does not:

<apex:attribute name="firstName" type="string" required="false" 
		description="The default value for First Name" 

 I don't suppose anyone has any more insight into this issue?


Did anyone create this as a bug or report to Salesforce Support? 


I logged a bug for the Visualforce team.  Fix is TBD.  If an urgent fix is needed, please open a support case and reference this community thread.  Thanks for raising.


I am also encountering this bug.


Here is some example code:


<apex:attribute name="okButtonLabel" description="Label for 'ok' button"
                type="String" required="false" default="Ok" />


<c:EQT_Popup title="{!$Label.EQT_Selection_Title}"
     okButtonLabel="{!$Label.EQT_Broker_Choose}" />



Literal value is required for attribute okButtonLabel in <c:EQT_Popup> in EQT_Portal at line 104 column 56