You need to sign in to do that
Don't have an account?

Command Link Without page redirect
Hi there. I have a commandLink which wraps around an apex param.
I have set the value and action attributes for the commandLink although a page redirect occurs.
I do not want this to happen.
The associated action method in my controller has a return type of PageReference but returns null, although
when I click the link a page redirect still occurs.
Is there a way to bypass the page redirect with a commandLink?
Thanks
All Answers
Can you post your code please (page & controller/method)? (or a small reproducible case)
Certainly:
Here's my visualforce:
<apex:commandLink value="{!timeSlotVar.timeSlotStatus}" action="{!printId}" immediate="true"> <apex:param value="{!timeSlotVar.timeSlotId}" name="{!timeSlotVar.timeSlotId}" assignTo="{!testId}" /> </apex:commandLink>
And here's the relevant sections of my controller:
public Id testId { get; set; } . . . public PageReference printId() { System.debug('***** TESTID IS: ' + testId); return null; }
Thanks
Forgot to mention that the command link is encapsulated by an apex repeat
of which the var is timeSlotVar
Thanks
The full page is refreshed which I don't want...
Is there a way to cancel the refresh with a bit of Javascript incorporated into the onclick or oncomplete attributes?
Basically what I am trying to do, is simply set a property in my controller (which I do) and then do a rerender on a pageBlock - all without a complete page refresh...
It takes away from the elegance of rerenders.
Thanks
Well, you haven't specified a rerender attribute on the commandlink which is the queue to do partial page, otherwise it's full page.
Also, I don't think your param is going to be set with immediate="true" on your link. I suspect you'll need to drop that.
Thanks for the reply. I haven't gotten to the rerender yet because if the page does a full refresh, I won't need it.
Yep, the immediate=true is superfluous...
Any other ideas welcomed!
Perfect!
That worked a treat ;)