-2

how to disable an apex commandbutton after first click . can someone help me out?

page : <apex:pageBlockSection  rendered="{!enableSpehere}"\> 

controller :

boolean enableSpehere {get;set;}

inside constructor :

enableSpehere =false

then there is a method:

  public void enableSphere()
    {
         enableSpehere=true;
    }
0

1 Answer 1

1

So I'm a little unclear based on your writeup but I'll take a guess as to what you are trying to do...

  • Clicking a commandButton calls enableSpehere()
  • After that click, you want that button disabled.
  • When the spehere is enabled, the button should always be disabled

If the above is all true, then in your controller, you can use your public boolean to disable the button.

public Boolean spehereEnabled = false;    

public void enableSpehere()
  {
    spehereEnabled = true;
  }

Then in your markup for the commandButton...

<apex:commandButton disabled="{!spehereEnabled}" value="{!enableSpehere}" value="Enable Spehere" />

Note that you had both your method named enableSpehere and also your Boolean property. I changed the Boolean property name for you to spehereEnabled. You'd just change the pageBlockSection rendered binding to...

<apex:pageBlockSection rendered="{!sphereEnabled}"\> 
2
  • Thanks a lot..But currently i'm facing another problem..i have implemented prev<< next>> buttons also..which will show me resultset part by part along with the sphere..i've used SOQL Offset-limit logic.....but the problem is when clicking prev or next button, pageblock containing the sphere is getting disappeared..what i want is that..while clicking prev or next button it will call the enablesphere method also, along with its own action function.. public void previous() {index = index - blockSize;enableSphere();} is not working..is there any way to call 2 functions from 1 button? please help Commented Jul 24, 2014 at 14:37
  • Since that is a separate question/issue, I'd log that as a separate post. Commented Jul 24, 2014 at 16:10

Not the answer you're looking for? Browse other questions tagged .