• Hugo Stoupe
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 9
    Replies
I have looked at the forums and for some reason, I think my code is complete, however, my page is not re-rendering.

When I click the commandbutton "Create Budget", it works in the background, it creates the budget, but the VF page does not refresh to show me the new budget related list.

Any help?

My VF page
<apex:page standardController="CCI_Project__c" extensions="budAddBudget">
    <apex:form>
    <apex:pageblock>
     <apex:pageblockButtons location="top">
                 <apex:commandButton value="Create Budget" action="{!addBudget}" reRender="bp"/>
            </apex:pageblockButtons>
     </apex:pageblock>
        <apex:outputPanel id="bp">
         <apex:repeat value="{!project}" var="p">
            <apex:pageBlock>
                <apex:pageBlockSection >
                    <apex:outputField value="{!p.Name}"/>
                    <apex:outputField value="{!p.Closed_Opportunity__c}"/>
                </apex:pageBlockSection>
        
                <apex:pageBlockTable value="{!p.Budgets__r}" var="b">
                    <apex:column value="{!b.Name}"/>
                    <apex:column value="{!b.Start_Date__c}"/>
                    <apex:column value="{!b.Total_Budget__c}"/>
                    <apex:column value="{!b.Total_Actual__c}"/>
                    <apex:column value="{!b.Total_Invoiced_to_Date__c}"/>
                </apex:pageBlockTable>
         
           
        </apex:pageBlock>
     </apex:repeat>
      </apex:outputpanel>
    </apex:form>
</apex:page>
The controlling class
public PageReference addBudget() {
        // Do code
        this.prj = (CCI_Project__c)standardController.getRecord();
        
        system.debug ('projId ' +prj.id);
        system.debug('a');

        proj = [Select ID, Name, Closed_Opportunity__c From CCI_Project__c Where Id=:prj.Id];
        // Call budgetAdd Method in class createBudget
            cb.budgetAdd(proj.id, proj.Closed_Opportunity__c);


        
        
        
        
        return null;
    
    }

Any suggestions GREATLY appreciated.
 
Hi there,

I am really struggling to write 2 test classes for 2 extensions.  Is there any good documentation to help write these test classes? The only resource I found was http://www.salesforce.com/docs/developer/pages/Content/pages_controller_error_handling.htm and it isn't helping...

The first extension is called by one VF page, then on success calls a second VF page that has it's own extension.  Both extensions follow here.
 
public class openTimeEntry {
public dummyTable__c dum{get;set;}
public Time_Entry__c emp{get;set;}
public ID pID{get;set;}
public String eID{get;set;}
private Date uDate; 


public openTimeEntry(ApexPages.StandardController controller) { 
    Date uDate = Date.valueOf(System.Now());
    dum=new dummyTable__c();
    emp=new Time_Entry__c();
    }

public PageReference fetchPage(){   
     String uAlias =  UserUtil.CurrentUser.Alias;    
     System.debug('ualias'+uAlias);
      eID = emp.Employee1__c;
      System.debug('eID'+eID);
      if(UserUtil.CurrentUser.Alias=='hsto'||UserUtil.CurrentUser.Alias=='cserv'||UserUtil.CurrentUser.Alias=='pdisc'||UserUtil.CurrentUser.Alias=='data'||UserUtil.CurrentUser.Alias=='edisc'||UserUtil.CurrentUser.Alias=='code'){
          
          if(eid==null){
         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter your name in the Employee field'));
    return null;
           }
       }
       
    
      String testDate = String.valueof(dum.dateOne__c);
      if(testDate==null) {
          uDate = Date.today();
      }else{
          uDate = dum.dateOne__c; 
      }
      System.debug('openTimeEntryTestDate'+testDate);
      System.debug('openTimeEntrydumDate'+dum.dateOne__c);
      System.debug('openTimeEntryuDate'+uDate);
      System.debug('ProjectID'+pID);
      //System.debug('useralias:'+uAlias);
      System.debug('geteID:'+eID);     
    pageReference teGridView = new PageReference('/apex/teGridView?uDate='+uDate+'&pid='+pID+'&eid='+eID);
    return teGridView; 
    }
}

Extension for 2nd vf page.
 
public class teGridClass {
    public dummyTable__c dum{get;set;}
    public Time_Entry__c timecards {get;set;}
    public Time_Entry__c del;
    public List<Time_Entry__c> addTEList {get;set;}
    public List<Time_Entry__c> delTEList {get;set;}
    public List<Time_Entry__c> TEList {get;set;}
    public Integer totalCount {get;set;}
    public Integer rowIndex {get;set;}
    public String query{get;set;}
    Public Date tDate{get;set;}
    Private Date uDate{get;set;}
    public String pID{get;set;}
    public String eID{get;set;}
    public String cID{get;set;}
    public user currentuser{get;set;}
    public SFDC_Employee__c currEmployee{get;set;} 
    Private String sDate;
 
    // Map of PageParameters
    private Map<string,string> urlParams=ApexPages.currentPage().getParameters();
 
    // Set the variable in Constructor
    public List<Time_Entry__c> delTEs {get; set;} 
 
 
    public teGridClass(ApexPages.StandardController controller) {
        pID = apexpages.currentpage().getparameters().get('pID');
        eID = apexpages.currentpage().getparameters().get('eID');
        cID = apexpages.currentpage().getparameters().get('cID');
        if(urlParams.containsKey('uDate')){
            sDate = urlParams.get('uDate');
           }    
        dum=new dummyTable__c();
               
                        System.debug('tDate1'+tDate);
  
        tDate = dum.dateOne__c;
                        System.debug('DateOne'+dum.DateOne__c);
                        System.debug('tDate2'+tDate);
                        System.debug('uDate'+uDate);
                        System.debug('sDate'+sDate);

        timecards = (Time_entry__c)controller.getRecord();
        // Temp place Date value
        if(sDate==null) {            
              tDate = date.ValueOf(System.now());
         } else {
              tDate = date.ValueOf(sDate.substring(0,10));
         }
         // Pull Current User Information
         currentuser=new User();
         currentuser=[Select Id,Name, Alias, Firstname, LastName, Email from User where Id=:userinfo.getuserId()];
        
         // Pull Current Employee Information
         // IF(currentUser.Alias=='
       // currEmployee=new SFDC_Employee__c();
        // currEmployee=[Select Id,first_name__c from SFDC_Employee__c where User__c=:userinfo.getuserId()];
        
          System.debug('curUserAlias'+currentuser.alias);
         // System.debug('curempFirstName'+currEmployee.first_name__c);
     
        String SobjectApiName = 'Time_Entry__c';
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
 
        String commaSepratedFields = '';
        for(String fieldName : fieldMap.keyset()){
            if(commaSepratedFields == null || commaSepratedFields == ''){
                commaSepratedFields = fieldName;
            }else{
                commaSepratedFields = commaSepratedFields + ', ' + fieldName;
            }
        }
        
        
        
        
        
      query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Where  Date__c=:tDate';
          if(eID.length()>6)
          //Do something with eID
           {
              query = query+' AND Employee1__c=:eID';
              currEmployee=new SFDC_Employee__c();
              currEmployee=[Select Id,first_name__c from SFDC_Employee__c where first_name__c=:userinfo.getfirstname() AND last_name__c=:userinfo.getlastname()];
        
          }else{
          // Look up employeeID based on user ID
          try{
              List<SFDC_Employee__c> E=[Select Id,first_name__c from SFDC_Employee__c where User__c=:userinfo.getuserId()];
              
              if (!E.isEmpty()) {
                
                }Else{
                currEmployee=new SFDC_Employee__c();
                 currEmployee=[Select Id,first_name__c from SFDC_Employee__c where User__c=:userinfo.getuserId()];
                 }
                
            }catch(Exception ex){
             ApexPages.addMessages(ex);
             }
        
              query = query+'';
          }
          
          if(pID.length()>6)
          //Do something with pID
           {
              query = query+' AND Project__c=:pID';
          }else{
              query = query+'';
          }
          query = query+' LIMIT 10';

                     System.debug('query:'+query);
                     System.debug('uDate:'+uDate);
                     System.debug('projectID:'+pID);
                     System.debug('EmpID:'+eID);
                     System.debug('Esize: ' + eID.length() );
                     System.debug('psize: ' + pID.length() );
                     System.debug('DateOne'+dum.DateOne__c);
                     System.debug('tDate2'+tDate);
                     System.debug('uDate'+uDate);
                     System.debug('sDate'+sDate);
             


 TEList = Database.query(query);

 totalCount = TEList.size();
 
                     System.debug('totalcount'+totalCount);
    IF(totalCount==0){
        addRow();
     }
 
 
 delTEList = new List<Time_Entry__c>();
 delTEs = new List<Time_Entry__c>();
 }
 
 public void addRow(){

        currEmployee=new SFDC_Employee__c();
        currEmployee=[Select Id,first_name__c from SFDC_Employee__c where User__c=:userinfo.getuserId()];

        eID=currEmployee.ID;

 System.debug('query:'+query);
                     System.debug('uDate:'+uDate);
                     System.debug('projectID:'+pID);
                     System.debug('EmpID:'+eID);
                     System.debug('Esize: ' + eID.length() );
                     System.debug('psize: ' + pID.length() );
                     System.debug('DateOne'+dum.DateOne__c);
                     System.debug('tDate2'+tDate);
                     System.debug('uDate'+uDate);
                     System.debug('sDate'+sDate);
 addTEList = new List<Time_Entry__c>();
 TEList.add(new Time_Entry__c(Date__c = tDate, project__c = pid, contract__c = cid, employee1__c=eid));
 }
 
 public PageReference ave(){
 
 try{
 
     upsert TEList;
     delete delTEList;
     
     
     return (new ApexPages.StandardController(timecards)).view();
     
     }catch(Exception ex){
     ApexPages.addMessages(ex);
     }
     return null;
 } 
 
 public void deleteRow(){
 
 rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
                     System.debug('rowbe deleted ' + rowIndex );
                     System.debug('rowm to be deleted '+TEList[rowIndex]);
 del = TEList.remove(rowIndex);
 delTEList.add(del);
 
 }
// }
 }


 
I have a visualforce page that has a date input.  This page is embedded in a object page detail.

My goal is to have them select a date - click the button which takes them to a new pop-up window / visualforce page where they can enter time / hours.

Depending on which object the first visualforce page is embedded, I want to pass that objects recordID to the controller, but I am getting nothing - getting "null".  I have tried <apex:param and <apex:inputhidden and neither work.

The workflow is:
  •      PARENT OBJECT (CCI_project__c) has an embedded VF page called "terlproject"
  •      TERLPROJECT has a form with a date picker.  Once the button is clicked, the controller is "OpenTimeEntry"
  •      All OpenTimeEntry does is gather the parameters (date and objectID) and pass it to a new VF page called teGridView
  •      TEGRIDVIEW has a controller (teGridClass) that pulls data and populates the VF page "teGridView"

Can anyone help?  Below is screen shots and code:

1.  embedded visualforce page "terlProject"   In this case, It is on a custom object called "CCI_Project__C" and I am trying to pass the Date and REcord ID - the date is passing fine - the record ID is not (I display it on the VF page so I know the ID exists)
User-added image

The code for the Visualforce page is: 
<apex:page Standardcontroller="CCI_Project__c" extensions="openTimeEntry">
    <apex:form >
        <!-- Variables go here -->
        

        <!-- Input Buttons here -->
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <b>Date</b><apex:inputfield value="{!dum.dateOne__c}"/>
                <apex:inputHidden value="{!CCI_Project__c.ID}" id="projID"/>
               Project. <apex:outputField value="{!CCI_Project__c.id}"/>
                <apex:commandButton value="Enter Time" action="{!fetchPage}">
               <!-- <apex:param name="projID" value="{!CCI_Project__c.ID}" assignTo="{!projID}"/>-->
                </apex:commandButton>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
    
    <!-- Related List Displays here -->



</apex:page>

Once clicked, I call the controller class "openTimeEntry" - you will see i have tried various ways of "getting" the ProjectID - but debug shows null.
public class openTimeEntry {
public dummyTable__c dum{get;set;}
public ID projID{get;set;}
public cci_Project__c co {get; set;}
private Date uDate; 

public openTimeEntry(ApexPages.StandardController controller) { 
    Date uDate = Date.valueOf(System.Now());
    dum=new dummyTable__c();
    System.debug('ProjID: '+projID);
    }

public PageReference fetchPage(){
      
      String testDate = String.valueof(dum.dateOne__c);
      if(testDate==null) {
          uDate = Date.today();
      }else{
          uDate = dum.dateOne__c; 
       }

              System.debug('openTimeEntryTestDate'+testDate);
              System.debug('openTimeEntrydumDate'+dum.dateOne__c);
              System.debug('openTimeEntryuDate'+uDate);
              System.debug('ProjectID----'+projID+co);
      
        pageReference teGridView = new PageReference('/apex/teGridView?uDate='+uDate+'&projectID='+projID);
        return teGridView ;
    
    }
 
  
}
Then I re-direct to the teGridView which has a controller class teGridClass

Here is the page, followed by the class.
<apex:page standardController="Time_Entry__c" extensions="teGridClass" sidebar="true">
 <apex:form >
 <apex:pageBlock title="Time Card" id="pb">
 <apex:pageMessages />
 <apex:variable var="rowNumber" value="{!0}"/>
            <!-- Debug - SQL statement -->
           <apex:pageBlockSection columns="1" title="DEBUG - Dynamic SOQL Query" collapsible="True">
                <apex:outputText value="{!query}">
                </apex:outputText>
               Date:  
                <apex:outputText value="{!tDate}">
                </apex:outputText>
               EmployeeID:  
                <apex:outputText value="{!tDate}">
                </apex:outputText>
            </apex:pageBlockSection>
 <apex:pageBlockSection title="Daily Time Entry" collapsible="false">
 Date:  <apex:outputText value="{!tDate}">
                </apex:outputText>
                
 Employee:  <apex:outputText value="{!tDate}">
                </apex:outputText>
 </apex:pageBlockSection>
 <apex:pageblockSection columns="1">
 <apex:pageBlockTable title="Time Card Entries" var="tce" value="{!TEList}"> 

 <apex:column headerValue="No." style="width:10px; text-align:center;" headerClass="centertext">
 <apex:outputText value="{0}" style="text-align:center;"> 
 <apex:param value="{!rowNumber+1}" /> 
 </apex:outputText>
 </apex:column> 
 <apex:column headerValue="Functional Area" width="10px">
 <apex:inputField value="{!tce.Functional_Area__c}"/>
 </apex:column> 
 
 <apex:column headerValue="Activity Detail" width="10px">
 <apex:inputField value="{!tce.Description__c}"/>
 </apex:column> 
 <apex:column headerValue="Project" width="10px">
 <apex:inputField value="{!tce.Project__c}"/>
 </apex:column> 
 <apex:column headerValue="Contract" width="10px">
 <apex:inputField value="{!tce.Contract__c}"/>
 </apex:column> 
 <apex:column headerValue="Hours" width="5%">
 <apex:inputField value="{!tce.Total_Time__c}"/>
 </apex:column> 
 <apex:column headerValue="Date" width="10px">
 <apex:inputField value="{!tce.Date__c}"/>
 </apex:column> 
 

 
 <apex:column headerValue="Action" >
 <apex:commandButton value="Delete" action="{!deleteRow}" reRender="pb">
 <apex:param name="rowIndex" value="{!rowNumber}"/>
 </apex:commandButton>
 <apex:variable var="rowNumber" value="{!rowNumber+1}"/>
 </apex:column> 
 </apex:pageBlockTable>
 <apex:commandButton action="{!addRow}" value="Add Time" reRender="pb"/>
 </apex:pageblockSection>
 <apex:pageBlockButtons >
 <apex:commandButton value="Save" action="{!ave}" />
 <apex:commandButton value="Cancel" action="{!cancel}"/>
 </apex:pageBlockButtons>
 </apex:pageBlock>
 </apex:form> 
 </apex:page>
teGridClass:
public class teGridClass {
    public dummyTable__c dum{get;set;}
    public Time_Entry__c timecards {get;set;}
    public Time_Entry__c del;
    public List<Time_Entry__c> addTEList {get;set;}
    public List<Time_Entry__c> delTEList {get;set;}
    public List<Time_Entry__c> TEList {get;set;}
    public Integer totalCount {get;set;}
    public Integer rowIndex {get;set;}
    public String query{get;set;}
    Public Date tDate{get;set;}
    Private Date uDate{get;set;}
    Private String sDate;
 
    // Map of PageParameters
    private Map<string,string> urlParams=ApexPages.currentPage().getParameters();
 
    // Set the variable in Constructor

    public List<Time_Entry__c> delTEs {get; set;} 
 
    public teGridClass(ApexPages.StandardController controller) {
    
        if(urlParams.containsKey('uDate')){
            sDate = urlParams.get('uDate');
             }
            
        dum=new dummyTable__c();
               
        System.debug('tDate1'+tDate);
  
        tDate = dum.dateOne__c;
        System.debug('DateOne'+dum.DateOne__c);
        System.debug('tDate2'+tDate);
        System.debug('uDate'+uDate);
        System.debug('sDate'+sDate);

 // public teGridClass (ApexPages.StandardController controller) {
     timecards = (Time_entry__c)controller.getRecord();
 // String tID = timecards.ID;

    
     // Temp place Date value
         if(sDate==null) {            
      tDate = date.ValueOf(System.now());
         } else {
         tDate = date.ValueOf(sDate.substring(0,10));
        
         }
     
        String SobjectApiName = 'Time_Entry__c';
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
 
        String commaSepratedFields = '';
        for(String fieldName : fieldMap.keyset()){
            if(commaSepratedFields == null || commaSepratedFields == ''){
                commaSepratedFields = fieldName;
            }else{
                commaSepratedFields = commaSepratedFields + ', ' + fieldName;
            }
        }
      query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Where  Date__c=:tDate Limit 10';

     System.debug('query:'+query);
     System.debug('uDate:'+uDate);


 TEList = Database.query(query);

 totalCount = TEList.size();
 
 
 delTEList = new List<Time_Entry__c>();
 delTEs = new List<Time_Entry__c>();
 }
 
 public void addRow(){
 addTEList = new List<Time_Entry__c>();
 TEList.add(new Time_Entry__c(Date__c = dum.dateOne__c));
 }
 
 public PageReference ave(){
 
 upsert TEList;
 delete delTEList;
 return (new ApexPages.StandardController(timecards)).view();
 } 
 
 public void deleteRow(){
 
 rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
 System.debug('rowbe deleted ' + rowIndex );
 System.debug('rowm to be deleted '+TEList[rowIndex]);
 del = TEList.remove(rowIndex);
 delTEList.add(del);
 
 }
// }
 }





 
I have been trying various "examples" to create a sub-total for columns in a visualforce page and have had no luck.  The closest I have gotten is the one below, however, the <script> doesn't seem to be working as I don't get any value in the <span></span> block when I render the page.

Could anyone take a look to see if my code is missing anything ?  See the <apex:facet> at the bottom which references the place that should be populated with the total.  I have a variable that should be holding the total, but not sure how to check this.
 
<apex:page controller="fetchTimeCardEntryDataController" tabStyle="Account" docType="HTML-5.0">
    <apex:form >
        <!-- Variables to hold Totals -->
        <apex:variable value="{!0.00}" var="tMon"/>
        <apex:variable value="{!0.00}" var="Total_Tuesday"/>
        <apex:variable value="{!0.00}" var="Total_Wednesday"/>
        <apex:variable value="{!0.00}" var="Total_Thursday"/>
        <apex:variable value="{!0.00}" var="Total_Friday"/>
        <apex:variable value="{!0.00}" var="Total_Saturday"/>
        <apex:variable value="{!0.00}" var="Total_Sunday"/>
        <apex:variable value="{!0.00}" var="Total_Grand"/>
        
        <apex:pageBlock Title="Time Card Entry Report">
            <!--Start and End block along with fetch button -->
            <apex:pageBlockButtons >
                <b>Starting Date</b><apex:inputfield value="{!dum.dateOne__c}"/>
                <b>Ending Date</b><apex:inputfield value="{!dum.dateTwo__c}"/>
                <apex:commandButton value="Fetch Time Entries" action="{!fetch}"/>
            </apex:pageBlockButtons>
          
           <!-- Debug - SQL statement -->
        <!--   <apex:pageBlockSection columns="1" title="DEBUG - Dynamic SOQL Query" collapsible="True">
                <apex:outputText value="{!query}">
                </apex:outputText>
            </apex:pageBlockSection> -->
             
            <!-- Display Time Entry Date -->
          
          <apex:pageblocktable value="{!TEList}" var="tec1" id="list1">
              <apex:column width="10" title="Week Starting" value="{!tec1.Monday_Date__c}"/>
              <apex:column headerValue="Mon">
                  <apex:outputfield value="{!tec1.Monday__c}"/>
                  <apex:variable var="tMon" value="{!tMon+1+tec1.Monday__c}"/>
                      <apex:facet name="footer">
                        t<span ID="tMonday"></span>
                      </apex:facet>
               </apex:column>
          
          </apex:pageblocktable>
          
          
         </apex:pageBlock>
        
        <!-- Script for generating Totals-->
        <script>
            document.getElementsByID('tMonday')[0].innerHTML='{!tMon}';
        </script>
         
    </apex:form>
</apex:page>

 
Hopeing someone can solve this for me.

I am trying to create variables to hold totals - in this case "Friday__c" hold either nothing or a decimal data type.  The query builds a list which I use in my visualforce page.  I would like to iterate through the list and add up all "Friday__c" fields into the variable totalFridayHours then display this field on my visualforce page.

I get the "Arithmetic Expression must use numeric arguments error in my "For" statement near the bottom of my code:
 
public class fetchTimeCardEntryDataController {

    public String datename{get;set;}
    public List<Time_Card_Entry__c> TEList{get;set;}
    public Decimal totalFridayHours {get;set;}
    public String query{get;set;}
    public dummyTable__c dum{get;set;} 


    public fetchTimeCardEntryDataController() {
        dum=new dummyTable__c();
    }

    public PageReference fetch(){
    
        Date sDate = dum.dateOne__c;
        Date eDate = dum.dateTwo__c;
    
        String SobjectApiName = 'Time_Card_Entry__c';
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
 
        String commaSepratedFields = '';
        for(String fieldName : fieldMap.keyset()){
            if(commaSepratedFields == null || commaSepratedFields == ''){
                commaSepratedFields = fieldName;
            }else{
                commaSepratedFields = commaSepratedFields + ', ' + fieldName;
            }
        }
      query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Where Monday_Date__c >=:sDate AND Monday_Date__c <=:eDate  Limit 500';

     System.debug('query:'+query);

        TEList = Database.query(query);
         // Process the totals

//************ERROR IN THIS BLOCK *******************

         for(Time_Card_Entry__c tec1 : TEList) {
         
         if(TEList.Friday__c!=null) {
             totalFridayHours += time_card_entry__c.Friday__c;
           }
         
         }

        return null;
    }
}

 
I am making a time entry report in a visualforce page that looks up records (hours in a week); based on a start / finish day and then displays the time in a grid format.

Is there a way that I can use a variable on the page to store the hours in each week that is written to the page and then at the bottom of the "Grid" show a total for each day.  I would then also want another variable "grandtotal" to display the total hours of all days.

Below is a screen shot of the page and the visual force code that follows.
User-added image
 
<apex:page controller="selectAllSOQLExampleController" tabStyle="Account" docType="HTML-5.0">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
               
                <b>Starting (yyyy-mm-dd): </b> <apex:inputText size="10" id="startDate" value="{!startDate}"/>&nbsp; &nbsp;
                <b>Ending (yyyy-mm-dd):</b>  <apex:inputText size="10" id="endDate" value="{!endDate}"/>&nbsp; &nbsp;
               
                <apex:commandButton value="Fetch Time Entries" action="{!fetch}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1" title="Dynamic SOQL Query" collapsible="True">
                <apex:outputText value="{!query}">
                </apex:outputText>
            </apex:pageBlockSection>
 
            <apex:pageBlockSection title="Billable Docket Report" columns="1" collapsible="False">Test
                <apex:pageBlockTable value="{!TEList}" var="tec">
                    <apex:column width="10" title="Week Starting" value="{!tec.Monday_Date__c}"/>
                    <apex:column width="30" value="{!tec.Functional_Area__c}"/>
                    <apex:column width="20" value="{!tec.Standard_Activities__c}"/>
                    <apex:column value="{!tec.Activity_Other__c}"/>
                    <apex:column width="10" value="{!tec.Project__c}"/>
                    <apex:column width="10" value="{!tec.Contract__c}"/>
                    <apex:column width="10" headerValue="Mon">
                        <apex:outputField value="{!tec.Monday__c}" Rendered="{!IF(MONTH(tec.Monday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" headerValue="Tue">
                        <apex:outputField value="{!tec.Tuesday__c}" Rendered="{!IF(MONTH(tec.Tuesday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" headerValue="Wed">
                        <apex:outputField value="{!tec.Wednesday__c}" Rendered="{!IF(MONTH(tec.Wednesday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" headerValue="Thu">
                        <apex:outputField value="{!tec.Thursday__c}" Rendered="{!IF(MONTH(tec.Thursday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" headerValue="Fri">
                        <apex:outputField value="{!tec.Friday__c}" Rendered="{!IF(MONTH(tec.Friday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" headerValue="Sat">
                        <apex:outputField value="{!tec.Saturday__c}" Rendered="{!IF(MONTH(tec.Saturday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" headerValue="Sun">
                        <apex:outputField value="{!tec.Sunday__c}" Rendered="{!IF(MONTH(tec.Sunday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" value="{!tec.subtotal__c}"/>
                    
                </apex:pageBlockTable>
 
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
Is it possible to use and IF statement when displaying date from a LIST using apex:column.  In my example below, I want to check the value of Monday_Date and if it is in a specific month, display the "Monday" field; if not, then don't display the "Monday" field.

In my Data set, there is a field called "tec.Monday_Date__c" which I don't display on the page.  I would like to check the value of the "tec.Monday_Date__c" and if it equals a certain month, then display the data in the "tec.Monday__c" field; if not, then display nothing.

In psuedo-code, I would like to do this:

If (MONTH(tec.Monday_Date__c) = MONTH(tec_Start_date__c),
   Then   <apex:column width="10" value="{!tec.Monday__c}"/>
    Else   don't display the value for that column.

Is that possible?

 
<apex:pageBlockSection title="Billable Docket Report" columns="1" collapsible="False">Test
                <apex:pageBlockTable value="{!TEList}" var="tec">
                    <apex:column width="30" value="{!tec.Functional_Area__c}"/>
                    <apex:column width="20" value="{!tec.Standard_Activities__c}"/>
                    <apex:column value="{!tec.Activity_Other__c}"/>
                    <apex:column width="10" value="{!tec.Project__c}"/>
                    <apex:column width="10" value="{!tec.Contract__c}"/>
                    <apex:column width="10" value="{!tec.Monday__c}"/>
                    <apex:column width="10" value="{!tec.Tuesday__c}"/>

 
Newbie here (sorry folks!); and I'm trying to get a date passed to my controller.  I created a dummy object (dummyTable) containing a date field so that I could use the InputText on my visual force page for the date field.  I did this so that the date picker would work.

The date I think is now passing to the controller, but I keep getting this error:

System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!fetch}' in component <apex:commandButton> in page testtereport: Class.selectAllSOQLExampleController.fetch: line 31, column 1
Class.selectAllSOQLExampleController.fetch: line 31, column 1

If I change my query to hard-code a date, I don't get the error.

Can anyone help? 

Below is the Visual Force Page; and Controller:
 
<apex:page controller="selectAllSOQLExampleController" tabStyle="Account" docType="HTML-5.0">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
               
               <b>Start Date: </b><apex:inputfield value="{!dum.dateOne__c}"/>
               
                <apex:commandButton value="Fetch Time Entries" action="{!fetch}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1" title="Dynamic SOQL Query" collapsible="True">
                <apex:outputText value="{!query}">
                </apex:outputText>
            </apex:pageBlockSection>
 
            <apex:pageBlockSection title="Billable Docket Report" columns="1" collapsible="False">Test
                <apex:pageBlockTable value="{!TEList}" var="tec">
                    <apex:column width="30" value="{!tec.Functional_Area__c}"/>
                    <apex:column width="20" value="{!tec.Standard_Activities__c}"/>
                    <apex:column value="{!tec.Activity_Other__c}"/>
                    <apex:column width="10" value="{!tec.Project__c}"/>
                    <apex:column width="10" value="{!tec.Contract__c}"/>
                    <apex:column width="10" value="{!tec.Monday__c}"/>
                    <apex:column width="10" value="{!tec.Tuesday__c}"/>
                    <apex:column width="10" value="{!tec.Wednesday__c}"/>
                    <apex:column width="10" value="{!tec.Thursday__c}"/>
                    <apex:column width="10" value="{!tec.Friday__c}"/>
                    <apex:column width="10" value="{!tec.subtotal__c}"/>
                </apex:pageBlockTable>
 
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
and the controller:

You can see on in the Query String, that the commented out query is working (with the hard-coded date); but the one with the dum.dateOne__c is not working.
public class selectAllSOQLExampleController {

   
    public dummyTable__c dum{get;set;} 
    public String startdt{get;set;}
    public List<Time_Card_Entry__c> TEList{get;set;}
    public String query{get;set;}
    public String startDate{get;set;}

 
 
 //   public dummyTable__c dum() {
 //    if(dum == null) dum = new dummyTable__c();
 //   return dum;
 //   }
    
    public PageReference fetch(){
        String SobjectApiName = 'Time_Card_Entry__c';
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
 
        String commaSepratedFields = '';
        for(String fieldName : fieldMap.keyset()){
            if(commaSepratedFields == null || commaSepratedFields == ''){
                commaSepratedFields = fieldName;
            }else{
                commaSepratedFields = commaSepratedFields + ', ' + fieldName;
            }
        }
 //       query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Where Monday_Date__c >=' + '2015-01-14' + ' Limit 500';
        query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Where Monday_Date__c >=' + dum.dateOne__c + ' Limit 500';
         
  
 
        TEList = Database.query(query);
 
        return null;
    }
}


 
Hopeing someone can solve this for me.

I am trying to create variables to hold totals - in this case "Friday__c" hold either nothing or a decimal data type.  The query builds a list which I use in my visualforce page.  I would like to iterate through the list and add up all "Friday__c" fields into the variable totalFridayHours then display this field on my visualforce page.

I get the "Arithmetic Expression must use numeric arguments error in my "For" statement near the bottom of my code:
 
public class fetchTimeCardEntryDataController {

    public String datename{get;set;}
    public List<Time_Card_Entry__c> TEList{get;set;}
    public Decimal totalFridayHours {get;set;}
    public String query{get;set;}
    public dummyTable__c dum{get;set;} 


    public fetchTimeCardEntryDataController() {
        dum=new dummyTable__c();
    }

    public PageReference fetch(){
    
        Date sDate = dum.dateOne__c;
        Date eDate = dum.dateTwo__c;
    
        String SobjectApiName = 'Time_Card_Entry__c';
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
 
        String commaSepratedFields = '';
        for(String fieldName : fieldMap.keyset()){
            if(commaSepratedFields == null || commaSepratedFields == ''){
                commaSepratedFields = fieldName;
            }else{
                commaSepratedFields = commaSepratedFields + ', ' + fieldName;
            }
        }
      query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Where Monday_Date__c >=:sDate AND Monday_Date__c <=:eDate  Limit 500';

     System.debug('query:'+query);

        TEList = Database.query(query);
         // Process the totals

//************ERROR IN THIS BLOCK *******************

         for(Time_Card_Entry__c tec1 : TEList) {
         
         if(TEList.Friday__c!=null) {
             totalFridayHours += time_card_entry__c.Friday__c;
           }
         
         }

        return null;
    }
}

 
Hi there,

I am really struggling to write 2 test classes for 2 extensions.  Is there any good documentation to help write these test classes? The only resource I found was http://www.salesforce.com/docs/developer/pages/Content/pages_controller_error_handling.htm and it isn't helping...

The first extension is called by one VF page, then on success calls a second VF page that has it's own extension.  Both extensions follow here.
 
public class openTimeEntry {
public dummyTable__c dum{get;set;}
public Time_Entry__c emp{get;set;}
public ID pID{get;set;}
public String eID{get;set;}
private Date uDate; 


public openTimeEntry(ApexPages.StandardController controller) { 
    Date uDate = Date.valueOf(System.Now());
    dum=new dummyTable__c();
    emp=new Time_Entry__c();
    }

public PageReference fetchPage(){   
     String uAlias =  UserUtil.CurrentUser.Alias;    
     System.debug('ualias'+uAlias);
      eID = emp.Employee1__c;
      System.debug('eID'+eID);
      if(UserUtil.CurrentUser.Alias=='hsto'||UserUtil.CurrentUser.Alias=='cserv'||UserUtil.CurrentUser.Alias=='pdisc'||UserUtil.CurrentUser.Alias=='data'||UserUtil.CurrentUser.Alias=='edisc'||UserUtil.CurrentUser.Alias=='code'){
          
          if(eid==null){
         ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Please enter your name in the Employee field'));
    return null;
           }
       }
       
    
      String testDate = String.valueof(dum.dateOne__c);
      if(testDate==null) {
          uDate = Date.today();
      }else{
          uDate = dum.dateOne__c; 
      }
      System.debug('openTimeEntryTestDate'+testDate);
      System.debug('openTimeEntrydumDate'+dum.dateOne__c);
      System.debug('openTimeEntryuDate'+uDate);
      System.debug('ProjectID'+pID);
      //System.debug('useralias:'+uAlias);
      System.debug('geteID:'+eID);     
    pageReference teGridView = new PageReference('/apex/teGridView?uDate='+uDate+'&pid='+pID+'&eid='+eID);
    return teGridView; 
    }
}

Extension for 2nd vf page.
 
public class teGridClass {
    public dummyTable__c dum{get;set;}
    public Time_Entry__c timecards {get;set;}
    public Time_Entry__c del;
    public List<Time_Entry__c> addTEList {get;set;}
    public List<Time_Entry__c> delTEList {get;set;}
    public List<Time_Entry__c> TEList {get;set;}
    public Integer totalCount {get;set;}
    public Integer rowIndex {get;set;}
    public String query{get;set;}
    Public Date tDate{get;set;}
    Private Date uDate{get;set;}
    public String pID{get;set;}
    public String eID{get;set;}
    public String cID{get;set;}
    public user currentuser{get;set;}
    public SFDC_Employee__c currEmployee{get;set;} 
    Private String sDate;
 
    // Map of PageParameters
    private Map<string,string> urlParams=ApexPages.currentPage().getParameters();
 
    // Set the variable in Constructor
    public List<Time_Entry__c> delTEs {get; set;} 
 
 
    public teGridClass(ApexPages.StandardController controller) {
        pID = apexpages.currentpage().getparameters().get('pID');
        eID = apexpages.currentpage().getparameters().get('eID');
        cID = apexpages.currentpage().getparameters().get('cID');
        if(urlParams.containsKey('uDate')){
            sDate = urlParams.get('uDate');
           }    
        dum=new dummyTable__c();
               
                        System.debug('tDate1'+tDate);
  
        tDate = dum.dateOne__c;
                        System.debug('DateOne'+dum.DateOne__c);
                        System.debug('tDate2'+tDate);
                        System.debug('uDate'+uDate);
                        System.debug('sDate'+sDate);

        timecards = (Time_entry__c)controller.getRecord();
        // Temp place Date value
        if(sDate==null) {            
              tDate = date.ValueOf(System.now());
         } else {
              tDate = date.ValueOf(sDate.substring(0,10));
         }
         // Pull Current User Information
         currentuser=new User();
         currentuser=[Select Id,Name, Alias, Firstname, LastName, Email from User where Id=:userinfo.getuserId()];
        
         // Pull Current Employee Information
         // IF(currentUser.Alias=='
       // currEmployee=new SFDC_Employee__c();
        // currEmployee=[Select Id,first_name__c from SFDC_Employee__c where User__c=:userinfo.getuserId()];
        
          System.debug('curUserAlias'+currentuser.alias);
         // System.debug('curempFirstName'+currEmployee.first_name__c);
     
        String SobjectApiName = 'Time_Entry__c';
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
 
        String commaSepratedFields = '';
        for(String fieldName : fieldMap.keyset()){
            if(commaSepratedFields == null || commaSepratedFields == ''){
                commaSepratedFields = fieldName;
            }else{
                commaSepratedFields = commaSepratedFields + ', ' + fieldName;
            }
        }
        
        
        
        
        
      query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Where  Date__c=:tDate';
          if(eID.length()>6)
          //Do something with eID
           {
              query = query+' AND Employee1__c=:eID';
              currEmployee=new SFDC_Employee__c();
              currEmployee=[Select Id,first_name__c from SFDC_Employee__c where first_name__c=:userinfo.getfirstname() AND last_name__c=:userinfo.getlastname()];
        
          }else{
          // Look up employeeID based on user ID
          try{
              List<SFDC_Employee__c> E=[Select Id,first_name__c from SFDC_Employee__c where User__c=:userinfo.getuserId()];
              
              if (!E.isEmpty()) {
                
                }Else{
                currEmployee=new SFDC_Employee__c();
                 currEmployee=[Select Id,first_name__c from SFDC_Employee__c where User__c=:userinfo.getuserId()];
                 }
                
            }catch(Exception ex){
             ApexPages.addMessages(ex);
             }
        
              query = query+'';
          }
          
          if(pID.length()>6)
          //Do something with pID
           {
              query = query+' AND Project__c=:pID';
          }else{
              query = query+'';
          }
          query = query+' LIMIT 10';

                     System.debug('query:'+query);
                     System.debug('uDate:'+uDate);
                     System.debug('projectID:'+pID);
                     System.debug('EmpID:'+eID);
                     System.debug('Esize: ' + eID.length() );
                     System.debug('psize: ' + pID.length() );
                     System.debug('DateOne'+dum.DateOne__c);
                     System.debug('tDate2'+tDate);
                     System.debug('uDate'+uDate);
                     System.debug('sDate'+sDate);
             


 TEList = Database.query(query);

 totalCount = TEList.size();
 
                     System.debug('totalcount'+totalCount);
    IF(totalCount==0){
        addRow();
     }
 
 
 delTEList = new List<Time_Entry__c>();
 delTEs = new List<Time_Entry__c>();
 }
 
 public void addRow(){

        currEmployee=new SFDC_Employee__c();
        currEmployee=[Select Id,first_name__c from SFDC_Employee__c where User__c=:userinfo.getuserId()];

        eID=currEmployee.ID;

 System.debug('query:'+query);
                     System.debug('uDate:'+uDate);
                     System.debug('projectID:'+pID);
                     System.debug('EmpID:'+eID);
                     System.debug('Esize: ' + eID.length() );
                     System.debug('psize: ' + pID.length() );
                     System.debug('DateOne'+dum.DateOne__c);
                     System.debug('tDate2'+tDate);
                     System.debug('uDate'+uDate);
                     System.debug('sDate'+sDate);
 addTEList = new List<Time_Entry__c>();
 TEList.add(new Time_Entry__c(Date__c = tDate, project__c = pid, contract__c = cid, employee1__c=eid));
 }
 
 public PageReference ave(){
 
 try{
 
     upsert TEList;
     delete delTEList;
     
     
     return (new ApexPages.StandardController(timecards)).view();
     
     }catch(Exception ex){
     ApexPages.addMessages(ex);
     }
     return null;
 } 
 
 public void deleteRow(){
 
 rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
                     System.debug('rowbe deleted ' + rowIndex );
                     System.debug('rowm to be deleted '+TEList[rowIndex]);
 del = TEList.remove(rowIndex);
 delTEList.add(del);
 
 }
// }
 }


 
I have a visualforce page that has a date input.  This page is embedded in a object page detail.

My goal is to have them select a date - click the button which takes them to a new pop-up window / visualforce page where they can enter time / hours.

Depending on which object the first visualforce page is embedded, I want to pass that objects recordID to the controller, but I am getting nothing - getting "null".  I have tried <apex:param and <apex:inputhidden and neither work.

The workflow is:
  •      PARENT OBJECT (CCI_project__c) has an embedded VF page called "terlproject"
  •      TERLPROJECT has a form with a date picker.  Once the button is clicked, the controller is "OpenTimeEntry"
  •      All OpenTimeEntry does is gather the parameters (date and objectID) and pass it to a new VF page called teGridView
  •      TEGRIDVIEW has a controller (teGridClass) that pulls data and populates the VF page "teGridView"

Can anyone help?  Below is screen shots and code:

1.  embedded visualforce page "terlProject"   In this case, It is on a custom object called "CCI_Project__C" and I am trying to pass the Date and REcord ID - the date is passing fine - the record ID is not (I display it on the VF page so I know the ID exists)
User-added image

The code for the Visualforce page is: 
<apex:page Standardcontroller="CCI_Project__c" extensions="openTimeEntry">
    <apex:form >
        <!-- Variables go here -->
        

        <!-- Input Buttons here -->
        <apex:pageBlock >
            <apex:pageBlockButtons >
                <b>Date</b><apex:inputfield value="{!dum.dateOne__c}"/>
                <apex:inputHidden value="{!CCI_Project__c.ID}" id="projID"/>
               Project. <apex:outputField value="{!CCI_Project__c.id}"/>
                <apex:commandButton value="Enter Time" action="{!fetchPage}">
               <!-- <apex:param name="projID" value="{!CCI_Project__c.ID}" assignTo="{!projID}"/>-->
                </apex:commandButton>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
    
    <!-- Related List Displays here -->



</apex:page>

Once clicked, I call the controller class "openTimeEntry" - you will see i have tried various ways of "getting" the ProjectID - but debug shows null.
public class openTimeEntry {
public dummyTable__c dum{get;set;}
public ID projID{get;set;}
public cci_Project__c co {get; set;}
private Date uDate; 

public openTimeEntry(ApexPages.StandardController controller) { 
    Date uDate = Date.valueOf(System.Now());
    dum=new dummyTable__c();
    System.debug('ProjID: '+projID);
    }

public PageReference fetchPage(){
      
      String testDate = String.valueof(dum.dateOne__c);
      if(testDate==null) {
          uDate = Date.today();
      }else{
          uDate = dum.dateOne__c; 
       }

              System.debug('openTimeEntryTestDate'+testDate);
              System.debug('openTimeEntrydumDate'+dum.dateOne__c);
              System.debug('openTimeEntryuDate'+uDate);
              System.debug('ProjectID----'+projID+co);
      
        pageReference teGridView = new PageReference('/apex/teGridView?uDate='+uDate+'&projectID='+projID);
        return teGridView ;
    
    }
 
  
}
Then I re-direct to the teGridView which has a controller class teGridClass

Here is the page, followed by the class.
<apex:page standardController="Time_Entry__c" extensions="teGridClass" sidebar="true">
 <apex:form >
 <apex:pageBlock title="Time Card" id="pb">
 <apex:pageMessages />
 <apex:variable var="rowNumber" value="{!0}"/>
            <!-- Debug - SQL statement -->
           <apex:pageBlockSection columns="1" title="DEBUG - Dynamic SOQL Query" collapsible="True">
                <apex:outputText value="{!query}">
                </apex:outputText>
               Date:  
                <apex:outputText value="{!tDate}">
                </apex:outputText>
               EmployeeID:  
                <apex:outputText value="{!tDate}">
                </apex:outputText>
            </apex:pageBlockSection>
 <apex:pageBlockSection title="Daily Time Entry" collapsible="false">
 Date:  <apex:outputText value="{!tDate}">
                </apex:outputText>
                
 Employee:  <apex:outputText value="{!tDate}">
                </apex:outputText>
 </apex:pageBlockSection>
 <apex:pageblockSection columns="1">
 <apex:pageBlockTable title="Time Card Entries" var="tce" value="{!TEList}"> 

 <apex:column headerValue="No." style="width:10px; text-align:center;" headerClass="centertext">
 <apex:outputText value="{0}" style="text-align:center;"> 
 <apex:param value="{!rowNumber+1}" /> 
 </apex:outputText>
 </apex:column> 
 <apex:column headerValue="Functional Area" width="10px">
 <apex:inputField value="{!tce.Functional_Area__c}"/>
 </apex:column> 
 
 <apex:column headerValue="Activity Detail" width="10px">
 <apex:inputField value="{!tce.Description__c}"/>
 </apex:column> 
 <apex:column headerValue="Project" width="10px">
 <apex:inputField value="{!tce.Project__c}"/>
 </apex:column> 
 <apex:column headerValue="Contract" width="10px">
 <apex:inputField value="{!tce.Contract__c}"/>
 </apex:column> 
 <apex:column headerValue="Hours" width="5%">
 <apex:inputField value="{!tce.Total_Time__c}"/>
 </apex:column> 
 <apex:column headerValue="Date" width="10px">
 <apex:inputField value="{!tce.Date__c}"/>
 </apex:column> 
 

 
 <apex:column headerValue="Action" >
 <apex:commandButton value="Delete" action="{!deleteRow}" reRender="pb">
 <apex:param name="rowIndex" value="{!rowNumber}"/>
 </apex:commandButton>
 <apex:variable var="rowNumber" value="{!rowNumber+1}"/>
 </apex:column> 
 </apex:pageBlockTable>
 <apex:commandButton action="{!addRow}" value="Add Time" reRender="pb"/>
 </apex:pageblockSection>
 <apex:pageBlockButtons >
 <apex:commandButton value="Save" action="{!ave}" />
 <apex:commandButton value="Cancel" action="{!cancel}"/>
 </apex:pageBlockButtons>
 </apex:pageBlock>
 </apex:form> 
 </apex:page>
teGridClass:
public class teGridClass {
    public dummyTable__c dum{get;set;}
    public Time_Entry__c timecards {get;set;}
    public Time_Entry__c del;
    public List<Time_Entry__c> addTEList {get;set;}
    public List<Time_Entry__c> delTEList {get;set;}
    public List<Time_Entry__c> TEList {get;set;}
    public Integer totalCount {get;set;}
    public Integer rowIndex {get;set;}
    public String query{get;set;}
    Public Date tDate{get;set;}
    Private Date uDate{get;set;}
    Private String sDate;
 
    // Map of PageParameters
    private Map<string,string> urlParams=ApexPages.currentPage().getParameters();
 
    // Set the variable in Constructor

    public List<Time_Entry__c> delTEs {get; set;} 
 
    public teGridClass(ApexPages.StandardController controller) {
    
        if(urlParams.containsKey('uDate')){
            sDate = urlParams.get('uDate');
             }
            
        dum=new dummyTable__c();
               
        System.debug('tDate1'+tDate);
  
        tDate = dum.dateOne__c;
        System.debug('DateOne'+dum.DateOne__c);
        System.debug('tDate2'+tDate);
        System.debug('uDate'+uDate);
        System.debug('sDate'+sDate);

 // public teGridClass (ApexPages.StandardController controller) {
     timecards = (Time_entry__c)controller.getRecord();
 // String tID = timecards.ID;

    
     // Temp place Date value
         if(sDate==null) {            
      tDate = date.ValueOf(System.now());
         } else {
         tDate = date.ValueOf(sDate.substring(0,10));
        
         }
     
        String SobjectApiName = 'Time_Entry__c';
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
 
        String commaSepratedFields = '';
        for(String fieldName : fieldMap.keyset()){
            if(commaSepratedFields == null || commaSepratedFields == ''){
                commaSepratedFields = fieldName;
            }else{
                commaSepratedFields = commaSepratedFields + ', ' + fieldName;
            }
        }
      query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Where  Date__c=:tDate Limit 10';

     System.debug('query:'+query);
     System.debug('uDate:'+uDate);


 TEList = Database.query(query);

 totalCount = TEList.size();
 
 
 delTEList = new List<Time_Entry__c>();
 delTEs = new List<Time_Entry__c>();
 }
 
 public void addRow(){
 addTEList = new List<Time_Entry__c>();
 TEList.add(new Time_Entry__c(Date__c = dum.dateOne__c));
 }
 
 public PageReference ave(){
 
 upsert TEList;
 delete delTEList;
 return (new ApexPages.StandardController(timecards)).view();
 } 
 
 public void deleteRow(){
 
 rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
 System.debug('rowbe deleted ' + rowIndex );
 System.debug('rowm to be deleted '+TEList[rowIndex]);
 del = TEList.remove(rowIndex);
 delTEList.add(del);
 
 }
// }
 }





 
I have been trying various "examples" to create a sub-total for columns in a visualforce page and have had no luck.  The closest I have gotten is the one below, however, the <script> doesn't seem to be working as I don't get any value in the <span></span> block when I render the page.

Could anyone take a look to see if my code is missing anything ?  See the <apex:facet> at the bottom which references the place that should be populated with the total.  I have a variable that should be holding the total, but not sure how to check this.
 
<apex:page controller="fetchTimeCardEntryDataController" tabStyle="Account" docType="HTML-5.0">
    <apex:form >
        <!-- Variables to hold Totals -->
        <apex:variable value="{!0.00}" var="tMon"/>
        <apex:variable value="{!0.00}" var="Total_Tuesday"/>
        <apex:variable value="{!0.00}" var="Total_Wednesday"/>
        <apex:variable value="{!0.00}" var="Total_Thursday"/>
        <apex:variable value="{!0.00}" var="Total_Friday"/>
        <apex:variable value="{!0.00}" var="Total_Saturday"/>
        <apex:variable value="{!0.00}" var="Total_Sunday"/>
        <apex:variable value="{!0.00}" var="Total_Grand"/>
        
        <apex:pageBlock Title="Time Card Entry Report">
            <!--Start and End block along with fetch button -->
            <apex:pageBlockButtons >
                <b>Starting Date</b><apex:inputfield value="{!dum.dateOne__c}"/>
                <b>Ending Date</b><apex:inputfield value="{!dum.dateTwo__c}"/>
                <apex:commandButton value="Fetch Time Entries" action="{!fetch}"/>
            </apex:pageBlockButtons>
          
           <!-- Debug - SQL statement -->
        <!--   <apex:pageBlockSection columns="1" title="DEBUG - Dynamic SOQL Query" collapsible="True">
                <apex:outputText value="{!query}">
                </apex:outputText>
            </apex:pageBlockSection> -->
             
            <!-- Display Time Entry Date -->
          
          <apex:pageblocktable value="{!TEList}" var="tec1" id="list1">
              <apex:column width="10" title="Week Starting" value="{!tec1.Monday_Date__c}"/>
              <apex:column headerValue="Mon">
                  <apex:outputfield value="{!tec1.Monday__c}"/>
                  <apex:variable var="tMon" value="{!tMon+1+tec1.Monday__c}"/>
                      <apex:facet name="footer">
                        t<span ID="tMonday"></span>
                      </apex:facet>
               </apex:column>
          
          </apex:pageblocktable>
          
          
         </apex:pageBlock>
        
        <!-- Script for generating Totals-->
        <script>
            document.getElementsByID('tMonday')[0].innerHTML='{!tMon}';
        </script>
         
    </apex:form>
</apex:page>

 
I am making a time entry report in a visualforce page that looks up records (hours in a week); based on a start / finish day and then displays the time in a grid format.

Is there a way that I can use a variable on the page to store the hours in each week that is written to the page and then at the bottom of the "Grid" show a total for each day.  I would then also want another variable "grandtotal" to display the total hours of all days.

Below is a screen shot of the page and the visual force code that follows.
User-added image
 
<apex:page controller="selectAllSOQLExampleController" tabStyle="Account" docType="HTML-5.0">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
               
                <b>Starting (yyyy-mm-dd): </b> <apex:inputText size="10" id="startDate" value="{!startDate}"/>&nbsp; &nbsp;
                <b>Ending (yyyy-mm-dd):</b>  <apex:inputText size="10" id="endDate" value="{!endDate}"/>&nbsp; &nbsp;
               
                <apex:commandButton value="Fetch Time Entries" action="{!fetch}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1" title="Dynamic SOQL Query" collapsible="True">
                <apex:outputText value="{!query}">
                </apex:outputText>
            </apex:pageBlockSection>
 
            <apex:pageBlockSection title="Billable Docket Report" columns="1" collapsible="False">Test
                <apex:pageBlockTable value="{!TEList}" var="tec">
                    <apex:column width="10" title="Week Starting" value="{!tec.Monday_Date__c}"/>
                    <apex:column width="30" value="{!tec.Functional_Area__c}"/>
                    <apex:column width="20" value="{!tec.Standard_Activities__c}"/>
                    <apex:column value="{!tec.Activity_Other__c}"/>
                    <apex:column width="10" value="{!tec.Project__c}"/>
                    <apex:column width="10" value="{!tec.Contract__c}"/>
                    <apex:column width="10" headerValue="Mon">
                        <apex:outputField value="{!tec.Monday__c}" Rendered="{!IF(MONTH(tec.Monday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" headerValue="Tue">
                        <apex:outputField value="{!tec.Tuesday__c}" Rendered="{!IF(MONTH(tec.Tuesday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" headerValue="Wed">
                        <apex:outputField value="{!tec.Wednesday__c}" Rendered="{!IF(MONTH(tec.Wednesday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" headerValue="Thu">
                        <apex:outputField value="{!tec.Thursday__c}" Rendered="{!IF(MONTH(tec.Thursday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" headerValue="Fri">
                        <apex:outputField value="{!tec.Friday__c}" Rendered="{!IF(MONTH(tec.Friday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" headerValue="Sat">
                        <apex:outputField value="{!tec.Saturday__c}" Rendered="{!IF(MONTH(tec.Saturday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" headerValue="Sun">
                        <apex:outputField value="{!tec.Sunday__c}" Rendered="{!IF(MONTH(tec.Sunday_Date__c) = MONTH(tec.Monday_Date__c), true, false)}"/>
                    </apex:column>
                    <apex:column width="10" value="{!tec.subtotal__c}"/>
                    
                </apex:pageBlockTable>
 
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 
Is it possible to use and IF statement when displaying date from a LIST using apex:column.  In my example below, I want to check the value of Monday_Date and if it is in a specific month, display the "Monday" field; if not, then don't display the "Monday" field.

In my Data set, there is a field called "tec.Monday_Date__c" which I don't display on the page.  I would like to check the value of the "tec.Monday_Date__c" and if it equals a certain month, then display the data in the "tec.Monday__c" field; if not, then display nothing.

In psuedo-code, I would like to do this:

If (MONTH(tec.Monday_Date__c) = MONTH(tec_Start_date__c),
   Then   <apex:column width="10" value="{!tec.Monday__c}"/>
    Else   don't display the value for that column.

Is that possible?

 
<apex:pageBlockSection title="Billable Docket Report" columns="1" collapsible="False">Test
                <apex:pageBlockTable value="{!TEList}" var="tec">
                    <apex:column width="30" value="{!tec.Functional_Area__c}"/>
                    <apex:column width="20" value="{!tec.Standard_Activities__c}"/>
                    <apex:column value="{!tec.Activity_Other__c}"/>
                    <apex:column width="10" value="{!tec.Project__c}"/>
                    <apex:column width="10" value="{!tec.Contract__c}"/>
                    <apex:column width="10" value="{!tec.Monday__c}"/>
                    <apex:column width="10" value="{!tec.Tuesday__c}"/>

 
Newbie here (sorry folks!); and I'm trying to get a date passed to my controller.  I created a dummy object (dummyTable) containing a date field so that I could use the InputText on my visual force page for the date field.  I did this so that the date picker would work.

The date I think is now passing to the controller, but I keep getting this error:

System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!fetch}' in component <apex:commandButton> in page testtereport: Class.selectAllSOQLExampleController.fetch: line 31, column 1
Class.selectAllSOQLExampleController.fetch: line 31, column 1

If I change my query to hard-code a date, I don't get the error.

Can anyone help? 

Below is the Visual Force Page; and Controller:
 
<apex:page controller="selectAllSOQLExampleController" tabStyle="Account" docType="HTML-5.0">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockButtons >
               
               <b>Start Date: </b><apex:inputfield value="{!dum.dateOne__c}"/>
               
                <apex:commandButton value="Fetch Time Entries" action="{!fetch}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1" title="Dynamic SOQL Query" collapsible="True">
                <apex:outputText value="{!query}">
                </apex:outputText>
            </apex:pageBlockSection>
 
            <apex:pageBlockSection title="Billable Docket Report" columns="1" collapsible="False">Test
                <apex:pageBlockTable value="{!TEList}" var="tec">
                    <apex:column width="30" value="{!tec.Functional_Area__c}"/>
                    <apex:column width="20" value="{!tec.Standard_Activities__c}"/>
                    <apex:column value="{!tec.Activity_Other__c}"/>
                    <apex:column width="10" value="{!tec.Project__c}"/>
                    <apex:column width="10" value="{!tec.Contract__c}"/>
                    <apex:column width="10" value="{!tec.Monday__c}"/>
                    <apex:column width="10" value="{!tec.Tuesday__c}"/>
                    <apex:column width="10" value="{!tec.Wednesday__c}"/>
                    <apex:column width="10" value="{!tec.Thursday__c}"/>
                    <apex:column width="10" value="{!tec.Friday__c}"/>
                    <apex:column width="10" value="{!tec.subtotal__c}"/>
                </apex:pageBlockTable>
 
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
and the controller:

You can see on in the Query String, that the commented out query is working (with the hard-coded date); but the one with the dum.dateOne__c is not working.
public class selectAllSOQLExampleController {

   
    public dummyTable__c dum{get;set;} 
    public String startdt{get;set;}
    public List<Time_Card_Entry__c> TEList{get;set;}
    public String query{get;set;}
    public String startDate{get;set;}

 
 
 //   public dummyTable__c dum() {
 //    if(dum == null) dum = new dummyTable__c();
 //   return dum;
 //   }
    
    public PageReference fetch(){
        String SobjectApiName = 'Time_Card_Entry__c';
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> fieldMap = schemaMap.get(SobjectApiName).getDescribe().fields.getMap();
 
        String commaSepratedFields = '';
        for(String fieldName : fieldMap.keyset()){
            if(commaSepratedFields == null || commaSepratedFields == ''){
                commaSepratedFields = fieldName;
            }else{
                commaSepratedFields = commaSepratedFields + ', ' + fieldName;
            }
        }
 //       query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Where Monday_Date__c >=' + '2015-01-14' + ' Limit 500';
        query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Where Monday_Date__c >=' + dum.dateOne__c + ' Limit 500';
         
  
 
        TEList = Database.query(query);
 
        return null;
    }
}