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

apex:commandLink not working per documentation - HELP!!
I have the following VF code:
When I load my VF page nothing happens. No redirect, no nothing.
What am I doing wrong here?
Thanks!!
<apex:page controller="Five9ScreenPop"> <head></head> <body> <apex:form> <apex:commandLink name="link" action="{!NewCase}" /> </apex:form> </body> </apex:page>Controller:
public with sharing class Five9ScreenPop{ public PageReference NewCase(){ PageReference pr = new PageReference('http://www.google.com'); pr.setRedirect(true); return pr; } }The SF documentation on <apex:commandLink> says "A link that executes an action defined by a controller, and then either refreshes the current page, or navigates to a different page based on the PageReference variable that is returned by the action." (http://www.salesforce.com/docs/developer/pages/Content/pages_compref_commandLink.htm)
When I load my VF page nothing happens. No redirect, no nothing.
What am I doing wrong here?
Thanks!!
The link does not work on page load, it only works when the user click on the link. The documentation says that "the link will execute an action" and does not say anything about the link working on page load. Having said that if you are looking to call the conroller's NewCase() method on pageload, the action attribute on the <apex:page> will help you call the method right away
<apex:page controller="Five9ScreenPop" action="{!NewCase}">
Note:The visualforce page will be redirected to google.com. You may have to relogin to salesforce based on ur browser setting.
All Answers
The link does not work on page load, it only works when the user click on the link. The documentation says that "the link will execute an action" and does not say anything about the link working on page load. Having said that if you are looking to call the conroller's NewCase() method on pageload, the action attribute on the <apex:page> will help you call the method right away
<apex:page controller="Five9ScreenPop" action="{!NewCase}">
Note:The visualforce page will be redirected to google.com. You may have to relogin to salesforce based on ur browser setting.
In order to go to external domain you can use javascript methods.
@Balaji:
When I do this all it does is refresh the page with the word "link" on it that is hyperlinked.
@Yury
I changed it to an internal link and it did the same thing.
When I click on the link it works, but I need it to redirect as soon as the VF page loads.
In your case
I recommend to use this approach in case of some controller logic should be executed
But if you need just redirect to another page (without any server side logic) I'd recommend to redirect from client side (javascript or html) for instance