Visualforce's expression language doesn't support the calling of controller methods with arbitrary parameters. (In occasional circumstances you may be able to use the available map syntax to approximate this.)
The binding between Visualforce pages and controllers is primarily based on controller properties that at most can have setter and getter methods. Multiple levels of reference are supported though e.g. "Child.Parent.ParentField".
So unfortunately you have to bend your thinking to these limitations, and as @dphil suggests that generally means refactoring so that instead of your controller supplying a list of SObjects, it supplies a list of "wrapper" objects:
public class MyWrapper {
public MySObject__c sob {get; private set;}
public MyWrapper(MySObject__c sob) {
this.sob = sob;
}
public String getStyle() {
Decimal val = getDefendNTAPNum();
if (val >= 0 && val < 25) {
return 'background-color:#FF0000;';
} else if ...
}
public Decimal getDefendNTAPNum() {
return ...;
}
}
Then your page can reference a "computed" value or just the underlying SObject field as required:
<apex:column headervalue="SitNum" style="{!w.style}" value="{!w.sob.MyField__c}">
Note that there is also a set of built in functions (including a CASE function) that sometimes can be used to implement basic conditional logic within the Visualforce expression.
Best Answer
This really depends on your Visualforce code and what you're checking against. For each column you can use a formula to determine whether or not a class gets used. For example:
You've not specified much, but the trick is here:
In other words for this example, if
DateField__c
is greater than today, returngreen
.green
is a CSS class and the formula is within thestyleClass
parameter. So, if the date is indeed greater than today, it'll render something like this:Edit
To answer your second question, in your CSS you'd need something like this:
Salesforce will have some standard styling and
:hover
will be one of them. You'll want to override/cascade over that by using your own class.Alternatively, you could do:
Although I'd avoid using this personally.