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
MTBRiderMTBRider 

Help with <apex:param> tag

Can some one help me understand why using the name of the param in the outputText value field does not work:

 

<apex:pageBlockSection columns="1" id="pbsList">
   <apex:pageBlockTable value="{!casesInQ}" id="pbt" var="c" columns="11" columnsWidth="50" width="1200" rowClasses="grey_background, white_background"> 
	<apex:column value="{!c.CaseNumber}"/>
	<apex:column value="{!c.Priority}"/>
	<apex:column value="{!c.Subject}" width="400"/>
	<apex:column value="{!c.Type}" width="200"/>
	<apex:column value="{!c.Status}"/>
	<apex:column value="{!c.ContactId}"/>
	<apex:column value="{!c.OwnerId}"/>
	<apex:column value="{!c.CreatedDate}"/>
	<apex:column headerValue="Case Age (hrs)">
	   <apex:outputText value="{cDt}" >
		<apex:param name="cDt" value="{!ROUND((NOW() - c.CreatedDate) * 24, 2)}"/>
	   </apex:outputText>		
        </apex:column>	
    </apex:pageBlockTable>      
</apex:pageBlockSection>

 I get a error when saving the page saying the value of the Output is not in a valid format.

 

If I {0} in the value field of outputText it works fine but, ultimately I want to change the background color of the column based on the age of the case, but using 0 to reference the param in a conditional that says if the age of the case is > 2, make the background red, is never going to eval correctly.

 

Thanks for your help

APathakAPathak

Hi,

If you want to mark the cell in red then you may use below :

 

 

<apex:outputText value="{0}" escape="false">
	<apex:param value="{!(If((NOW() - c.CreatedDate)> 2,'<span style=\"color:red\">Should be in red</span>','<span>Should be in Black</span>'))}"/>
</apex:outputText>   

Here the text would come in red if the case age is greater than 2 days. if you want to the backgroud to be red then you need to modify the background property of the span.

 

 

MTBRiderMTBRider

Thanks for the response.  It does not answer my question though.  I know how to change the color.  My question is around why the name attribute of the param tag is not recognized by the outputText tag.  

Scott.MScott.M

shouldn't the value be {!cDt} not {cDt} ?

 

You can't use <apex:param> that way. I think <apex:variable> is what you're looking for:

 

try this:

 

<apex:variable var="cDt" value="{!(If((NOW() - c.CreatedDate)> 2,'<span style=\"color:red\">Should be in red</span>','<span>Should be in Black</span>'))}"/>                
<apex:outputText value="{!cDt}" />

 

MTBRiderMTBRider

If you use {!cDt} it wants to find cDt in the controller, so you will get an error that say "myController.cDt not found" when trying to save your page.

 

I think you are right though, that I want to use <apex:variable> instead.  Problem is I am using this in a pageBlockTable and the docs say that <apex:variable> does not support reassignment inside of an iteration component.  So maybe I am just hosed and need to come up with some other way of doing this.

 

Thanks for the response.