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

Condition statements in datatable

  Can I use condition in Visual Force Page for follwing code...
My original code is
Apex class:
public class Library
    public List<Library__c> getLTH()
        return [select Name,Page_Link__c from Library__c];
Page code:
<apex:page sidebar="false" controller="Library">
    <apex:dataTable value="{!LTH}" var="lib" cellpadding="5">
     <apex:column ><apex:outputLink value="{!lib.Page_Link__c}">{!lib.Name}</apex:outputLink></apex:column>
    The above Apex class query return around 1000 records.. 
    I want to filter records based on Name fileds again for some reason..
Can I use if condition here...
ex: if(lib.Name=="Test")
    <apex:column ><apex:outputLink value="{!lib.Page_Link__c}">{!lib.Name}</apex:outputLink></apex:column>
Is this possible in VF.
I can use this condtion in Apex class... ( return [select Name,Page_Link__c from Library__c where Name ='Test']; )
But Like this condition I have to check 25 different Names.. Each result is shown in separate VF page... So I have to create
25 separate Apex class and call this class as a controller in 25 VF page... So that only I am using I want to use If condition in Page code for avoiding 25 same type of apex class... How can I avoid it...
Please give some suggestion

Message Edited by MohanaGopal on 08-18-2008 03:09 AM
Use the rendered attribute on column to control whether the column is displayed or not.

Thanks for ur reply...

But I have to check record is displayed or not...

Ron HessRon Hess
your controller will have to determine if a record is included in this list or not.


Please reply for my first message..

"controller will have to determine" means I have to create 25 Apex class?

or an other way...

Ron HessRon Hess
you can use one class, you will need 1 method that returns a different list depending on the other variables stored in the controller