function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Koen (BvD)Koen (BvD) 

Button bo link to a page in a visual force page integrated in an existing page layout

I am trying to mimick some behavior I had with an s-control with visual force. If you place a custom button that links to an s-control and then specify that you want the side bar for example, you could link to a page without header and side bar refershing.

 

So I made a visual force page that I added to my account page layout and there I place a link or button. I tried with the commandlink and commandbutton that reference an action on my controller and the action returns a PageReference to a second visual force page. If I specify nothing then the page goes into the iframe in the account detail, not the idea, so I would need to add target=_top and force a client side redirect. However then the entire page is refreshed which makes it seem much slower than the original behavior with the s-control where only the account detail itself was refreshed. How can I obtain the same behavoir as the s-control linked to a custom button?

Best Answer chosen by Admin (Salesforce Developers) 
tankgirlrstankgirlrs

Not sure if you are still having any touble with this, but i found a good workaround that works since i had the same issue... i used a bit of jQuery and it works like a dream....

 

keep your class that gets the URL, here is my class:

 

public string viewAll;
public string getViewAll(){
string t = getCaseId();
PageReference pageRef = new PageReference('/apex/TicketHistory?id=' + t);
return pageRef.getUrl();
}

Then on the page you just need to add some jQuery:

 

<apex:includeScript value="{!URLFOR($Resource.ActivityHistory, '/jquery1_4.js')}"/>

<script type="text/JavaScript" language="JavaScript">
//pop up the new window...
function popWindow(s){
window.open(s,'_top');
}
</script>

 Then in the apex:outputlink you add a onclick event that calls the function popWindow and put your class in the () and for the value you need it to equal something or you will get an error, so i use value="javascript:void(0);"

 

<apex:outputLink value="javascript&colon;void(0);" onclick="popWindow('{!viewAll}');" id="createbutton" target="_top">View All</apex:outputLink>

 

And it keeps the headers and side bar when it loads.

 

 

 

 

 

 

 

Message Edited by tankgirlrs on 02-25-2010 11:14 AM
Message Edited by tankgirlrs on 02-25-2010 11:15 AM

All Answers

Koen (BvD)Koen (BvD)

It's even worse than I thought. I thought the referesh of the other parts of the page would be the problem, but I can't get this even to work correctly with or without page refresh. There must be something fundamental I am missing. I have a visual force page that I place on the account detail page. There I place a commandlink. The action does nothing, it just sends back a PageReference with parameters. I put the redirect to true on the pagereference, I set the target to _top, but the resulting link contains a parameter inline=1 which seems  to correspond to a parameter meant to generate only part of the page as top menu and left sidebars are missing while removing that parameter brings up the page correctly. Where is this inline parameter comming from? How can I avoid it? Or better even how can I exploit it so that indeed only the necessary part of the current page is refreshed by the result just like a cutom button does?

 

Koen.

Koen (BvD)Koen (BvD)

One more workaround added: I used apex outputlink, generated the url with page.getUrl () and removed manually the inline=1 by a string replace - urk - and added target=_top. The apparent refresh of the whole page seems to be related to the fact that I was in development mode, switching from a non-editable page to an editable page. If I remove the development mode option the page doesn't go blank when following the link.

If someone has a cleaner solution, please let me know, for now it seems that after some frustrating hours of searching I can continue working again.

tankgirlrstankgirlrs

Not sure if you are still having any touble with this, but i found a good workaround that works since i had the same issue... i used a bit of jQuery and it works like a dream....

 

keep your class that gets the URL, here is my class:

 

public string viewAll;
public string getViewAll(){
string t = getCaseId();
PageReference pageRef = new PageReference('/apex/TicketHistory?id=' + t);
return pageRef.getUrl();
}

Then on the page you just need to add some jQuery:

 

<apex:includeScript value="{!URLFOR($Resource.ActivityHistory, '/jquery1_4.js')}"/>

<script type="text/JavaScript" language="JavaScript">
//pop up the new window...
function popWindow(s){
window.open(s,'_top');
}
</script>

 Then in the apex:outputlink you add a onclick event that calls the function popWindow and put your class in the () and for the value you need it to equal something or you will get an error, so i use value="javascript:void(0);"

 

<apex:outputLink value="javascript&colon;void(0);" onclick="popWindow('{!viewAll}');" id="createbutton" target="_top">View All</apex:outputLink>

 

And it keeps the headers and side bar when it loads.

 

 

 

 

 

 

 

Message Edited by tankgirlrs on 02-25-2010 11:14 AM
Message Edited by tankgirlrs on 02-25-2010 11:15 AM
This was selected as the best answer