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
cinov8cinov8 

Cannot retrieve param

I'm trying to allow the user to click a button in a pageBlockTable to launch a new URL.

 

Here is the page code:

 

<apex:column style="text-align: left;vertical-align:middle;">
           <apex:facet name="header">Action</apex:facet>
                    <apex:commandButton value="Log Time" action="{!LogTime}">
                            <apex:param name="selectedJob" value="{!job.Id}"/>
                    </apex:commandButton>
</apex:column>

 

..and here is the controller function:

 

public PageReference LogTime() {
        selectedJobID = System.currentPageReference().getParameters().get('selectedJob');
        PageReference ref = new PageReference('/' + selectedJobId);
        ref.setRedirect(true);
        return ref;   
    }

 

What am I doing wrong?

mikeafter6mikeafter6

I've had success passing a param to the controller using the 'assignTo' attribute of the <apex:param> tag.

 

Try:

- move selectedJobID so that it is a public controller variable 

   (move outside of the LogTime() method)

 

 

public Id selectedJobID {get; set;}

 

 - Then, add the assignTo attribute to your apex:param tag

 

<apex:param name="selectedJob" value="{!job.Id}" assignTo="selectedJobID" />

 

 

 

 - finally, remove the first line of the LogTime method (PageReference should now be the first line.)