You need to sign in to do that
Don't have an account?
stunaite
Rerender colacteral effect!
Hi There!
I have a page wich loads a huge image. I want to enable a commandbutton after image is loaded.
That's my page:
<apex:page action="{!Initio}" Controller="async"> <apex:form > <apex:actionFunction name="enableButton" action="{!enableButton}" rerender="Button1"/> <script> function imgLoaded(){ enableButton(); } </script> <apex:commandButton id="Button1" value="myButton" action="{!doNothing}" disabled="{!buttonDisabled}"/> <apex:repeat value="{!myIntegerSet}" var="myis"> <apex:outputtext value="{!myis}"/> </apex:repeat> <img src="http://www.free-pictures-photos.com/vegetable/radish-5di2.jpg" onload="imgLoaded()"/> </apex:form> </apex:page>
And my controller:
public with sharing class async { public List<Integer> myIntegerSet; public Boolean buttonDisabled {get;set;} public void Initio(){ buttonDisabled = true; myIntegerSet = new List<Integer>(); myIntegerSet.add(1); myIntegerSet.add(2); myIntegerSet.add(3); } public void enableButton(){ buttonDisabled = false; } public List<Integer> getMyIntegerSet(){ System.debug('It was called'); return myIntegerSet; } public void doNothing(){} }
So, when image is loaded, javascript function imgLoaded is called and it calls method enableButton on controller.
A rerender of commandButton is done.
I can't explain why but the method getMyIntengerLst() is called twice as the result of ajax call. I checked that using system log.
System.debug('It was called');
is called once when page is loading and is called twice as the result of Ajax call.
Someone can help? Yhanks in Advance
This is published behaviour of Visualforce - from page 203 of the Developer's Guide :
--- snip ---
--- snip ---
All Answers
This is published behaviour of Visualforce - from page 203 of the Developer's Guide :
--- snip ---
--- snip ---
It is very boring.
Thanks and Regards.