• ali abdullah
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 7
    Replies

hello,

 

i am new to visual force and apex and will appreciate the help on below.

 

i created a table in VF and retrieving the data like consultants , no of project and no of tasks from from the controller. its working fine but i need to click one of the consultants from the list above to get the detail report on the other page. i am trying to pass some parameters once "Onclick" function is performed but its returning null when i am clikcing on one of the consultant to get the reports on new page. below is my VF page.

 

Visual Force Page :

 

<apex:page controller="Consultant_Information">

<script type="text/javascript">
      function loadReports(Alias){
        if(typeof AF_LoadReports  == "function") {AF_LoadReports(Alias);}
      }
  </script>


  <apex:form >
  <apex:actionFunction name="AF_LoadReports" action="{!loadReports}" >
  <apex:param name="Alias" assignTo="{!Alias1}" value="" />    
  </apex:actionFunction>
  <apex:pageBlock title="Consultant Summary" >
  <apex:PageBlockSection columns="1" >
 <apex:pageBlockTable value="{!Items}" var="item">

 
<apex:column headerValue="Consultant" value="{!item.theUser.Name}" onclick="javascript&colon;AF_LoadReports('{!item.theUser.Alias}')"/>
<apex:column headerValue="Department" value="{!item.theUser.Division}"/>
<apex:column headerValue="Active Projects" value="{!item.noProjects}"/>
<apex:column headerValue="Active Tasks" value="{!item.noTasks}"/>
<apex:column headerValue="Last Login Date" value="{!item.theUser.LastLoginDate}"/>
</apex:pageBlockTable>
  </apex:PageBlockSection>
 
 
 
 
  
   
       
     </apex:pageBlock>

   
  </apex:form>
  </apex:page>

 

 

 

and below is my controler

 

public with sharing class Consultant_Information {
 public Consultant_Information(){
  loadConsultants();
 }
 
 public class userWrap{
                public User theUser{get;set;}
                public integer noProjects{get;set;}
                public integer noTasks{get;set;}
             
   }
public PageReference loadReports(){  
 String Alias1 =ApexPages.currentPage().getParameters().get('Alias');
 PageReference pageRef = new PageReference('https://c.na7.visual.force.com/apex/pConsultantSummary?Alias'+'='+Alias1);                    
  pageRef.setRedirect(true);
 
  return pageRef;
  }
 
public List<userWrap> listConsultant = new list<userWrap>();
  
public List<userWrap> getItems() {return listConsultant;}
 
 private void loadConsultants(){ 
 listConsultant.clear();
 List<User> users = new List<User>([Select u.Name, u.Id, u.Alias, u.Division, u.LastLoginDate From User u where u.IT_User__c = true and u.IsActive = true order by u.Name]);
 List<AggregateResult> Projects = new List<AggregateResult>([Select count(p.Id) noProjects, p.OwnerId from Project__c p where p.Project_Life_Cycle_Stages_2__c <> 'Closed' group by p.OwnerId]);
 List<AggregateResult> Tasks = new List<AggregateResult>([Select count(t.Id) noTasks, t.OwnerId from Task__c t where t.Task_Status__c <> 'Closed' group by t.OwnerId]);

 for(User u : users){
  userWrap wrap = new userWrap();
  wrap.theUser = u;
   for(AggregateResult r : projects){
   if(r.get('OwnerId') == u.Id){wrap.noProjects = (r.get('noProjects')==null?0: integer.valueOf(r.get('noProjects'))) ;}
  }
  for(AggregateResult r : tasks){
   if(r.get('OwnerId') == u.Id){wrap.noTasks = (r.get('noTasks')==null?0: integer.valueOf(r.get('noTasks')));}
  }
  listConsultant.add(wrap);
  }
  
 }
  
}

hello,

 

i am new to visual force and apex and will appreciate the help on below.

 

i created a table in VF and retrieving the data like consultants , no of project and no of tasks from from the controller. its working fine but i need to click one of the consultants from the list above to get the detail report on the other page. i am trying to pass some parameters once "Onclick" function is performed but its returning null when i am clikcing on one of the consultant to get the reports on new page. below is my VF page.

 

Visual Force Page :

 

<apex:page controller="Consultant_Information">

<script type="text/javascript">
      function loadReports(Alias){
        if(typeof AF_LoadReports  == "function") {AF_LoadReports(Alias);}
      }
  </script>


  <apex:form >
  <apex:actionFunction name="AF_LoadReports" action="{!loadReports}" >
  <apex:param name="Alias" assignTo="{!Alias1}" value="" />    
  </apex:actionFunction>
  <apex:pageBlock title="Consultant Summary" >
  <apex:PageBlockSection columns="1" >
 <apex:pageBlockTable value="{!Items}" var="item">

 
<apex:column headerValue="Consultant" value="{!item.theUser.Name}" onclick="javascript&colon;AF_LoadReports('{!item.theUser.Alias}')"/>
<apex:column headerValue="Department" value="{!item.theUser.Division}"/>
<apex:column headerValue="Active Projects" value="{!item.noProjects}"/>
<apex:column headerValue="Active Tasks" value="{!item.noTasks}"/>
<apex:column headerValue="Last Login Date" value="{!item.theUser.LastLoginDate}"/>
</apex:pageBlockTable>
  </apex:PageBlockSection>
 
 
 
 
  
   
       
     </apex:pageBlock>

   
  </apex:form>
  </apex:page>

 

 

 

and below is my controler

 

public with sharing class Consultant_Information {
 public Consultant_Information(){
  loadConsultants();
 }
 
 public class userWrap{
                public User theUser{get;set;}
                public integer noProjects{get;set;}
                public integer noTasks{get;set;}
             
   }
public PageReference loadReports(){  
 String Alias1 =ApexPages.currentPage().getParameters().get('Alias');
 PageReference pageRef = new PageReference('https://c.na7.visual.force.com/apex/pConsultantSummary?Alias'+'='+Alias1);                    
  pageRef.setRedirect(true);
 
  return pageRef;
  }
 
public List<userWrap> listConsultant = new list<userWrap>();
  
public List<userWrap> getItems() {return listConsultant;}
 
 private void loadConsultants(){ 
 listConsultant.clear();
 List<User> users = new List<User>([Select u.Name, u.Id, u.Alias, u.Division, u.LastLoginDate From User u where u.IT_User__c = true and u.IsActive = true order by u.Name]);
 List<AggregateResult> Projects = new List<AggregateResult>([Select count(p.Id) noProjects, p.OwnerId from Project__c p where p.Project_Life_Cycle_Stages_2__c <> 'Closed' group by p.OwnerId]);
 List<AggregateResult> Tasks = new List<AggregateResult>([Select count(t.Id) noTasks, t.OwnerId from Task__c t where t.Task_Status__c <> 'Closed' group by t.OwnerId]);

 for(User u : users){
  userWrap wrap = new userWrap();
  wrap.theUser = u;
   for(AggregateResult r : projects){
   if(r.get('OwnerId') == u.Id){wrap.noProjects = (r.get('noProjects')==null?0: integer.valueOf(r.get('noProjects'))) ;}
  }
  for(AggregateResult r : tasks){
   if(r.get('OwnerId') == u.Id){wrap.noTasks = (r.get('noTasks')==null?0: integer.valueOf(r.get('noTasks')));}
  }
  listConsultant.add(wrap);
  }
  
 }
  
}