You need to sign in to do that
Don't have an account?
Qin Lu
Drill down from a visual force page to a standard detail page doesn't work
I have a visual force page for a custom object. I have build a custom controller for this custom object, then embed this page in Contact Detail page. I put a drill down for a field in the visual force page to drill down to the detail page of this custom object which is a standard page. The custom detail page is actually rendered inside the iFrame, but I want it to go to the detail page.
I looked it up on google, and found this examplehttp://stackoverflow.com/questions/11552514/visualforce-page-embedded-in-a-detail-page-that-needs-to-redirect-to-other-page.
I tried, but it doesn't work for me. Here is my controller class, I have omitted other logics.
public with sharing Class FinAccntFilterByTypeController {
private ApexPages.StandardController controller {get; set;}
public String redirectUrl {get; set;}
public FinAccntFilterByTypeController( ApexPages.StandardController controller){
//initialize the stanrdard controller
this.controller = controller;
}
public PageReference doStuffAndRedirect() {
redirectUrl = controller.view().getUrl();
System.debug ('URL '+redirectUrl);
return null;
}
Here is my page, please ignore the variables, basically, I have repeat loop through list and fields, I have a outputLink with onClick to call doStuffAndRedirect, then I have the javascrip part to add
window.top.location.href to redirect. After I added the javascript part, whenever I go to Contact page, without click on outputLink field, it automatically navigates to the redirectUrl. Is there anything wrong with my code?
<apex:page standardController="Contact" id="fapage" extensions="FinAccntFilterByTypeController">
<apex:repeat value="{!availableCategories}" var="category">
<apex:pageBlock title="{!category}" >
<apex:pageBlockTable value="{!finAcctListByCategory[category]}" var="fa" rendered="{!NOT(ISNULL(finAcctListByCategory[category]))}" title="category">
<apex:repeat value="{!fieldListByCategory[category]}" var="field">
<apex:column headerValue="{!fieldLabelMapByCategory[category][field]}" value="{!fa[field]}" rendered="{!field!='Account_Number__c'}"></apex:column>
<apex:column headerValue="{!fieldLabelMapByCategory[category][field]}" rendered="{!(field='Account_Number__c')}">
<apex:outputLink onClick="doStuffAndRedirect">{!fa[field]}
<script type="text/javascript">
window.top.location.href = '{!redirectUrl}';
</script>
</apex:outputLink>
</apex:column>
</apex:repeat>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:repeat>
</apex:page>
I looked it up on google, and found this examplehttp://stackoverflow.com/questions/11552514/visualforce-page-embedded-in-a-detail-page-that-needs-to-redirect-to-other-page.
I tried, but it doesn't work for me. Here is my controller class, I have omitted other logics.
public with sharing Class FinAccntFilterByTypeController {
private ApexPages.StandardController controller {get; set;}
public String redirectUrl {get; set;}
public FinAccntFilterByTypeController( ApexPages.StandardController controller){
//initialize the stanrdard controller
this.controller = controller;
}
public PageReference doStuffAndRedirect() {
redirectUrl = controller.view().getUrl();
System.debug ('URL '+redirectUrl);
return null;
}
Here is my page, please ignore the variables, basically, I have repeat loop through list and fields, I have a outputLink with onClick to call doStuffAndRedirect, then I have the javascrip part to add
window.top.location.href to redirect. After I added the javascript part, whenever I go to Contact page, without click on outputLink field, it automatically navigates to the redirectUrl. Is there anything wrong with my code?
<apex:page standardController="Contact" id="fapage" extensions="FinAccntFilterByTypeController">
<apex:repeat value="{!availableCategories}" var="category">
<apex:pageBlock title="{!category}" >
<apex:pageBlockTable value="{!finAcctListByCategory[category]}" var="fa" rendered="{!NOT(ISNULL(finAcctListByCategory[category]))}" title="category">
<apex:repeat value="{!fieldListByCategory[category]}" var="field">
<apex:column headerValue="{!fieldLabelMapByCategory[category][field]}" value="{!fa[field]}" rendered="{!field!='Account_Number__c'}"></apex:column>
<apex:column headerValue="{!fieldLabelMapByCategory[category][field]}" rendered="{!(field='Account_Number__c')}">
<apex:outputLink onClick="doStuffAndRedirect">{!fa[field]}
<script type="text/javascript">
window.top.location.href = '{!redirectUrl}';
</script>
</apex:outputLink>
</apex:column>
</apex:repeat>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:repeat>
</apex:page>
When below code executes, it redirects the page. Instead of writing javascript in script tag, you can call that statement in onclick of outputlink.
<apex:outputLink onClick="window.top.location.href = '{!redirectUrl}';">{!fa[field]}
</apex:outputLink>