You need to sign in to do that
Don't have an account?

Buton not Rerendering correctly
Hello,
I have a VF page with a button that should be hidden while the Id of its parent record is null (meaning until the Save buton higher up in the page is clicked and a save method is executed which will persist the object in the DB. At that point I want to have the button farther down (which creates instances of child records to appear again so that releated items can be added. See the code below:
This is at the top of the page where a save buton is placed to execute the saving of the Sales Order (parent object)
<apex:pageblockButtons > <apex:commandButton action="{!saveSO}" value="Save Changes" reRender="out,btnAddSOI" status="saveStatus"> </apex:commandButton>
then at the bottom of the page in another pageblock I have the following:
<apex:pageBlockButtons > <apex:outputPanel id="btnAddSOI" rendered="{!SOsaved}"> <apex:commandButton action="{!AddSOI}" value="Add New Item" rerender="tablePnl" /> </apex:outputPanel> </apex:pageBlockButtons>
This is the button that should dissapear if the parent record has not been saved yet and should magically reapear once the button has been saved. Currently on page load the visibility reflect correctly(e.g. if editing an existing record via the VF page then the button is visible, else if its a new record via the same VF page then the button is hidden) The problem lies in that the button doesn't REAPPEAR once the record is saved. Below is the controller method in use (SOsaved):
public Boolean SOsaved { get { boolean bool; bool= so.Id <> null ? True : False; System.debug('SO saved ' + bool + ' - ' + so.Id); return bool; } }
Can someone please assist???
Hello,
I am posting my final code in order for it to be of use to anyone experiencing the same issue. I have solved this some time ago but did not get to the solution without much trial and error. I cannot recall the exact solution I found but I will paste the relevant code that is working so anyone can reference it. See below:
The button in question:
The button that should fire the rerender:
Keep in mind that I have added other stuff to the page so the same code that was before may now be a litle different, but the basic functionality in question is the same.
All Answers
Actually, you can't reRender more than one component for one action.
It should work fine if you write reRender="btnAddSOI".
I'm sure you can rerender more than one component.
Just have to change
to
(You have to rerender parent component in order to "rendered" tag to be evaluated again)
I've made the changes but NO LUCK! I checked a debug statement to see if the {!SOsaved} method is returning true or false when it should and it does. Also the button that fires off the saveSO method (at the top of the page, is working correctly as well since when it rerenders the "out" panel I have the name field updated to the actual record name:
<apex:commandButton action="{!saveSO}" value="Save Changes" reRender="out,btnAddSOI" status="saveStatus">
To reply to SeAlVa, I have another component that fires off a method and rerenders several fields at the same time so I think that the rerendering can happen for more than one component from one method execution.
So I am unsure if it's the order of the rerendering or some missing tag but it still not rerendering the button.
If you have required fields, they might not let you rerender. Try (as a temporal way to check it) immediate=true.
If that is your problem, you may have to use <apex:actionRegion or the immediate="true" to get what you want.
Thank you for your reply, I have tried adding the immediate = "true" parameter with no luck, we do not have any required fields on the object yet so that should not be the issue.
I am attaching entire VF code minus some middle static input fields that do not do anything special, also adding in the controller code in the chance that I may be writting something wrong and you can identify it.
And here goes the controller code:
Hope this gives a more complete picture of the issue
Try to transfer Id from <apex:commandButton> to <apex:pageBlock>:
Try replacing
with
Just for future coding,
you have to take into account that when you rerender a component, you rerender its content. what means that if there is a tag rendered="{!xxx}" it will not be recalculated. You will have to rerender its parent to do so.
Hello,
I am posting my final code in order for it to be of use to anyone experiencing the same issue. I have solved this some time ago but did not get to the solution without much trial and error. I cannot recall the exact solution I found but I will paste the relevant code that is working so anyone can reference it. See below:
The button in question:
The button that should fire the rerender:
Keep in mind that I have added other stuff to the page so the same code that was before may now be a litle different, but the basic functionality in question is the same.
Hello,
I am posting my final code in order for it to be of use to anyone experiencing the same issue. I have solved this some time ago but did not get to the solution without much trial and error. I cannot recall the exact solution I found but I will paste the relevant code that is working so anyone can reference it. See below:
The button in question:
The button that should fire the rerender:
Keep in mind that I have added other stuff to the page so the same code that was before may now be a litle different, but the basic functionality in question is the same.