0

I want to display different images inside this pageBlockTable Column based on the value of a field. I am receiving this error:

You may specify either a ''value'' attribute or a body for the column component, but not both

Here is the code:

<apex:pageBlock rendered="{!showPI}">
    <apex:pageBlockTable value="{!listPICompleted}" var="item">
          <apex:column footerClass="itemHeader" value="{!item.Item__c}"/>
          <apex:column footerClass="subAreaHeader" value="{!item.Sub_Area__c}"/>
          <apex:column footerClass="actionStatementHeader" value="{!item.Action_Statement__c}"/>
          <apex:column footerClass="reviewStatusHeader" value="{!item.Plan_Review_Status__c}">
                   <apex:image value ="{!IF(item.Plan_Review_Status=="Not Submitted", URLFOR($Resource.NotStarted),
                        IF(item.Plan_Review_Status=="Re-submit"), URLFOR($Resource.NotStarted),
                        IF(item.Plan_Review_Status=="Approved"), URLFOR($Resource.Complete),
                        IF(item.Plan_Review_Status=="Received"), URLFOR($Resource.Pending),
                        IF(item.Plan_Review_Status=="Submitted"), URLFOR($Resource.Pending) )}" width="20" height="20"/>
           </apex:column></apex:pageBlockTable>

Does anyone know what the proper way to do this is? should I not be using a pageBLockTable? alternatvely to this, I also tried using the IF Condition in a style tag to change the background as opposed to an apex:image tag, however salesforce does not recognize the closing tag for the column when i do this.

Your help is very much appreciated, thank you in advance.

0

You cannot specify both the value attribute AND include a body for the apex:column

Easy fix though just change it to:

<apex:column footerClass="reviewStatusHeader" >
                   <apex:image value ="{!IF(item.Plan_Review_Status=="Not Submitted", URLFOR($Resource.NotStarted),
                        IF(item.Plan_Review_Status=="Re-submit"), URLFOR($Resource.NotStarted),
                        IF(item.Plan_Review_Status=="Approved"), URLFOR($Resource.Complete),
                        IF(item.Plan_Review_Status=="Received"), URLFOR($Resource.Pending),
                        IF(item.Plan_Review_Status=="Submitted"), URLFOR($Resource.Pending) )}" width="20" height="20"/>
           </apex:column>

If you need the text for plan review status simple add an output field before the apex:image

| improve this answer | |
  • Hi thank you very much this worked, unfortunately though doing this keeps the table header's title for plan review status blank. Do you know how I can keep the field name inside the header while still generating images as opposed to the text? – user7167 Dec 29 '14 at 3:01
  • AH HA! I found it, i had to use apex:facet name= header – user7167 Dec 29 '14 at 3:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.