You need to sign in to do that
Don't have an account?
Binding outputText to Functions
How come I can bind outputText to a global macro like this:
<apex:outputText value="The formatted time right now is: {0}">
<apex:param value="{!NOW()}" />
</apex:outputText>
But I can't bind to a function on a custom controller like this:
<apex:outputText value="The formatted time right now is: {0}">
<apex:param value="{!MyCustomFunction()}" />
</apex:outputText>
In the second example (above) the error message is
Save error: Unknown function MyCustomFunction. Check spelling.
The method is public. Changing it to a property seems to work, but I lose the ability to pass arguments to the function, which is ultimately what I'm trying to achieve.
Thanks!
Well, I am afraid you can only bind to the property methods in the controller:(
But, you can still pass arguments to your controller method by using the params, right?
Am i missing something here?:S
Cool_D
This doesn't work either.
<!-- VF Page -->
<apex:outputText value="{!MyCustomProperty}">
<apex:param assignTo="{!GetSetProperty}" value="Display this" />
</apex:outputText>
//Controller
public with sharing class MyPageController {
public String GetSetProperty {get; set;}
public String MyCustomProperty{
get{
return GetSetProperty;
}
}
}
Looking at the page lifecycle documentation, I'd expect the param assignTo setter to have already happened before the outputText binding to MyCustomProperty. But it's not happening.
There must be an easier way to pass params to Apex functions for use in dynamic VF pages (?)
As per what i have read in the docs, the dependency between methods in the controller should be minimal as the order of execution is not fixed.
So, the best practice says, do not rely on methods getting executed in the systematic order. In case, there is a dependency, then try invoking the other method explicitly.
Maybe, you can try something like this-
<!-- VF Page -->
<apexutputText value="{!MyCustomProperty}">
<apexaram name="myProperty" value="Display this" />
</apexutputText>
//Controller
public with sharing class MyPageController {
public String GetSetProperty;
public String MyCustomProperty{
get{
String myProperty = ApexPages.currentPage().getParameters().get('myProperty');
// Add ur logic here and see if the myProperty is set to "Display this"
return GetSetProperty;
}
}
}
Cool_D
Hi There,
Did you ever get this to work?
I'm having exactly the same issue:
Get method simply doesn't get called at all.
TIA