- Home
- Technical Library
- Boards
- Cookbook
- Code Share
- Blogs
- Partners
-
More
-
Services
- Training & Certification
- Support
-
Galleries
- Force.com Sites Gallery
- Chatter Challenge Entries
-
Other Web Sites
- Salesforce.com
- Database.com
- AppExchange
- CRM Community
-
Discussions
- Announcements
- General Development
- Schema Development
- New to Cloud Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules Discussion
- Security
- Mobile
- Force.com Sites
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby Development
- Adobe Flash Builder for Force.com
- Desktop Integration
- REST API Integration
- Streaming API
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- Excel Connector
- AJAX Toolkit & S-controls
- Force.com Builder & Native Apps
- AppExchange Directory & Packaging
- Force.com Labs Projects
- Open Source
- Site.com
- Jobs Board - Administrators
- Jobs Board - Developers
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Visualforce Development
- :
- Pass Parameter from Page to Controller Method
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Pass Parameter from Page to Controller Method
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-24-2012 08:22 AM
Hi everyone,
I am trying to style rows in a table of Tasks based upon the due date and time of the tasks.
<apex:page showHeader="false" controller="atTaskListController">
<style type="text/css">
.normalPriority{font-weight:bold; background-color: #FFFFCC;}
.highPriority{font-weight:bold; background-color: #FFFFCC;}
.critical Priority{font-weight:bold; background-color: #FFFFCC;}
</style>
<apex:outputPanel id="taskList">
<apex:pageBlock title="Callback Task List" >
<apex:pageBlockTable value="{!tasks}" var="t">
<apex:column headerValue="Task"> <apex:outputLink value="/{!t.id}" target="_parent"> {!t.Task_ID__c}</apex:outputLink></apex:column>
<apex:column headerValue="Subject"><apex:outputLink value="/{!t.id}"> {!t.Subject}</apex:outputLink></apex:column>
<apex:column value="{!t.ActivityDate}" styleClass="{!style}"/>
<apex:column value="{!t.Due_Time__c}" />
<apex:column value="{!t.Priority}"/>
<apex:column value="{!t.Status}"/>
<apex:column value="{!t.whatid}"/>
<apex:column value="{!t.OwnerId}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:page>
public with sharing class atTaskListController {
private List<Task> tasks = new List<Task>();
private Task thisTask {get;set;}
Map<Id, String> styleMap = new Map<Id, String>();
public atTaskListController () {
Schema.Describesobjectresult r = Task.sObjectType.getDescribe();
Map<String, Schema.RecordTypeInfo> rtMap = r.getRecordTypeInfosByName();
Id tRt = rtMap.get('Callback Request').getRecordTypeId();
tasks = [select id, whoid, whatid,OwnerId, Subject, Priority, Task_ID__c,Due_Time__c, Due_Date_Time__c, ActivityDate, Status from Task
where OwnerId= :UserInfo.getUserId() AND RecordTypeId=:tRt AND (Status!='Cancelled' OR Status!='Completed')];
for(Task tk: tasks){
if(System.now()>=tk.ActivityDate){
styleMap.put(tk.id, 'overdue');
}else if(System.now()>=tk.Due_Date_Time__c.addHours(-2)) {
styleMap.put(tk.id, 'criticalPriority');
}else if(System.now()>=tk.Due_Date_Time__c.addHours(-4)) {
styleMap.put(tk.id, 'highPriority');
}else{
styleMap.put(tk.id, 'normalPriority');
}
}
}
public List<Task> getTasks(){
return tasks;
}
public String getStyle() {
return styleMap.get(thisTask.Id);
}
}My problem is that I cannot figure out how to get a the task 't' from the page into the controller. I'd like to pass it to getStyle(Task t) but cannot work out how to do this. I cannot rely upon user interaction to do this, it must just happen.
Any help much appreciated.
Cheers,
James.
Re: Pass Parameter from Page to Controller Method
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-24-2012 09:51 AM
Use a wrapper for your tasks .... the best way to describe is point you to a similar post: http://boards.developerforce.com/t5/Apex-Code-Deve
--dirk
++
If any of my replies/answers work for you, do mark them as 'Solution' as it may help others.
++
Re: Pass Parameter from Page to Controller Method
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-25-2012 06:05 PM - last edited on 02-25-2012 06:05 PM
If the logic for determining your normal, high, or critical status is relatively simple you could use a formula in your VF page. For example:
<apex:column value="{!t.Due_Time__c}" styleClass="{!IF( t.Due_Time__c < TODAY(), "normalPriority", "highPriority" )}" />
Otherwise, as Dirk mentioned above, a wrapper class with a variable to hold the style name would work well.
~ Clint
The Flywheel Group
www.theflywheelgroup.com
Re: Pass Parameter from Page to Controller Method
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-29-2012 01:52 AM
Dirk, Billy,
thanks for your help. As I'm pushed for time I went with the formula based solution but I'll remember the wrapper method for any more complex situations.
Cheers,
James.

