i need to replace instead 'Time selected is no longer available' i want to display a cross image and instead AVAILABLE i want to display a check image. How can i achieve this? Thanks in advance.


<apex:pageBlock id="teacherPageBlock">    
                        <div style="margin-top: 10px; padding: 45px;"> 
                            <apex:pageBlockTable value="{!WrapTS}" var="item" id="teacherBlock">

                                <apex:column headerValue="Teacher" value="{!item.t1.First_Name__c} {!item.t1.Name}"/>
                                <!--   <apex:param id="teacherid" name="teacherId" value="{!item.t1.Id}" assignTo="{!selectedTId}"/> -->
                                <apex:column headerValue="Subject" value="{!item.t1.Subject__c}"/>
                                <apex:column headerValue="Room" value="{!item.t1.Room_Assignment__c}"/>
                                <apex:column headerValue="Time">
                                    <apex:selectList size="1" value="{!selectedTime}">
                                     <apex:actionSupport event="onchange"  action="{!checkTeacherSched}" reRender="teacherBlock"/>
                                        <apex:selectOption itemValue=""></apex:selectOption>
                                        <apex:selectOption itemValue="9:00AM - 10:00AM"></apex:selectOption>
                                        <apex:selectOption itemValue="10:00AM - 11:00AM"></apex:selectOption>
                                        <apex:selectOption itemValue="11:00AM - 12:00PM"></apex:selectOption>
                                        <apex:selectOption itemValue="12:00PM - 1:00PM"></apex:selectOption>
                                        <apex:selectOption itemValue="1:00PM - 2:00PM"></apex:selectOption>
                                        <apex:selectOption itemValue="2:00PM - 3:00PM"></apex:selectOption>
                                        <apex:selectOption itemValue="3:00PM - 4:00PM"></apex:selectOption>
                                        <apex:selectOption itemValue="4:00PM - 5:00PM"></apex:selectOption>
                                        <apex:actionSupport event="onchange"  action="{!checkTeacherSched}" reRender="teacherBlock"/>
                                <apex:column headerValue="Status">
                                    <apex:outputText value="{!strCheck}">




Controller snippet


public void checkTeacherSched(){
    strCheck = null;
    wrapTeaSched = new list<schedule__c>();

    for(schedule__c myTime : [Select id, name, teacher__c, time__c, student__c, parent__c, teacher_cname__c 
        from schedule__c WHERE teacher__c =: myTea AND time__c =: selectedTime ]){

       //system.assertequals(checkSchedTeaId + '','test');
       if(checkSchedTeaId!= null){
           strCheck = 'Time selected is no longer available';  
       else if(checkSchedTeaId== null){
           strCheck = 'AVAILABLE';


A simple solution would be:

Upload your images for cross and check as a static resource.

In your VF page instead of displaying the strCheck string, display your images and use conditional rendering.

Something like:

<apex:column headerValue="Status">
    <apex:image url="{!URLFOR($Resource.TestZip,
                      'images/Cross.jpg')}" rendered="{!IF(strCheck ='Time selected is no longer available',true,false)}"/>

    <apex:image url="{!URLFOR($Resource.TestZip,
                      'images/Check.jpg')}" rendered="{!IF(strCheck ='AVAILABLE',true,false)}"/>

  • can i do the conditional statement in the controller? and tje image will just display the result? – sfdclearner Feb 26 '16 at 2:23
  • 1
    Yes you can do it. In this case you will have one Apex:image tag and the value of the url will be set in a variable in your controller based on your logic. – Richard N Feb 26 '16 at 5:55
  • how can i set url value from controller? string? – sfdclearner Feb 26 '16 at 6:09
  • Yes. But why dont you do it like the way I have suggested? – Richard N Feb 26 '16 at 6:31
  • 1
    You are welcome..glad it worked :) – Richard N Feb 29 '16 at 23:23

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.