function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Cindy NormanCindy Norman 

Forcing response from commandButton in a popup

I have a popup...pretty simple use of a form, a couple of outputPanels and a couple of commandButtons (shown below
...probably don't need to explain the little bits, or do i?).
I'm wondering if i can *force* the user to click one of the buttons before any more input is taken on the screen...
ie in effect "disabling" everything else on the screen until they choose 1 button or the other.
Any ideas?
Thank You!

<apex:form >
  <apex:outputPanel id="ShowPopup">
        <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopup2Buttons}"/>
        <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopup2Buttons}">
            <apex:outputLabel escape="false" value="{!messageInPopup}"/>
            <br/><br/><br/>
            <apex:commandButton style="align:center;" value="{!buttonLabel1}" action="{!closePopup}" rerender="ShowPopup">
                <apex:param name="popupButtonChosen" value="1" assignTo="{!popupButtonChosen}" />
            </apex:commandButton>
            <apex:commandButton value="{!buttonLabel2}" style="align:center;" action="{!closePopup}" rerender="ShowPopup">
                <apex:param name="popupButtonChosen" value="2" assignTo="{!popupButtonChosen}" />
            </apex:commandButton>
        </apex:outputPanel>
  </apex:outputPanel>
</apex:form>
Anupam RastogiAnupam Rastogi
Hi Cindy,

It depends on the VF component that you wish to disable. Example, You can use the 'disabled' attribute to disable the Command Buttons using a condition. 

An example that I tested and works for the command button - 
<apex:page standardController="Lead">
    <apex:form id="form">
        <apex:variable var="eButton" value="1" />
        <apex:pageBlock id="block1">
            <apex:commandButton action="{! create }" value="New Lead" disabled="{! IF(eButton = '1', true, false) }" />
        </apex:pageBlock>
    </apex:form>
</apex:page
This code disables the New Lead button when value of variable eButton = 1.

Thanks
AR

If you find the reply useful that solves your problem then please mark it as best answer.
 
Cindy NormanCindy Norman
Hi AR!
Thank you!
I was trying to ask if there was a way for a commandButton to "take over" and all other input objects on the page would be disabled until the button was satisfied/clicked/... Or is there a form or an outputPanel or a ? to put the commandButton in to that would completely take over.
Its a common concept...you popup a window and you want the user to answer the question or acknowledge the information before *anything* else happens..that's what i'm after.
Cindy