0

I have a vf page "ASC_NAR_Page2" that allows the user to select from a list of accounts, with checkboxes, to be inserted into a custom object. Once the user clicks on "Process Records" button, it writes the records to the custom object "NAR__c" and then should redirect to another vf page "ASC_NAR_Page2a" where the newly written records will be displayed for verification to the user. However, when once the button, "Process Records" is clicked, the browser will load "ASC_NAR_Page2a" on the screen but the browser url will show "ASC_NAR_Page2". AND at the bottom, since i am in development mode, I see the two development bars....one for "ASC_NAR_Page2" with it's respective class "ASC_NAR_Class2"....and the other is for "ASC_NAR_Page2a" with it's class "wrapperClassController". On the "ASC_NAR_Page2a", I have a button to send a notification email "Send Email". However, if I click on the button, i get a completely blank white screen and it doesn't send the email. If i modify the url to add the "a" to the end of the page name in the browser and then click the "Send Email" button, it will redirect the the correct screen and it will send the email.

ASC_NAR_Page2a development bar at the bottom of ASC_NAR_Page2a

ASC_NAR_Page2

<apex:form id="TheForm">

    <apex:pageBlock title="New/Reactivated Accounts" mode="edit">
        <apex:pageBlockSection title="Parent BPID" columns="2">
            <apex:inputText id="parentBPID" value="{!bogusNAR.Parent_BPID__c}"/>
        </apex:pageBlockSection>
        <apex:pageBlockSection title="General Notes" columns="2">
            <apex:inputTextarea id="newNote" value="{!bogusNAR.General_Notes__c}" cols="100"/>
        </apex:pageBlockSection>
        <apex:pageBlockSection title="Web Notes" columns="2">
            <apex:inputTextarea id="webNote" value="{!bogusNAR.Web_Notes__c}" cols="100"/>
        </apex:pageBlockSection>
    </apex:pageBlock>

    <!-- ***************************** -->
    <!-- Search Criteria               -->
    <apex:pageBlock title="Search For an Account" mode="edit"><!--mode="maindetail"-->
        <div class="search-block">
            <div style="display: inline-table">
                <span>BPID:</span>
                <apex:inputText value="{!SearchBPID}" />
            </div>
            <div style="display: inline-table">
                <span>Account Name:</span>
                <apex:inputText value="{!SearchName}" />
            </div>
            <!--<div style="display: inline-table">
                <span>Billing Address:</span>
                <apex:inputText value="{!SearchBillingAddress}" />
            </div>-->
            <apex:commandButton styleClass="search-block-button" value="Search" action="{!SearchAccount}" rerender="TablePanel" status="TableUpdateStatus" />
        </div>

        <div class="process-block">
            <apex:actionStatus id="ProcessButtonStatus">
                <apex:facet name="stop">
                    <apex:outputPanel >
                        <apex:commandButton styleClass="process-block-button" value="Process Selected" action="{!DoSomethingMany}" status="ProcessButtonStatus" rerender="nothing" />
                        <apex:commandButton styleClass="process-block-button" value="Clear All" action="{!ClearAll}" rerender="TheForm,TablePanel" />
                    </apex:outputPanel>
                </apex:facet>
                <apex:facet name="start">
                    <apex:outputPanel >
                        <apex:commandButton styleClass="process-block-button" value="Processing..." disabled="true" />
                        <apex:commandButton styleClass="process-block-button" value="Processing..." disabled="true" />
                    </apex:outputPanel>
                </apex:facet>
            </apex:actionStatus>
        </div>
    </apex:pageBlock>

    <!-- ************************* -->
    <!-- search results table      -->
    <apex:pageBlock id="TablePanel">
        <div>
            <span class="page-buttons" style="float: left; margin-bottom: 5px;"> 
                <apex:commandButton disabled="{!!StdSetControllerAccount.hasprevious}" value="Previous" action="{!StdSetControllerAccount.previous}" rerender="TablePanel" /> <apex:commandButton disabled="{!!StdSetControllerAccount.hasnext}" value="Next" action="{!StdSetControllerAccount.next}" rerender="TablePanel" />
            </span>
            <!-- alphabet selection -->
            <span style="float: right; margin: 5px 5px 5px 5px;"> 
                <apex:repeat value="{!AlphaList}" var="a">
                    <apex:commandLink value="{!a}" action="{!BuildQuery}" rerender="TablePanel" styleClass="alpha-link{!if(AlphaFilter=a,' alpha-select','')}" status="TableUpdateStatus">
                        <apex:param name="AlphaFilter" value="{!a}" assignTo="{!AlphaFilter}" />
                    </apex:commandLink>
                </apex:repeat>
            </span>
        </div>

        <div style="clear: both;"></div>

        <apex:actionStatus id="TableUpdateStatus">
            <apex:inputHidden value="{!AlphaFilter}" id="hiddenField" />

            <!-- loading message -->
            <apex:facet name="start">
                <apex:outputPanel layout="block" styleClass="message infoM4">
                    <apex:panelGrid columns="2" styleClass="messageTable" columnClasses="messageCell" style="padding:0px;margin:0px;">
                        <apex:panelGroup >
                            <img class="loading-icon" src="/s.gif" />
                        </apex:panelGroup>
                        <apex:panelGroup >
                            <div class="messageText">Please wait...</div>
                        </apex:panelGroup>
                    </apex:panelGrid>
                </apex:outputPanel>
            </apex:facet>

            <!-- Account table -->
            <apex:facet name="stop">
                <apex:pageBlockTable value="{!CurrentAccountList}" var="a">
                    <!--<apex:column >
                        <apex:commandLink styleClass="alpha-link" action="{!DoSomethingOne}"><apex:param value="{!a.aAccount.Id}" assignTo="{!SelectedOneAccount}" />Select</apex:commandLink>
                    </apex:column>-->

                    <!-- Checkbox -->
                    <apex:column >
                        <apex:facet name="header">
                            <apex:outputPanel id="SelectedCount">
                                <div style="text-align: center;">
                                    <apex:outputText value="Selected" />
                                    <br />
                                    <apex:outputText value="{!AccountSelectedCount}" />
                                </div>
                            </apex:outputPanel>
                        </apex:facet>
                        <div style="text-align: center;">
                            <apex:inputCheckBox value="{!a.aCheckBox}" id="check-box">
                                <apex:actionSupport event="onchange" rerender="SelectedCount" action="{!UpdateAccountSelectedSet}" />
                            </apex:inputcheckbox>
                        </div>
                    </apex:column>

                    <!-- table columns -->
                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                                <apex:param name="SortField" value="Baan_BPID__c" assignTo="{!SortField}" />
                                <apex:outputText value="{!$ObjectType.Account.Fields.Baan_BPID__c.Label}{!IF(SortField=='Baan_BPID__c',IF(SortDirection='asc','▲','▼'),'')}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!a.aAccount.Baan_BPID__c}" />
                    </apex:column>


                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                                <apex:param name="SortField" value="Name" assignTo="{!SortField}" />
                                <apex:outputText value="{!$ObjectType.Account.Fields.Name.Label}{!IF(SortField=='Name',IF(SortDirection='asc','▲','▼'),'')}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputLink value="/{!a.aAccount.Id}" target="_blank">{!a.aAccount.Name}</apex:outputlink>
                    </apex:column>


                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                                <apex:param name="SortField" value="OG_Baan_BP_Type__c" assignTo="{!SortField}" />
                                <apex:outputText value="{!$ObjectType.Account.Fields.OG_Baan_BP_Type__c.Label}{!IF(SortField=='OG_Baan_BP_Type__c',IF(SortDirection='asc','▲','▼'),'')}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!a.aAccount.OG_Baan_BP_Type__c}" />
                    </apex:column>


                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                                <apex:param name="SortField" value="DEA_License__c" assignTo="{!SortField}" />
                                <apex:outputText value="{!$ObjectType.Account.Fields.DEA_License__c.Label}{!IF(SortField=='DEA_License__c',IF(SortDirection='asc','▲','▼'),'')}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!a.aAccount.DEA_License__c}" />
                    </apex:column>


                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                                <apex:param name="SortField" value="ASD_SML__c" assignTo="{!SortField}" />
                                <apex:outputText value="{!$ObjectType.Account.Fields.ASD_SML__c.Label}{!IF(SortField=='ASD_SML__c',IF(SortDirection='asc','▲','▼'),'')}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!a.aAccount.ASD_SML__c}" />
                    </apex:column>


                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                                <apex:param name="SortField" value="OG_Channel_Code__c" assignTo="{!SortField}" />
                                <apex:outputText value="{!$ObjectType.Account.Fields.OG_Channel_Code__c.Label}{!IF(SortField=='OG_Channel_Code__c',IF(SortDirection='asc','▲','▼'),'')}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!a.aAccount.OG_Channel_Code__c}" />
                    </apex:column>


                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                                <apex:param name="SortField" value="OG_Credit_Limit__c" assignTo="{!SortField}" />
                                <apex:outputText value="{!$ObjectType.Account.Fields.OG_Credit_Limit__c.Label}{!IF(SortField=='OG_Credit_Limit__c',IF(SortDirection='asc','▲','▼'),'')}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!a.aAccount.OG_Credit_Limit__c}" />
                    </apex:column>


                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                                <apex:param name="SortField" value="OG_Payment_Terms__c" assignTo="{!SortField}" />
                                <apex:outputText value="{!$ObjectType.Account.Fields.OG_Payment_Terms__c.Label}{!IF(SortField=='OG_Payment_Terms__c',IF(SortDirection='asc','▲','▼'),'')}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!a.aAccount.OG_Payment_Terms__c}" />
                    </apex:column>


                    <apex:column >
                        <apex:facet name="header">
                            <apex:commandLink action="{!SortToggle}" rerender="TablePanel" status="TableUpdateStatus">
                                <apex:param name="SortField" value="OG_Statement_Method__c" assignTo="{!SortField}" />
                                <apex:outputText value="{!$ObjectType.Account.Fields.OG_Statement_Method__c.Label}{!IF(SortField=='OG_Statement_Method__c',IF(SortDirection='asc','▲','▼'),'')}" />
                            </apex:commandLink>
                        </apex:facet>
                        <apex:outputField value="{!a.aAccount.OG_Statement_Method__c}" />
                    </apex:column>


                </apex:pageBlockTable>
            </apex:facet>
        </apex:actionStatus>
        <div style="margin-top: 5px;">
            <apex:outputText value="Number of Records per Page: " />
            <apex:selectList value="{!RecPerPage}" size="1">
                <apex:selectOptions value="{!RecPerPageOption}" />
                <apex:actionSupport event="onchange" action="{!BuildQuery}" reRender="TablePanel" status="TableUpdateStatus" />
            </apex:selectList>
        </div>
    </apex:pageBlock>
</apex:form>

ASC_NAR_Class2

public with sharing class ASC_NAR_Class2 {
public New_Account_Reactivation__c bogusNAR { get; set; }
public New_Account_Reactivation__c nar {get;set;}
public List<Account> accountList2 {get; set;}

// account and selection set/variables
private list<AccountSubClass> AccountList {get; set;}
private set<Id> AccountSelectedSet;
public Integer AccountSelectedCount {get; set;}

// selection and filter 
public list<String> AlphaList {get; set;}
public String AlphaFilter {get; set;}
public String SearchName {get; set;}
public String SearchBPID {get; set;} // ADDED
private String SaveSearchName;
private String SaveSearchBPID; // ADDED
private String QueryAccount;

// display sort and number
public String RecPerPage {get; set;}
public list<SelectOption> RecPerPageOption {get; set;}  
public String SortFieldSave;

public ASC_NAR_Class2(){
    bogusNAR = new New_Account_Reactivation__c();
    AccountList = new list<AccountSubClass>();
    AccountSelectedSet = new set<Id>();        
    // list generation
    BuildQuery();  
}

public ApexPages.StandardSetController StdSetControllerAccount {
    get {
        if(StdSetControllerAccount == null) {
            StdSetControllerAccount = new ApexPages.StandardSetController(Database.getQueryLocator(QueryAccount));
            // sets the number of records in each page set
            StdSetControllerAccount.setPageSize(Integer.valueOf(RecPerPage));
        }
        return StdSetControllerAccount;
    }
    set;
}

public list<AccountSubClass> getCurrentAccountList() {
    UpdateAccountSelectedSet();

    AccountList = new list<AccountSubClass>();
    for (Account a : (list<Account>)StdSetControllerAccount.getRecords()) {
        AccountList.add(new AccountSubClass(a, AccountSelectedSet.contains(a.Id)));
    }
    return AccountList;
}

public PageReference ClearAll(){
    AccountList.clear();
    AccountSelectedSet.clear();
    AccountSelectedCount = 0;
    SearchName = '';
    SearchBPID = '';  // ADDED
    SaveSearchName = '';
    SaveSearchBPID = ''; // ADDED
    AlphaFilter = 'All';

    BuildQuery();

    return null;
}


public PageReference DoSomethingMany() {
    List<Account> selectedAccounts = new List<Account>();

    // create a list for DML - this list is populated by the account loop below
    List<New_Account_Reactivation__c> reactivationsToUpsert = new List<New_Account_Reactivation__c>();


    for (Id AccountId : AccountSelectedSet) {
        // create an instance
        New_Account_Reactivation__c nar = new New_Account_Reactivation__c();

        // get the notes from the fake NAR record bound to the page input fields
        nar.Parent_BPID__c = bogusNAR.Parent_BPID__c;
        nar.Web_Notes__c = bogusNAR.Web_Notes__c;
        nar.General_Notes__c = bogusNAR.General_Notes__c;
        nar.Send__c = True;

        // Get selected account fields
        for(Account a : [SELECT Id, baan_bpid__c, name, og_baan_bp_type__c, 
                         DEA_License__c, ASD_SML__c, OG_Channel_Code__c, OG_Credit_Limit__c, OG_Payment_Terms__c, OG_Statement_Method__c 
                         FROM Account WHERE Id =:AccountId]) {
            // set the field values
            nar.BPID__c = a.Baan_BPID__c;
            nar.Account__c = a.Id;
            nar.Baan_BP_Type__c = a.og_baan_bp_type__c;
            nar.DEA__c = a.DEA_License__c;
            nar.SML__c = a.ASD_SML__c;
            nar.Channel_Code__c = a.OG_Channel_Code__c;
            nar.Credit_Limit__c = a.OG_Credit_Limit__c;
            nar.Payment_Terms__c = a.OG_Payment_Terms__c;
            nar.Statement_Method__c = a.OG_Statement_Method__c;

        }

        // add it to the list for later DML
        reactivationsToUpsert.add(nar);


        //system.debug('Checked: ' + AccountId);
    }

    // check for not empty and then DML
    if (!reactivationsToUpsert.isEmpty()) {
        upsert reactivationsToUpsert;
    }

    PageReference nextPage = new PageReference('/apex/ASC_NAR_Page2a');
    nextPage.setRedirect(true);
    return nextPage;

}      

}

ASC_NAR_Page2a

<apex:page controller="wrapperClassController_Cont" >

<apex:form >
    <apex:commandButton action="{!sendEmail}" value="Send Email" id="theButton"/>
</apex:form>    

<apex:dataTable value="{!NAR2s}" var="nar2">
    <apex:column ><apex:facet name="header">General Notes</apex:facet>{!nar2.General_Notes__c}</apex:column>
</apex:dataTable>
<br/>
<apex:dataTable value="{!NAR2s}" var="nar2">
    <apex:column ><apex:facet name="header">Parent BPID</apex:facet>{!nar2.Parent_BPID__c}</apex:column>
</apex:dataTable>
<br/>

<apex:dataTable value="{!NARs}" var="nar">
    <apex:column >
        {!nar.Account__r.name}<br/>
        {!nar.Address__c}<br/>
        {!nar.City__c}, {!nar.State__c} {!nar.Zip__c}<br/>

        <b>Acct#</b> {!nar.BPID__c}<br/>
        Acct Type: {!nar.Baan_BP_Type__c}<br/>
        Credit Limit: {!nar.Credit_Limit__c}<br/>
        Terms: {!nar.Payment_Terms__c}<br/>
        Channel Code: {!nar.Channel_Code__c}<br/>
        Statement Method: {!nar.Statement_Method__c}<br/>
        DEA# {!nar.DEA__c}<br/>
        SML# {!nar.SML__c}<br/>
        <br/><br/>
    </apex:column>
</apex:dataTable>

<br/><br/>
<apex:dataTable value="{!NAR2s}" var="nar2">
    <apex:column ><apex:facet name="header">Web Notes</apex:facet>{!nar2.Web_Notes__c}</apex:column>
</apex:dataTable>

wrapperClassController

public class wrapperClassController_Cont {

public User myUser { get;set;}
User currentUser = [Select email from User where username = :UserInfo.getUserName() limit 1];

public PageReference sendEmail() {
    PageReference emailPage = new PageReference('/email/author/emailauthor.jsp');
    Map<String, String> params = emailPage.getParameters();
    //params.put('p3_lkid',acct.ID); //email will be attached to the activity history of the account where the button was clicked using the acct.ID
    params.put('template_id','00Xd0000001BbLi'); /// template ID of the email template to be shown goes here
    params.put('rtype','003');
    params.put('p24',currentUser.Email); //currentUser.Email showing in "Additional to" field
    //params.put('p5','[email protected]'); //email address showing in Bcc field
    params.put('new_template','1');
    params.put('retURL','/a0K/o'); //after send button is clicked, go back to the account where the button was clicked


    return emailPage;
}


private final List<New_Account_Reactivation__c> nar;
private final List<New_Account_Reactivation__c> nar2;

public wrapperClassController() {
    nar = [SELECT
                Id,
                BPID__c, 
                Account__r.name, 
                Address__c, 
                City__c, 
                State__c, 
                Zip__c, 
                Baan_BP_Type__c,
                DEA__c, 
                SML__c,
                Channel_Code__c, 
                Credit_Limit__c, 
                Payment_Terms__c, 
                Statement_Method__c
            FROM 
                New_Account_Reactivation__c 
            WHERE 
                Send__c = True];

    nar2 = [SELECT Parent_BPID__c, General_Notes__c, Web_Notes__c FROM New_Account_Reactivation__c WHERE Send__c = True LIMIT 1];
}

public List<New_Account_Reactivation__c> getNARs() {
    return nar;
}

public List<New_Account_Reactivation__c> getNAR2s() {
    return nar2;
}

}

Any ideas? I hope I was able to explain the issue I am having, well enough. Thanks in advance for any insight you can provide.

4 Answers 4

0

On the apex:commandButton in the ASC_NAR_Page2 try taking the rerender attribute off. I suspect it is preventing the page redirecting as indicated by the PageReference.

1
  • 2
    Also, turn off "developer footer" when testing that stuff out. The footer does tend to get in the way of things sometimes.
    – sfdcfox
    Sep 19, 2014 at 4:37
1

Are you using same controller for both VF pages ? Do you want to pass data from one VF page to another ?

If you will set setRedirect attribute of pageReference to TRUE , then it will change URL of the page as per your need. But in this case, the values which you might have set in class , will be lost. Can you please confirm what actually you want to achieve ?

0

I think as you logged in as Admin and trying to navigate to different page it is showing like that.

This will not replicate if you 'login as user' and trying to navigate.

Please let me know if you observe the same.

Thanks.

0

I had my dev mode on so my page was redirecting and rerendering but URL on top of the page remain same or old one. I turned off Development mode and it fixed my issue. @sfdcfox Thanks for your tip

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .