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
Angello Camacho DragoAngello Camacho Drago 

apex:commandButton redirect with rerender tag

I have a commandButton that call two actionfunctions the two actionfunctions call to methods that return a String, but one of the methods some time return null, and when the method return null the visualforce page is reloaded , I try putting a rerender attribute but is not working the visualforce page reload everything when the method return null, the button is "Exportar" this is my code:

<apex:page standardController="npe03__Recurring_Donation__c" extensions="ReporteCompromisosExportacionController" tabStyle="Reporte_Compromisos__tab">

    <script type="text/javascript">
        function loading(val) {
            //document.getElementById('{!$Component.theForm1.theBlock.theSection.theSectionItemTipo.typeCard}').value;
            if (val) {
                document.getElementById('contentLoading').style.display = 'block';
                document.getElementById('contentLoaded').style.display = 'none';
            } else {
                document.getElementById('contentLoading').style.display = 'none';
                document.getElementById('contentLoaded').style.display = 'block';
            }
        }
    </script>
    <apex:form id="theForm1">
        <apex:pageBlock title="Reporte Donaciones Recurrentes" id="theBlock">
            <apex:pageMessages id="errors" />
            
            <apex:actionFunction name="showbn" action="{!chooseCardType}" reRender="theSection,theSectionItemBanco,theSectionItemBlank" status="loading">
                <apex:param name="mediodePago" value="" />
            </apex:actionFunction>
            <apex:actionFunction name="showpn" action="{!showPreNotificacion}" reRender="theSection,theSectionItemBlank" status="loading">
                <apex:param name="nombreBanco" value="" />
            </apex:actionFunction>
            
            <apex:actionFunction name="generate" action="{!generateURL}" reRender="{!If(cards=='Visa','errors,buttons','')}" status="{!If(cards=='Visa','loading','')}"/>
            <apex:actionFunction name="disable" action="{!runUpdate}" reRender="errors,buttons" status="loading"/>
            <apex:actionFunction name="redirectPre" action="{!redirectPreURL}"/>
            <apex:actionFunction name="enable" action="{!enableExport}" reRender="buttons" status="loading"/>

            <apex:actionStatus id="loading" onstart="loading(true)" onstop="loading(false)" />

            <apex:pageblockSection id="theSection" title="Filtros de búsqueda">
                <apex:pageBlockSectionItem id="theSectionItemMedio" rendered="{!showFinancia}">
                    <apex:outputLabel value="Medio de Pago" for="medioCard" />
                    <apex:inputField value="{!Donation.Medio_de_Pago__c}" id="medioCard" onchange="showbn(this.value);"/>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem id="theSectionItemTipo" rendered="{!showFinancia}">
                    <apex:outputLabel value="Tipo de Tarjeta" for="typeCard" />
                    <apex:selectList id="typeCard" multiselect="false" size="1" value="{!card}" disabled="{!!cardt}">
                        <apex:selectOptions value="{!cards}" />
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem id="theSectionItemBanco" rendered="{!bank}">
                    <apex:outputLabel value="Entidad de Cobro" for="entidadCobro" />
                    <apex:selectList id="cobrador" multiselect="false" size="1" value="{!cobra}" onchange="showpn(this.value);">
                        <apex:selectOptions value="{!cobradores}" />
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem id="theSectionItemBlank" rendered="{!bank}">
                    <apex:outputLabel value="Pre Notificación" for="preNotificacion" rendered="{!preNotificacion}"/>
                    <apex:inputField value="{!Donation.Pre_Notificado__c}" id="preNotificado" rendered="{!preNotificacion}"/>
                </apex:pageBlockSectionItem>
                
                <apex:pageBlockSectionItem id="theSectionItemDesde">
                    <apex:outputLabel value="Fecha Desde" for="fromDate" />
                    <apex:inputField value="{!Donation.npe03__Date_Established__c}" id="fromDate" />
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem id="theSectionItemHasta">
                    <apex:outputLabel value="Fecha Hasta" for="toDate" />
                    <apex:inputField value="{!DonationHasta.npe03__Date_Established__c}" id="toDate" />
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem id="theSectionItemSemana">
                    <apex:outputLabel value="Semana de Cobro" for="weekPay" />
                    <apex:selectList id="weekPay" multiselect="true" size="5" value="{!semana}" style="width:50px;">
                        <apex:selectOptions value="{!semanas}" />
                    </apex:selectList>
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem id="theSectionItemEstado">
                    <apex:outputLabel value="Estado" for="status" />
                    <!--  <apex:inputField value="{!npe03__Recurring_Donation__c.npe03__Open_Ended_Status__c}" id="status"/>  -->
                    <apex:selectList id="status" multiselect="true" size="3" value="{!estado}">
                        <apex:selectOptions value="{!estados}" />
                    </apex:selectList>
                </apex:pageBlockSectionItem>

                <!--  <apex:pageBlockSectionItem id="theSectionItemInStop" >
                    <apex:outputLabel value="En pausa" for="inStop"/>
                    <apex:inputField value="{!npe03__Recurring_Donation__c.En_Pausa__c}" id="inStop"/> 
                </apex:pageBlockSectionItem> -->
            </apex:pageblockSection>
            <div id="contentLoaded">
                <apex:pageblockSection id="buttons">
                    <apex:pageBlockSectionItem >
                        <apex:commandButton value="Buscar" action="{!runSearch}" reRender="grilla,debug,errors,buttons" status="loading"/>
                    </apex:pageBlockSectionItem>
                    <apex:pageBlockSectionItem >
                        <apex:commandButton value="Pre Visualizar" onclick="redirectPre();" oncomplete="enable();" disabled="{!!exportedPre}" />
                        <apex:commandButton value="Exportar" onclick="generate();" oncomplete="disable();" disabled="{!!exported}" />                     
                    </apex:pageBlockSectionItem>
                </apex:pageBlockSection>
            </div>
            <div id="contentLoading" style="display: none;">
                <div style="text-align: center;">
                    <img src="/img/loading.gif" alt="Procesando..." />
                </div>
            </div>
            <br/>
            <apex:pageblockSection id="grilla" columns="1">
                <apex:pageBlockTable value="{!resultado}" var="c">
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="Id Donación" action="{!toggleSort}" rerender="grilla,debug">
                                <apex:param name="sortField" value="Id" assignTo="{!sortField}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!c.Id}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="PSN" action="{!toggleSort}" rerender="grilla,debug">
                                <apex:param name="sortField" value="PSN__c" assignTo="{!sortField}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!c.PSN__c}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="Nombre Cuenta" action="{!toggleSort}" rerender="grilla,debug">
                                <apex:param name="sortField" value="AccountId" assignTo="{!sortField}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!c.Nombre_Cuenta__c}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="Nombre" action="{!toggleSort}" rerender="grilla,debug">
                                <apex:param name="sortField" value="Nombre__c" assignTo="{!sortField}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!c.Nombre__c}" />
                    </apex:column>                  
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="Apellido" action="{!toggleSort}" rerender="grilla,debug">
                                <apex:param name="sortField" value="Apellidos__c" assignTo="{!sortField}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!c.Apellidos__c}" />
                    </apex:column>                  
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="DNI" action="{!toggleSort}" rerender="grilla,debug">
                                <apex:param name="sortField" value="N_mero_de_Documento__c" assignTo="{!sortField}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!c.N_mero_de_Documento__c}" rendered="{!c.N_mero_de_Documento__c!=null}"/>
                        <apex:outputField value="{!c.Account.N_Fiscal__c}" rendered="{!c.N_mero_de_Documento__c==null}"/>
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="Monto" action="{!toggleSort}" rerender="grilla,debug">
                                <apex:param name="sortField" value="Amount" assignTo="{!sortField}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!c.Amount}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="Tipo Tarjeta" action="{!toggleSort}" rerender="grilla,debug">
                                <apex:param name="sortField" value="Tipo_de_Tarjeta__c" assignTo="{!sortField}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!c.Tipo_de_Tarjeta__c}" />
                    </apex:column>                  
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="Número Tarjeta" action="{!toggleSort}" rerender="grilla,debug">
                                <apex:param name="sortField" value="Numero_de_Tarjeta__c" assignTo="{!sortField}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!c.Numero_de_Tarjeta__c}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="Fecha Vencimiento" action="{!toggleSort}" rerender="grilla,debug">
                                <apex:param name="sortField" value="Fecha_de_Vencimiento__c" assignTo="{!sortField}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!c.Fecha_de_Vencimiento__c}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="Número Cuenta" action="{!toggleSort}" rerender="grilla,debug">
                                <apex:param name="sortField" value="Numero_de_Tarjeta__c" assignTo="{!sortField}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!c.Numero_de_Cuenta__c}" />
                    </apex:column>
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink value="Frecuencia" action="{!toggleSort}" rerender="grilla,debug">
                                <apex:param name="sortField" value="Frecuencia__c" assignTo="{!sortField}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!c.Frecuencia__c}" />
                    </apex:column>
                </apex:pageBlockTable>
            </apex:pageblockSection>
            <apex:pageMessages />
        </apex:pageBlock>
    </apex:form>

</apex:page>
SonamSonam (Salesforce Developers) 
Hi,

I checked your code and seems like you are trying to rerender the pageblocksection based on card value.Can you please try to update the action fucntion as given below and confirm if that works for you:

</apex:actionFunction>
            <apex:actionFunction name="showpn" action="{!showPreNotificacion}" reRender="theSection,theSectionItemBlank" status="loading">
                <apex:param name="nombreBanco" value="" />
            </apex:actionFunction>
            
            <apex:actionFunction name="generate" action="{!generateURL}" reRender="errors,buttons" status="loading"/>
            <apex:actionFunction name="disable" action="{!runUpdate}" reRender="errors,buttons" status="loading"/>
            <apex:actionFunction name="redirectPre" action="{!redirectPreURL}"/>
            <apex:actionFunction name="enable" action="{!enableExport}" reRender="buttons" status="loading"/>