You need to sign in to do that
Don't have an account?
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?
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.)