You need to sign in to do that
Don't have an account?
OutputPanel render FIRST and ONLY when button is pressed
How could you load up an output panel that doesnt bind at all UNTIL a button is pushed?
For example, I have the following
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Go" action="{!invokeService}" status="myStatus" rerender="myOutput" />
</apex:pageBlockButtons>
<apex:outputPanel id="myOutput">
<apex:actionStatus id="myStatus">
<apex:facet name="start">
Working...
</apex:facet>
<apex:facet name="stop">
<c:myComponent />
</apex:facet>
</apex:actionStatus>
</apex:outputPanel>
The component "myComponent" contains a datatable. This datatable appears to render the component on load, and bind the datatable on load.
But I dont want this behavior. I want it to first render ONLY when the button is pressed.
Any ideas?
I started trying to do a flag, where by [ if (flase) { dont bind, set true} ] so that on second click it would bind.
The tag was changed to
<apex:outputPanel rendered="{!ButtonClicked}" id="myOutput">
and the controller looks something like this
public class MyController {
Boolean clicked = false;
public MyController() {
clicked = false;
}
public PageReference invokeService() {
clicked = true;
return null;
}
public Boolean ButtonClicked(){
return clicked;
}
}
However when ever I click on the button I get the following error:
Attempt to de-reference a null object
An unexpected error has occurred. Your development organization has been notified.
I do not know if this will solve your problem, but I noticed an error in your code.
You have: <apex:outputPanel rendered="{!ButtonClicked}">.
Yet, your method is public Boolean ButtonClicked().
The return type of your method is a boolean, which means that it is not an action. Therefore, it is a property. To access it, your method name must be public Boolean getButtonClicked().
ApexGuy.
Modified code accordingly - this is not the problem.