Skip to main content
replaced http://salesforce.stackexchange.com/ with https://salesforce.stackexchange.com/
Source Link

OK So after research i cant redirect new page in new window from server side , so used in other method : first of all i make validation in java script and if it return true the action in the controller running ,

JavaScript

 function PdfReport(id,type)
         {
         var selectCheckbox = false;
         var tab =  document.getElementById(id).getElementsByTagName("table")[0];
               for(j = 0 ; j < tab.rows.length ; j++) 
                { 
                   if (tab.rows[j].cells[0].querySelector("input[type='checkbox']").checked == true )
                   { 
                        selectCheckbox = true;  
                   }  
                }
        if(selectCheckbox  == false)
           {
                alert('You must select at least one technology in order to export ');
                return false;
            } 
            return true;
         }
     

Apex:

   <apex:commandLink rendered="{!visible}" styleClass="exportTo" value="export result to Pdf" id="exportPdf"  target="_blank"  action="{!Export}" onclick="return PdfReport('mainPage:mainForm:pageBlock:sectionSearch:searcResult_:result:blockdetail','Simple');"  />

the idea from : How to add a confirm dialog to a command button?How to add a confirm dialog to a command button?

OK So after research i cant redirect new page in new window from server side , so used in other method : first of all i make validation in java script and if it return true the action in the controller running ,

JavaScript

 function PdfReport(id,type)
         {
         var selectCheckbox = false;
         var tab =  document.getElementById(id).getElementsByTagName("table")[0];
               for(j = 0 ; j < tab.rows.length ; j++) 
                { 
                   if (tab.rows[j].cells[0].querySelector("input[type='checkbox']").checked == true )
                   { 
                        selectCheckbox = true;  
                   }  
                }
        if(selectCheckbox  == false)
           {
                alert('You must select at least one technology in order to export ');
                return false;
            } 
            return true;
         }
     

Apex:

   <apex:commandLink rendered="{!visible}" styleClass="exportTo" value="export result to Pdf" id="exportPdf"  target="_blank"  action="{!Export}" onclick="return PdfReport('mainPage:mainForm:pageBlock:sectionSearch:searcResult_:result:blockdetail','Simple');"  />

the idea from : How to add a confirm dialog to a command button?

OK So after research i cant redirect new page in new window from server side , so used in other method : first of all i make validation in java script and if it return true the action in the controller running ,

JavaScript

 function PdfReport(id,type)
         {
         var selectCheckbox = false;
         var tab =  document.getElementById(id).getElementsByTagName("table")[0];
               for(j = 0 ; j < tab.rows.length ; j++) 
                { 
                   if (tab.rows[j].cells[0].querySelector("input[type='checkbox']").checked == true )
                   { 
                        selectCheckbox = true;  
                   }  
                }
        if(selectCheckbox  == false)
           {
                alert('You must select at least one technology in order to export ');
                return false;
            } 
            return true;
         }
     

Apex:

   <apex:commandLink rendered="{!visible}" styleClass="exportTo" value="export result to Pdf" id="exportPdf"  target="_blank"  action="{!Export}" onclick="return PdfReport('mainPage:mainForm:pageBlock:sectionSearch:searcResult_:result:blockdetail','Simple');"  />

the idea from : How to add a confirm dialog to a command button?

Source Link
Racheli
  • 83
  • 3
  • 10

OK So after research i cant redirect new page in new window from server side , so used in other method : first of all i make validation in java script and if it return true the action in the controller running ,

JavaScript

 function PdfReport(id,type)
         {
         var selectCheckbox = false;
         var tab =  document.getElementById(id).getElementsByTagName("table")[0];
               for(j = 0 ; j < tab.rows.length ; j++) 
                { 
                   if (tab.rows[j].cells[0].querySelector("input[type='checkbox']").checked == true )
                   { 
                        selectCheckbox = true;  
                   }  
                }
        if(selectCheckbox  == false)
           {
                alert('You must select at least one technology in order to export ');
                return false;
            } 
            return true;
         }
     

Apex:

   <apex:commandLink rendered="{!visible}" styleClass="exportTo" value="export result to Pdf" id="exportPdf"  target="_blank"  action="{!Export}" onclick="return PdfReport('mainPage:mainForm:pageBlock:sectionSearch:searcResult_:result:blockdetail','Simple');"  />

the idea from : How to add a confirm dialog to a command button?