I have created one vf page in which all pages and apex classes in my org are shown. I have 2 problems 1. I want to get owner name for each apex class and apex pages. 2. I want one checkbox which will act as a select all values in my coloumn

vf page

<apex:page controller="vfpagectrl" sidebar="false" >
    <script type="text/javascript">
        function checkall(cb,filter)
            var inputItem=document.getElementsByTagName("inputcheckbox");       
            for(var v=0;v<inputItem.length;v++)
                   inputItem[i].checked= cb.checked;

    <apex:form >
        <apex:pageBlock >
            <apex:pageblockSection title="Apex Classes and Pages" >
                <apex:pageblockTable value="{!aclass}" var="a">
                    <apex:column headerValue="selectall" >       
                        <apex:inputCheckbox value="{!se}" id="check" selected="true"/>
                    <apex:column value="{!a.Name}"/>            
                    <apex:column value="{!a.CreatedDate }"/>                   
                <apex:pageBlockTable value="{!apage}" var="w">
                    <apex:column headerValue="selectall" > 
                        <apex:inputCheckbox value="{!se}" id="check"  selected="true"/>
                    <apex:column value="{!w.Name}"/>
                    <apex:column value="{!w.CreatedDate}"/>


public class vfpagectrl {
    public List<apexclass> aclass{get;set;}
    public List<apexpage>  apage{get;set;}
    public String se{get;set;}
    public vfpagectrl()
        aclass=new List<apexclass>();        
        aclass=[select Name,Status,CreatedDate from apexclass where Status='Active'];       
        apage=new List<apexpage>();        
        apage=[select Name,CreatedDate,ControllerKey from apexpage];    
    public List<User> getuid()
        return null;    

Solution for Problem 1:

There is no field called owner for Apex Classes, Apex Triggers and Visualforce pages.

You can use CreatedBy.Name and LastModifiedBy.Name to show who created it first and who modified it last.

Solution for Problem 2:

We used JQuery to select all the checkboxes once the top check box is checked. We need to uncheck the top check box if any of the bottom checkboxes is unchecked.

function test(){
    j$ = jQuery.noConflict();                        
    // add multiple select / deselect functionality
    j$(function() {                                    
        j$("input.selectAll").click(function () {                                
            j$("input.checkBox").prop('checked', this.checked);

        // if all checkbox are selected, check the selectall checkbox
        // and viceversa
            if(j$("input.checkBox").length == j$("input.checkBox:checked").length)
                j$("input.selectAll").prop("checked", true);
                j$("input.selectAll").prop("checked", false);                         

        j$("input.selectAllExisting").click(function () {                                
            j$("input.checkBoxExisting").prop('checked', this.checked);

        // if all checkbox are selected, check the selectall checkbox
        // and viceversa
            if(j$("input.checkBoxExisting").length == j$("input.checkBoxExisting:checked").length)
                j$("input.selectAllExisting").prop("checked", true);
                j$("input.selectAllExisting").prop("checked", false);                         

<apex:column >
    <apex:facet name="header">
        <apex:inputCheckbox value="{!boolSelectExisting}" styleClass="selectAllExisting" onchange="test()"/>
    <apex:inputCheckbox value="{!bpr.Selected}" styleClass="checkBoxExisting" onchange="test()"/>
  • @Vingeshwaran G: Do you made any changes in apex controller?? – Shantanu Mahajan Jul 10 '15 at 12:34
  • You should modify this query by adding CreatedBy.Name aclass=[select Name,Status,CreatedDate,CreatedBy.Name from apexclass where Status='Active']; and add <apex:column value="{!aclass.CreatedBy.Name}"/> to visualforce page. – Vigneshwaran G Jul 10 '15 at 13:11
  • I am talking about the jqury.SOQL is working fine – Shantanu Mahajan Jul 11 '15 at 16:22
  • The jquery i showed is an solution which we applied for specific condition. You can modify it according to your need. The controller doesn't need any changes i believe. – Vigneshwaran G Jul 11 '15 at 17:10

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.