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

apex:outputLink redirecting to the wrong URL
Hi
I have an apex:outputLink field inside a table cell.
I set the value to: www.mysite.com but when I press the link I get directed to https://c.na12.visual.force.com/apex/www.mysite.com
I can't understand why this is happening and how to fix it.
Any advise is appreciated.
Thanks
Oded
I did some quick testing and you do need external links in the form http://www.whatever.com or it treats it as a local page reference. So you have three choices:
1. Make sure that pe.URL__c is in the form http://www.mysite.com.
2. Make sure that pe.URL__c is always in the form www.mysite.com and change your tag to:
<apex:outputLink value="http://{!pe.URL__c}" styleClass="outputLinkStyle" id="productionLink">
3. Use your controller to chek the first 7 characters of pe.URL__c and then return an appropiate string based on the results.
All Answers
Can you post the code?
I think though from what you are saying that if you set the value to http://www.mysite.com it might work.
This is my code:
Where pe.URL__c gets the url field on my object.
Thanks
Oded
Hi
Please specify the URL as value="https://www.mysite.com".I think this will help you.
Thanks
I did some quick testing and you do need external links in the form http://www.whatever.com or it treats it as a local page reference. So you have three choices:
1. Make sure that pe.URL__c is in the form http://www.mysite.com.
2. Make sure that pe.URL__c is always in the form www.mysite.com and change your tag to:
<apex:outputLink value="http://{!pe.URL__c}" styleClass="outputLinkStyle" id="productionLink">
3. Use your controller to chek the first 7 characters of pe.URL__c and then return an appropiate string based on the results.
Even when I hard-code the url into the value I get the same behavior
Here I copied and pasted this from a working page I have, you can try it and see if it works for you.
<apex:outputLink value="http://www.google.com" target="_blank">Google</apex:outputLink>
If it does not could you post the whole page code so I can take a look as it would have to be something else in the page causing the behavior.
I want to use the 2nd option you suggested above but when I add http:// to my value like this:
<apex:outputLink value="http://{!pe.URL__c}" styleClass="outputLinkStyle" id="productionLink">{!pe.URL__c}</apex:outputLink>
I get an error.
Am I missing something?
Remove this {!pe.URL__c} there and place any text in that place.
Thanks
Got it to work.
Thank you all
I am glad you got it!!
What was done to make it work? I'm having the same issue...
Appreciate posting what you did to fix this.
In my controller, I extract the ContentUrl from the ContentVersion object. This string is stripped of the https:// portion and set in a String property in the class named:
contentUrl
This is then referenced in my VisualForce page using:
<apex:outputLink target="_blank" title="{!$Label.TandC_Label}" value="https://{! contentUrl}">Read Terms</apex:outputLink>
Does this look correct?
thx.
This is what I finally used:
I included a tool-tip for my users to not include the http:// prefix when they enter the URL in the field.
I suggest checking if it begins with 'http' as opposed to 'http://' in case there are secure connections.