+ Start a Discussion
Cesar Ramirez Vasquez005391619375684564Cesar Ramirez Vasquez005391619375684564 

So i have a method in my controller and i want to called from a buttom in my VF page why this is not working; i dont now i have been trying everything i can and still not working

This is the visualforce code :
Payment Method
    <apex:form >
    <apex:pageMessages />
        <apex:pageBlock >
       
        <p>
        <apex:inputCheckbox value="{!Efectivo}">
         <apex:actionSupport event="onchange" action="{!toogle_a}" rerender="the_outputpanel_0"/> 
        </apex:inputCheckbox> Efectivo <br/>
        <br/>
        <apex:inputText value="{!EfectivoP}" rendered="{!(!Efectivo == false)}"/>
        
        </p>
        <p>
        <apex:inputCheckbox value="{!Tarjeta}">
        <apex:actionSupport event="onchange" action="{!toogle_b}" rerender="the_outputpanel_0"/> 
        </apex:inputCheckbox> Tarjeta
        </p>
       
        <br/>
        <apex:commandButton value="Pagar" >
                       <apex:actionSupport event="onclic"  action="{!Pagar()}"/>
                        
                       </apex:commandButton>
                       <br/>  
                                         
        </apex:pageBlock>
    </apex:form>
</apex:outputPanel>


This is the method i want to call in the controller :

public void Pagar(){
   
   
    if(Efectivo=true && total_str > '0'){
      /*  
        calcular_total();
                     
        current_factura.Descuento__c == ;
        current_factura.Efectivo__c == ;
        current_factura.Estado__c == 'Pagado';
        current_factura.Fecha_y_Hora_de_Factura__c == system.now().addHours(-6);
        current_factura.Forma_de_Pago__c == ;
        current_factura.Porcentaje__c == ;
        current_factura.Subtotal__c == ;
        current_factura.Tarjeta__c == ;
        current_factura.Total__c == ;
        current_factura.Vuelto__c == ;
        
        insert(current_factura):
        */
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Gracias por pagar en Efectivo'));
    }
       
    else if (Tarjeta=true && total_str > '0')
   
    {
    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Gracias por pagar con Targeta'));
    }
   
    else
   
    {
    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Por favor seleccione un metodo de pago'));
   
    }

}

I also have this already declared

public boolean Efectivo {get;set;}
public boolean Tarjeta {get;set;}

public pageReference toogle_a(){

if(Efectivo==false){Tarjeta=true;}
else{Efectivo=true;Tarjeta=false;}

return null;
}
public pageReference toogle_b(){

if(Tarjeta==false){Efectivo=true;}
else{Tarjeta=true;Efectivo=false;}

return null;
}
Best Answer chosen by Cesar Ramirez Vasquez005391619375684564
SFDC_DevloperSFDC_Devloper
Hi,
 
try below code...

<apex:form >
    <apex:pageMessages />
        <apex:pageBlock >
     
        <p>
        <apex:inputCheckbox value="{!Efectivo}">
         <apex:actionSupport event="onchange" action="{!toogle_a}" rerender="the_outputpanel_0"/>
        </apex:inputCheckbox> Efectivo <br/>
        <br/>
        <apex:inputText value="{!EfectivoP}" rendered="{!(!Efectivo == false)}"/>
      
        </p>
        <p>
        <apex:inputCheckbox value="{!Tarjeta}">
        <apex:actionSupport event="onchange" action="{!toogle_b}" rerender="the_outputpanel_0"/>
        </apex:inputCheckbox> Tarjeta
        </p>
     
        <br/>
        <apex:commandButton action="{!Pagar}" value="Pagar" id="theButton"/>
                       <br/>
                                       
        </apex:pageBlock>
    </apex:form>
</apex:outputPanel>



Thanks,
Rockzz

All Answers

SFDC_DevloperSFDC_Devloper
Hi ,

 try below code...

<apex:form >
    <apex:pageMessages />
        <apex:pageBlock >
      
        <p>
        <apex:inputCheckbox value="{!Efectivo}">
         <apex:actionSupport event="onchange" action="{!toogle_a}" rerender="the_outputpanel_0"/>
        </apex:inputCheckbox> Efectivo <br/>
        <br/>
        <apex:inputText value="{!EfectivoP}" rendered="{!(!Efectivo == false)}"/>
       
        </p>
        <p>
        <apex:inputCheckbox value="{!Tarjeta}">
        <apex:actionSupport event="onchange" action="{!toogle_b}" rerender="the_outputpanel_0"/>
        </apex:inputCheckbox> Tarjeta
        </p>
      
        <br/>
        <apex:commandButton value="Pagar" >
                       <apex:actionSupport event="onclick"  action="{!Pagar}"/>
                       
                       </apex:commandButton>
                       <br/> 
                                        
        </apex:pageBlock>
    </apex:form>
</apex:outputPanel>


If this solves your problem, kindly mark it as the best answer.


Thanks,
Rockzz
Cesar Ramirez Vasquez005391619375684564Cesar Ramirez Vasquez005391619375684564
Hi thank you for your reply, but is still bad i dont get any response from the method pagar, what could be wrong ?
SFDC_DevloperSFDC_Devloper
Hi,
 
try below code...

<apex:form >
    <apex:pageMessages />
        <apex:pageBlock >
     
        <p>
        <apex:inputCheckbox value="{!Efectivo}">
         <apex:actionSupport event="onchange" action="{!toogle_a}" rerender="the_outputpanel_0"/>
        </apex:inputCheckbox> Efectivo <br/>
        <br/>
        <apex:inputText value="{!EfectivoP}" rendered="{!(!Efectivo == false)}"/>
      
        </p>
        <p>
        <apex:inputCheckbox value="{!Tarjeta}">
        <apex:actionSupport event="onchange" action="{!toogle_b}" rerender="the_outputpanel_0"/>
        </apex:inputCheckbox> Tarjeta
        </p>
     
        <br/>
        <apex:commandButton action="{!Pagar}" value="Pagar" id="theButton"/>
                       <br/>
                                       
        </apex:pageBlock>
    </apex:form>
</apex:outputPanel>



Thanks,
Rockzz
This was selected as the best answer
Cesar Ramirez Vasquez005391619375684564Cesar Ramirez Vasquez005391619375684564
Hi thanks that worked just fine now i have i doubt when i mark a checkbox and press the button no matter what i do i always recive the same answer this line ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Gracias por pagar en Efectivo')); why is not entering the other clauses of my method.
Thanks
Cesar Ramirez Vasquez005391619375684564Cesar Ramirez Vasquez005391619375684564
Solved thanks for your time !