You need to sign in to do that
Don't have an account?
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;
}
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;
}
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
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
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
Thanks