You need to sign in to do that
Don't have an account?
dmcheng
Update viewstate with actionFunction rerender?
Hello. I need to refresh viewstate on a page to show the latest query results but it's not working.
I have an inputText on the page for the user to enter a filter value. When that happens, I re-query records and I rerender the pageBlockTable that displays the records.
I'm using onChange on the inputText and an actionFunction with Javascript.
When I enter a value in the input field, the page is rerendered. However, the viewstate is not changing so the pageBlockTable still shows the original set of records.
Here are the code snippets.
VF page:
Controller:
I have an inputText on the page for the user to enter a filter value. When that happens, I re-query records and I rerender the pageBlockTable that displays the records.
I'm using onChange on the inputText and an actionFunction with Javascript.
When I enter a value in the input field, the page is rerendered. However, the viewstate is not changing so the pageBlockTable still shows the original set of records.
Here are the code snippets.
VF page:
<apex:page> <script> CCx.thispage = {}; CCx.thispage.filterByName = function(evt) { var name = evt.value; // log a google analytics event // submit via actionfunction doFilterByName(name); }; </script> <apex:form id="form"> <div class="ccx-list-header"> <div class="ccx-advocate-buttons" id="bulkListActions"> <apex:inputText value="{!searchName}" onChange="CCx.thispage.filterByName(this); return false;" html-placeholder="Search for advocate" /> </div> </div> <apex:actionFunction name="doFilterByName" action="{!filterByName}" rerender="bulkListActions, advocateListTable" /> <apex:pageBlock id="pageblock"> <apex:pageBlockSection columns="1" collapsible="false" id="section"> <apex:pageBlockTable id="advocateListTable" value="{!advocates}" var="advocateListItem"> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock>
Controller:
public class MyController { public String currentDeskId; public String searchName { get; set; } public List<CCx_AdvocateServices.onboardingAdvocateDecorator> advocates { get; set; } public void filterByName() { system.debug('*** searchName: ' + searchName); if (string.isBlank(searchName)) return; advocates = CCx_AdvocateSelector.selectAdvocateDecoratorForDeskAndName(currentDeskId, searchName); system.debug('*** advocates: ' + advocates); searchName = null; } // Constructor // etc }
-
Rerender the pageblock instead of the pageblocktable.
-
Do your debug statements produce the correct results when you type in the inputtext box?
Visit Forcetree.com for code samples and tips.I am using a PageBlockTable to show a set of OpportunityLineItems. Some of the columns depend on some info about the products. My controller has a map of that product info, which is referenced in the VF page, using pricebookentryid as key.
When the user uses an autocomplete to set a new pricebookentryid, I need to add the corresponding product info to the cache.
I use an actionfunction to get the controller to add the product info to the cache. Using the developer console, I can see that a new entry is made in the caching map.
However, the viewstate retains the old value of the caching map, so the columns that reference product info get a cache miss, and the page throws an error.