You need to sign in to do that
Don't have an account?
Ines Costa
Calling an Apex method from inside a Visualforce tab <apex:commandButton>
In case someone has the same problem for the future I do believe this is a bug and this is the workaround that I found.
I had a button that performed a search in a standalone visualforce page and it was working without any issues. From the button I could see it working and refreshing the pageblock and calling the function in the debug logs. I then decided to embed it in a visualforce tab panel and it stopped working - page block would refresh but no reference to my function/system debugs in the debug logs.
But I found a workaround that works:
My initial button inside the tab panel/tab:
<apex:commandButton styleClass="search-block-button" value="Search" action="{!SearchAccountProspect}" rerender="TablePanelProspect" status="TableUpdateStatus" />
Workaround - instead of using the action and calling the function there you can use the onclick and call a action function inside Visualforce:
<apex:commandButton styleClass="search-block-button" value="Search Prospects" onclick="SearchProspect(); return false;" rerender="TablePanelProspect" status="TableUpdateStatus" />
<apex:actionFunction name="SearchProspect" action="{!SearchAccountProspect}" rerender="TablePanel" status="TableUpdateStatus"/>
(placed just after the apex:form tab - outside the apex:TabPanel tag.
I had a button that performed a search in a standalone visualforce page and it was working without any issues. From the button I could see it working and refreshing the pageblock and calling the function in the debug logs. I then decided to embed it in a visualforce tab panel and it stopped working - page block would refresh but no reference to my function/system debugs in the debug logs.
But I found a workaround that works:
My initial button inside the tab panel/tab:
<apex:commandButton styleClass="search-block-button" value="Search" action="{!SearchAccountProspect}" rerender="TablePanelProspect" status="TableUpdateStatus" />
Workaround - instead of using the action and calling the function there you can use the onclick and call a action function inside Visualforce:
<apex:commandButton styleClass="search-block-button" value="Search Prospects" onclick="SearchProspect(); return false;" rerender="TablePanelProspect" status="TableUpdateStatus" />
<apex:actionFunction name="SearchProspect" action="{!SearchAccountProspect}" rerender="TablePanel" status="TableUpdateStatus"/>
(placed just after the apex:form tab - outside the apex:TabPanel tag.
I tried 4 solutions:-
1- separate VF page that has a search functionality with a commandButton = everything works fine - search results ok / sorting works / pagination works
2- same exact code but the VF page is now part of of tabpanel with a commandButton to search = search and other functionalities stopped working - no reference in the debug logs to any call to the Apex class/functions
3- same exact code but with the actionFunction calling a javascript to call the search functionality = search and other functionalities stopped working - debug logs show that the search function is called but since it doesnt instatiate the constructor etc the results page doesn't work - no sorting, pagination etc
4- same page as attempt #1 but now in the tabPanel inside an IFRAME - everything works fine - search results ok / sorting works / pagination works - AND goes around the view state limitations since its running separate pages individually