You need to sign in to do that
Don't have an account?
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.
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!!
Just ran into this problem, removing the default attribute took care of it. Was able to make my own default value using BLANKVALUE.
Another way to fix this is to create a property in the class:
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:
But this does not:
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:
Error:
Literal value is required for attribute okButtonLabel in <c:EQT_Popup> in EQT_Portal at line 104 column 56