+ Start a Discussion
r_boyd_848r_boyd_848 

CASE Function enbedded in VisualForce component

I'm trying to pass a value to the attribute of a component from a query parameter value. I need to change the value passed to the attribute based on the query string value. Here's the code:

 

 

showPreviousBtn="{!CASE($CurrentPage.Parameters.step,"0","false","true")}"
showNextBtn="{!CASE($CurrentPage.Parameters.isLast,"false","true","true","false","true")}"
				

 

 

Line 2 in the code 'showNextBtn' works fine, its the first line that returns the following error:


Save error: Attribute name "false" associated with an element type "apex:componentReference" must be followed by the ' = ' character. at line 31  

 

I did try this hack, thinking the CASE function didn't like just one statement, but the same error occurred

 

 

showPreviousBtn="{!CASE($CurrentPage.Parameters.step,"0","false","1","true","true")}"

 The only difference in the parameters is that the first uses a digit and the latter true/false. But it shouldn't matter as anything in the query param is treated as a string. As soon as I remove the offending line everything works again. I also tried using the IF function but it doesn't seem to like non-boolean values

 

Heres how the attribute appears in the component

 

 

<apex:attribute name="showPreviousBtn"
description="display/hide button" type="string" required="false"
assignTo="{!showPreviousButton}"  />

 

 

 

aballardaballard

Not sure why one would work but not the other.  I'd expect both to have problems if this is actually what you have in your page... looks like you have quoted strings inside quoted strings.   Try using single quotes for the outer ones.