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
lvivaninlvivanin 

action Attribute on <apex: page> tag

I am doing simple test on action with in the <apex: page>


I have a word file uploaded under the Static Resource named customerhelp

 

 

 

<apex:page action="{!URLFOR($Resource.customerhelp)}">
<p>
Hello world!
</p>
<apex:form >
<apex:commandButton title="Sample Button" value="Sample Button"/>
</apex:form>
</apex:page>

 

1. When I load this page a popop window is displayed to dowonload/open the file within the Static Resource.
2. After that action is done by clicking OK/Cancel page remains blank.

If I try to do refresh/backward it just repeats the steps 1 & 2 . Not only it doesn't show the sample button and the 'Hello  world' text, but also does not allow to navigate to the other pages...

 

 

How can I download/open or Cancel at first (only one time ) and then see the rest of the content on the page?

 

Thanks in advance.

 

jwetzlerjwetzler

As documented, the action attribute is meant for redirection (or conditional redirection) on load of the page.

 

You should just use javascript to open a pop up with your page.  Put it in between <script> tags right at the top of the page and it will run when the page is loaded.

ThomasTTThomasTT
And, try to use showModalPopup() to open a window with the static resource. It suspends the execution of JavaScript on the main page untill the popup window is closed. Once the JavaScript is resumed, remaining page on the main page will be rendered.
ThomasTT
Pragna BharadvaPragna Bharadva
There is an updated content for this, please check out:
https://www.consilat.com/blogs-why-not-to-use-action-attribute-in-vf-tag/