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
chris_centrachris_centra 

VF as Word doc - but also reloads the browser...

Hello.  I have VF page which allows the User to select some records.  Then the User presses a button - which calls a controller method that returns a PageReference to a VF page with the contentType attribute set to a Word doc type.  Works perfectly - except that in addition to launching Word it also tries to load the page in the browser...so the browser is blank (Word doc looks fine).  What do i have to do to make the browser stay on the same page?  (i thought setting the contentType would have prevented the browser change, but apparently i'm mistaken there.

 

thanks

chris

Geetha ReddyGeetha Reddy

hi chris,

try cache = true.

<apex:page cache = true>


chris_centrachris_centra

already have that.  my page node is:

 

apex:page showHeader="False"
           controller="ActivityHistoryNotesController"
             language="en" cache="true"
              contentType="application/msword; charset=Windows-1252" 

s_s.ax1351s_s.ax1351

I guess adding "pageRef.setRedirect(false);"should do it right..

 

Like:

PageReference pageRef = new PageReference('/apex/MyVFPage');
pageRef.setRedirect(false);
return pageRef;

 

Sumit

chris_centrachris_centra

Hello.

 

Thanks for your reply.  I had tried that as well, but the results are the same. When the button is clicked, the URL changes to the new page (https://c.cs11.visual.force.com/apex/ActivityHistoryList?id=001A000000AWO6i) - the browser renders (blank) and the Word doc opens...

 

Any ideas?

 

Thanks

Chris

chris_centrachris_centra

Looks like i figured it out, although i'm not entirely sure what it means...

 

In my original setup, i was on one VF page...the button called a separate VF page (different controller, etc). 

 

i decided to consolidate all of the logic into one VF page and one controller.  Now it works as expected.  I'm guessing if in my original setup - if i had the same controller but two pages, it would have worked properly...

 

Thanks again for your responses.

Chris

s_s.ax1351s_s.ax1351

I am sorry, I presumed that you have 2 pages with 1 controller..the solution which I suggested will 100% work in that situation..

 

Also, I really don't think that you can control this if you use different controller.

 

Thanks

Sumit