You need to sign in to do that
Don't have an account?
rsoesemann
apex:actionFunction seems not to rerender
In my component I use actionfunction and rerender
<apex:component controller="MultiSelectBoxController"> ... <apex:panelGrid columns="4"> ... <apex:actionFunction name="moveDown" action="{!moveDown}" reRender="selectedRight"/> ... <apex:selectList id="selectedRight" required="false" value="{!selectedRight}" multiselect="true" size="20" style="width:250px"> <apex:selectOptions value="{!rightOptions}"/> </apex:selectList> <apex:panelGroup layout="block" style="text-align: center; padding:10px;"> Up<br/> <a href="javascript:moveUp();" style="text-decoration:none"> <img src="/s.gif" alt="Move Up" class="upArrowIcon" title="Move Up"/> </a><br/> ... </apex:panelGroup> </apex:panelGrid> </apex:component>
By debuging I am sure that my action method is called correctly
public class MultiSelectBoxController { ... public PageReference moveDown() { // For each selected item right for(Integer r=0; r<selectedRight.size(); r++) { // Iterate over right list for(Integer pos=rightOptions.size()-2; pos >=0; pos--) { // When select item is found if(rightOptions[pos].getValue() == selectedRight[r]) { // Save item above SelectOption tmp = rightOptions[pos+1]; // Switch options with item above rightOptions[pos+1] = rightOptions[pos]; rightOptions[pos] = tmp; } } } return null; } }
Even in Firebug I can see the AJAX POST request coming from the rerender. But on the page nothing happens although the rightOptions have changed...
After an hour of trial and error I hand this over to someone whos smarter than me....
Robert
The rerenender attribute isn't case sensitive is it? Noticed you have a capital in there.
Other than that, at first glance all looks to be correct! Maybe try wrapping the select list in an outputpanel, and rerender the panel instead.
I renamed the attribute, the ids I even wrapped both apex:selectLists in output panels.
But nothing changed anything.
Is there a way to make a rerender visible? I tried to add a Message to the page at the end of the action method but it was not displayed.
Feels like trial and error in the darkness....
Robert
There seems to be something wrong with the whole page. I just added the pagination from the Apex-Lang project whicht itself uses actionSupport and rerender and the same happens,
- Methods are called
- HTTP Ajax Requests happen
- Nothing changes inside the page.
???
Do you see any errors in the debug log in Firebug if you use that? You might need to paste the whole page in or something, though before doing that I'd suggest stripping the page back to a few bare essentials using comments then slowly put things back until it breaks, that way you can narrow down the problem area.
Hy Matt,
can my problem haveb something to do with this bug reported here?
http://frombelvideres4thfloor.blogspot.com/2011/03/bug-with-custom-component-rerender.html
Sound really like my case.. Custom component rerenders part of itself.
But my dev org is on Winter '12?!
&%$§%&!
R.
I move all my custom components code to the page and merged the custom components controller code with my page controller.
Now everything works.
The problem is: I need to habe all this inside a reusable component.
Robert
The main issue with ActionFunctions and custom components is that the ActionFunctions are implemented through javascript, leading to conflicts (i.e. the first component on the page calling the ActionFunctions of the second, since the javscript exists in two places on the page).
The way around this is to prepend some sort of unique identifier to the name attribute, and call the right one. I often accomplish this with an 'id' apex:attribute on the component:
Now, when you use the component on your page, give them unique id's:
...and they will call their own ActionFunctions. If you'd like to use the ActionFunctions from the outer page, just remember to call the right one ('1moveDown()', '2moveDown()', etc.).
Hope this helps, even though it's after the fact by a long while.
-Luke
I was struggling with the same problem and the solution for me was to place the <apex:actionFunction> BELOW the components that need rerendering. So e.g.
When the function is created earlier on, it doesn't seem to have the correct reference to the element that needs to be rerendered.