1

I have two command buttons (say A , B). I want when A is clicked then only B would be shown. When B clicked then it would be hidden again. Is this achievable ? Please find my page below.

Page snippet:

 <apex:panelGrid columns="3" >
        <apex:inputFile value="{!csvFileBody}"  />

        <apex:actionRegion >  
             <apex:commandButton value="Check updates" action="{!readcsvFile}" />  
        </apex:actionRegion>
        <apex:pagemessages id="errmsg"/>
        <apex:commandButton value="Reload file" action="{!reset}" onclick="window.location.reload();" rendered="{!sObjectList.size!=0}" />                

 </apex:panelGrid>

2 Answers 2

2

Update Vf as below

<apex:commandButton value="Check updates" action="{!readcsvFile}" />
<apex:commandButton value="Reload file" action="{!reset}" onclick="window.location.reload();" rendered="{!AND(sObjectList.size!=0,showReload)}" /> 

Take a boolean in your controller as below

public class mycontroller{
    public boolen showReload{get;set;}

    public mycontroller(){
         showReload=false;
    }
     public pagereference readcsvFile(){
        showReload=true;
        return null;
     }         
}
4
  • I am sorry. What exactly I need is check updates command button is always to be shown. When a file is chosen here as Inputfile then Reload Page button will instantly appear. One click on "Choose file" would make "Reload page" button appear. Can you please let me know that. Commented Jan 8, 2015 at 7:19
  • I have made the changes above. Let me know if this what is required @SFDC_GEEK
    – snehakem
    Commented Jan 8, 2015 at 7:53
  • It is throwing this error: Incorrect parameter type for function 'and()'. Expected Boolean, received Text Commented Jan 8, 2015 at 8:40
  • 1
    Check my code again. You are supposed to assign a boolean value, showReload=true; and not the text value showReload='true'; Please make sure of it
    – snehakem
    Commented Jan 8, 2015 at 9:17
1

Hi I got the requirement achieved by using script in apex page. Please have a look. Also snehakem's answer was right.

Apex page:

<script>


    function show()
    {
      document.getElementById("{!$Component.thePage.theForm.theid.cancelButton}").style.display='inline-block';


    }

     function showRev()
    {

      document.getElementById("{!$Component.thePage.theForm.theid.theRevert}").style.display='inline-block';

    }
    </script> 

   Upload Incidents ready to Publish 

</apex:outputPanel>


<apex:form id="theForm" >  <!-- csv reader demo -->

    <apex:pageBlock id="theid">
          <apex:panelGrid columns="3" id="theGrid">
              <apex:inputFile value="{!csvFileBody}" onchange="show();"  />

              <apex:actionRegion id="Action">  
                    <apex:commandButton value="Check updates" onclick="showRev();" action="{!readcsvFile}" id="Updates" />                               

                     <apex:commandButton value="Cancel" onClick="window.location.reload();" action="{!reset}" id="cancelbutton" style="display:none"/>
                     <apex:commandButton value="Revert changes" action="{!enableCloseDateInput}" id="theRevert" rendered="{!RevertList.size!=0}" />
              </apex:actionRegion>
              <apex:pagemessages id="errmsg"/>


        </apex:panelGrid>




    </apex:pageBlock>


    <apex:pageBlock >
      <apex:pagemessages />
       <apex:pageblocktable value="{!sObjectList}" var="rec" rendered="{!sObjectList!= null}">
          <apex:column value="{!rec.name}" />
          <apex:column value="{!rec.Rep_abv__c}" />
          <apex:column value="{!rec.OwnerId}" />
          <apex:column value="{!rec.Incident_Loaded_Date_abv__c}" />
          <apex:column value="{!rec.Report_Publish_Date_abv__c}" />
          <apex:column value="{!rec.No_Of_Transactions_abv__c}" />
          <apex:column value="{!rec.Status_abv__c}" />



    </apex:pageblocktable>

 </apex:pageBlock>

You must log in to answer this question.

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