function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mike @ BlackTabMike @ BlackTab 

Calling Methods with Parameters From Visualforce

<apex:panelBar >
      <apex:repeat value="{!OpenProjects}" var="project" id="panelBarItems">
          <apex:panelBarItem label="Project Name: {!project.Project_Name__c}">
              <apex:detail subject="{!project.ID}" relatedList="false" inlineEdit="true" title="false" rendered="{!showDetails}"/>
              <apex:panelBar >
                  <apex:repeat value="{!Milestones(project.ID)}" var="milestone">
                      <apex:panelBarItem label="Milestone Name: {!milestone.Name}">
                      </apex:panelBarItem>
                  </apex:repeat>
              </apex:panelBar>
          </apex:panelBarItem>
      </apex:repeat>
  </apex:panelBar>

 

    //Get Milestones Based On Project
    public List<Milestone__c> getMilestones(ID Project) {
        return [SELECT Name FROM Milestone__c WHERE Project__c = :Project];
    }

 I'm trying to call a method "getMilestones" with a parameter called "Project" however i'm getting an apex error: Unknown Function Milestones

calvin_nrcalvin_nr

where are u calling that function?

Mike @ BlackTabMike @ BlackTab
<apex:repeat value="{!Milestones(project.ID)}" var="milestone">

 

Sealless2Sealless2

I really thought this kind of call would work, too - only because it seems so obvious.  Turns out it is not valid syntax - no arguments can be passed in this manner from VF to Apex controllers.  

 

There are some solutions out there that utilize apex:param and rerender but these are limited to command buttons and other actions. 

Mike @ BlackTabMike @ BlackTab

Interesting...Well I solved the problem. I just did an aggragate SOQL query and it did the trick.

varun.sforcevarun.sforce

 

Good, but question is still open, can we call apex function with parameter in VF page? I thoughts