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
ParnisariPabloParnisariPablo 

Custom Controller Action Method works only first run !

 

I built a VF with a pick-up list and a button with an action that call a method "generar" on a Custom Controller Class.
When the page starts only this are showed. Then the user select an option (today, week, yesterday, etc) and click the button wich call the methods an 
populates a List<LineaVencida> where LineaVencida is a inner class (inner to the controller) built with OpportunityLineItem (customized) and a boolean 
(called "Seleccion") that is represented in VF with a ckeck buttom.
After the first click the debug log shows that first of all the setters / getters are runned and after this the method "Generar" is successfully runned an 
finally the List<LineaVencida> is populated and showed thru a "pageBlockTable" component.
After that if I select another option in the filter pick list (i.e: "Yesterday") and click the button that call the "Generar" method the page is just refresh 
whit the same data that had been loaded the first (former) time.
When I check the debug log I can see that the setters / getters are runned (much more in this ocassion because there were muche more data in the postback) 
and after that the method "GENERAR" wasn't  never called  !!!! 
SalesForce not raise any error, neither error is reported in the debug log.
Please I need any haelp or clue.
Thanks in advance !!
I built a VF with a pick-up list and a button with an action that call a method "generar" on a Custom Controller Class.When the page starts only this are showed. Then the user select an option (today, week, yesterday, etc) and click the button wich call the methods an 
populates a List<LineaVencida> where LineaVencida is a inner class (inner to the controller) built with OpportunityLineItem (customized) and a boolean 
(called "Seleccion") that is represented in VF with a ckeck buttom.After the first click the debug log shows that first of all the setters / getters are runned and after this the method "Generar" is successfully runned an 
finally the List<LineaVencida> is populated and showed thru a "pageBlockTable" component.After that if I select another option in the filter pick list (i.e: "Yesterday") and click the button that call the "Generar" method the page is just refresh 
whit the same data that had been loaded the first (former) time.When I check the debug log I can see that the setters / getters are runned (much more in this ocassion because there were muche more data in the postback) 
and after that the method "GENERAR" wasn't  never called  !!!! SalesForce not raise any error, neither error is reported in the debug log.Please I need any haelp or clue.
Thanks in advance !!

 

ParnisariPabloParnisariPablo

I attach the VF and controller code :

Any help will be very appreciated !!

 

 

<apex:page tabStyle="Account"  controller="Justificar_Opp_Vencidas" contentType="text/html">
    <apex:messages />
    <apex:sectionHeader title="Justificación Oportunidades vencidas"/>
    <apex:pageBlock >
    <apex:form styleClass="bodyDiv" >
        <apex:outputLabel value="Periodo:" for="periodList" />
        <apex:selectList id="periodList" value="{!periodo}" size="1" required="false">
            <apex:selectOptions id="periodo" value="{!periodos}" />
        </apex:selectList>
        <apex:commandButton action="{!generar}"  value="Ir"/>
        <apex:commandButton action="{!grabar}" value="Grabar" />
        <br/><br/>


        <apex:pageBlockTable id="tabla"   styleClass="bodyDiv" value="{!filas}" var="fila" >

            <apex:column headerValue="Sel" styleClass="dato"> 
              <apex:selectCheckboxes value="{!fila.selecc}" required="false"/>            
            </apex:column>
            <apex:column headerValue="Motivo" styleClass="dato">             
              <apex:actionRegion >
              <apex:selectList id="motivos" value="{!fila.motivo}" size="1" required="false">
                <apex:actionSupport action="{!fila.cargarSubMotivos}" event="onchange" reRender="subMotivos"/>      
                <apex:selectOptions id="motivo" value="{!fila.motivos}"/>
              </apex:selectList>                    
              </apex:actionRegion>
            </apex:column>                         
            <apex:column headerValue="SubMotivo" styleClass="dato">                         
              <apex:actionRegion >
              <apex:selectList id="subMotivos" value="{!fila.subMotivo}" size="1" required="false">
                <apex:selectOptions id="subMotivo" value="{!fila.subMotivos}" />
              </apex:selectList>   
              </apex:actionRegion>                 
            </apex:column>
      
            <apex:column headerValue="Acción" styleClass="dato">                                                  
               <apex:inputText value="{!fila.accion}" required="false"/>            
            </apex:column>                        
            <apex:column headerValue="Comentario" styleClass="dato">                                                  
               <apex:inputTextarea value="{!fila.comentario}" required="false"/>                                                
            </apex:column>    

		.....
        </apex:pageBlockTable>
    
    </apex:form>  
    </apex:pageBlock> 
</apex:page>

APEX CONTROLLER ------------------------------------

public with sharing class Justificar_Opp_Vencidas {

    public List<SelectOption> periodos { get; set; }
    String periodo;
    public void setperiodo (string p) {periodo=p;}
    public string getperiodo () {return periodo;}    
    public String contentType { get; set; }
    public List<Linea_Vencida> filas {get; set;}
    public Justificar_Opp_Vencidas () {
        filas = new List<Linea_Vencida>();    
        periodos=new  List<SelectOption>();
        armarperiodos();
    }
    
    public pagereference generar() {
    try{
system.debug('DEBUGDEBUGDEBUGDEBUG------------------------------------------------------');
system.debug(periodo);    
        date hasta;
	date desde=date.parse(periodo);
system.debug(desde);            
        if (periodo==date.today().format()) hasta=date.today().addDays(1);
	.........        
        for (OpportunityLineItem resultado: [SELECT id, BRM_Fecha_Requerida__c, 
                                                      Fecha_Facturado__c,IND_VencidoCapability__c, 
                                                      IND_VencidoReliability__c, AccionVencida__c, 
                                                      ComentarioVencida__c, Opportunity.OV_MFG__c,
                                                      PricebookEntry.Product2.ProductCode,                                                    
                                                      PricebookEntry.Product2.Name, 
                                                      opportunity.account.AccountNumber, opportunity.account.Name,
                                                      Quantity, 
                                                      IND_DeliveryTime__c 
                                                      FROM OpportunityLineItem
                                                      where AccionVencida__c='' and BRM_Fecha_Requerida__c>=:desde and BRM_Fecha_Requerida__c<:hasta LIMIT 5]) {
            Linea_Vencida unaFila=new Linea_Vencida();
            unaFila.comentario=resultado.ComentarioVencida__c;
            unaFila.accion=resultado.AccionVencida__c;
            unaFila.id=resultado.id;
            unaFila.ov=resultado.Opportunity.OV_MFG__c<>null? resultado.Opportunity.OV_MFG__c:'-';
            unaFila.fecReq=resultado.BRM_Fecha_Requerida__c<>null? resultado.BRM_Fecha_Requerida__c.format():'-'; 
	    .............
            filas.add(unaFila);
        }
}
catch(Exception ex){
ApexPages.addMessages(ex);
}

        return ApexPages.currentPage();
    }
    
       
    public void armarperiodos() {
        periodo=date.today().format();
        periodos.add(new SelectOption(date.today().format(),'Hoy'));        
        periodos.add(new SelectOption(date.today().addDays(-1).format(),'Ayer'));                
	.........                                     
    }    
    
    public with sharing class Linea_Vencida {
       Boolean selecc;
       public boolean getSelecc () {return selecc;}
       public void setSelecc (boolean s) {selecc=s;}
       String accion;
       public string getAccion () {return accion;}
       public void setAccion (string a) {accion=a;}
       String comentario;
       public string getComentario() {return comentario;}
       public void setComentario(string c) {comentario=c;}
       public List<SelectOption> motivos { get; set; }
       public List<SelectOption> subMotivos { get; set; }       
       String Motivo;
       public string getMotivo() {return motivo;}
       public void setMotivo(string m) {motivo=m;}       
       String subMotivo;    
       public string getSubMotivo() {return subMotivo;}
       public void setSubMotivo(string s) {subMotivo=s;}       

                 
       public String ov { get; set; } 
       public String fecReq { get; set; }        
       public String fecFac { get; set; }        
       public String indCap { get; set; }           
       public String indRea { get; set; }           
       public String prdCod { get; set; }         
       public String prdName { get; set; }  
       public String accNumber { get; set; }         
       public String accName { get; set; }         
       public String quanti { get; set; }                
       public String delTime { get; set; }                       
       
       public ID id { get; set; } 
       
       Public Linea_Vencida() {
           motivos= new List<SelectOption>();
           subMotivos= new List<SelectOption>();           
           motivos.add(new SelectOption('m1','m1'));        
           comentario='';...............
       }



           
    }
}

 

 

EMHDevEMHDev

I think I've read somewhere that you shouldn't have a form tag inside a pageBlock.  Try putting the pageBlock inside the form and see if that makes any difference.

 

ParnisariPabloParnisariPablo

Hi.

I try your suggestion but It doesn't works.

I interchanged pageBlock and forms tags without result (just changed the aspect of the rows table's)

Ive checked the debug an obtain the same result as before: first time the setters an method (generar) are runned and next times just setters runs but not the method called on the "action" attribute, without error on screen neither debug log.

 

Anyway I real appreciate your help.

 

Thanks.

Pablo.

ParnisariPabloParnisariPablo

The problem seems related with the"VisualForce execution flow of post back request" described here.

 

In this explanation is described that if some error appear while the postback data (viewstate) is processed the action method is never called, the problem is that, in my case, there aren't any error reported.

 

And seem that have had other similar problems in this and this post.

 

If any know this mechanism (execution flow) maybe could point me in the wright direction.

 

Thanks

Pablo.

SteveBowerSteveBower

Hola, try a few things:

 

1. Instead of returning ApexPages:currentPage() from generar, return null;

 

2. On your commandButton for generar, try adding: reRender="tabla"

 

3. Inside generar, I think you're going to want to add a   filas.clear()  before you start adding things to it.

 

Perhaps something there will help.  Best, Steve.

tabla" 
ParnisariPabloParnisariPablo

Steve:

 

I tried your suggestions but don´t work. Thanks anyway !

 

Finally I found the cause of the problem. It seems to be a BIG BUG in the platform itself.

 

In few words: when I remove the checkbox "Selecc" from the table everything works fine as is expected.

 

Put a checkbox inside a table inside a form generates a error that isn´t reported and cancel the proccess of the controller without any error !!

 

Tanks everyone !

Pablo

SteveBowerSteveBower

What do you get if you use <apex:inputCheckbox> instead of <apex:selectCheckboxes>?

 

selectCheckboxes requires some <apex:selectOptions> and I don't think that's what you want in your situation.

 

 

Note: I think my other suggestions are still correct for what you're doing. Best, Steve.