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
Abdul RazzaqAbdul Razzaq 

WrapperClass, Checkbox, One Vfpage to other Vfpage.

I don't know where I am going wrong. I am being redirected to other Vfpage yet niether URL changes nor I am able to fetch the values from one Vfpage to other.

And I am using single controller for both Vfpages. Agony is I am getting two develpment mode windows of two visualforce page; when I click "edit".

Vfpage one 

<apex:page controller="WrapperAccountextension">
   <apex:form >
        <apex:pageBlock title="Account List">
        
            <apex:pageBlockButtons >
                <apex:commandButton value="Edit" action="{!geteditormoz}" rerender="out"/>
            </apex:pageBlockButtons>
           
            <apex:pageBlockTable value="{!Accountsz}" var="Acc">
                <apex:column headerValue="Action">
                   
                    <apex:inputCheckbox value="{!Acc.selected}"/>
                </apex:column>
                
                <apex:column value="{!Acc.con.Name}" />
                <apex:column value="{!Acc.con.Phone}" />
                <apex:column value="{!Acc.con.Fax}"/>
                <apex:column value="{!Acc.con.AnnualRevenue}"/>
                <apex:column value="{!Acc.con.AccountNumber}"/>
            </apex:pageBlockTable>
        
        </apex:pageBlock>
        </apex:form>
</apex:page>

 

=========================================================================================================================================================================================================================================================================================================================Vfpage two:-

<apex:page controller="WrapperAccountextension">
<apex:form >
 <apex:pageblock mode="InlineEdit">
        <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!rasavez}"/>
        </apex:pageBlockButtons>
      
               <apex:pageBlockTable value="{!selectedAccountsz}" var="Rec" id="out" title="Selected Accounts" columnsWidth="400px,400px">
                    <apex:column headerValue="Account Name">
                        <apex:outputField value="{!Rec.name}"/>
                    </apex:column>   
                    <apex:column headerValue="Phone">
                        <apex:outputField value="{!Rec.Phone}"/>
                    </apex:column>             
                    <apex:column headerValue="Fax">
                    <apex:outputField value="{!Rec.Fax}"/>
                    </apex:column>
                    <apex:column headerValue="Annual Revenue">
                    <apex:outputField value="{!Rec.AnnualRevenue}"/>
                    </apex:column>
                    <apex:column headerValue="Account Number">
                    <apex:outputfield value="{!Rec.AccountNumber}"/>
                    </apex:column>
                </apex:pageBlockTable>   
               
          </apex:pageblock>
</apex:form>
</apex:page>

=========================================================================================================================================================================================================================================================================================================================Controller:-

public class WrapperAccountextension {


Public pagereference rasavez(){

Update selectedAccountsz;
return null;
}

Public Pagereference editmoderz(){

return null;
}

public PageReference geteditormoz(){
Pagereference ldkedit = New PageReference('/apex/WrapperAccountlsteditera');
processSelectedz();

ldkedit.setRedirect(true);

return ldkedit;
}
    
 public List<cAccountz> accListz {get; set;}
  public List<Account> selectedAccountsz{get; set;}
//Adding the Records to inner class and to get the values for page block table.
  public List<cAccountz> getAccountsz(){
        if(accListz == null){
            accListz = new List<cAccountz>();
            for(Account acc : [select Id, Name, Phone,Fax,AnnualRevenue,AccountNumber from Account limit 25]){
                  accListz.add(new cAccountz(acc));
            }
         }
       return accListz;
   }  
//on button click it will show the list of records what we have selected.
  public PageReference processSelectedz(){     
  
  
        selectedAccountsz= new List<Account>();
        for(cAccountz cCon : getAccountsz()) {
            if(cCon.selected == true){
                selectedAccountsz.add(cCon.con);
                
            }
        }            
        return null;
   }
  //  Inner class for capture the records
  public class cAccountz {
        public Account con {get; set;}
        public Boolean selected {get; set;}
        public cAccountz(Account c) {
            con = c;
            selected = false;
        }
   }
     
}

 

Thanks and Regards,

Razzzaq.

Best Answer chosen by Abdul Razzaq
Sagarika RoutSagarika Rout
HI Abdul , 

Please try to remove the rendered Attribute from the command button , I think there is no use of rendered attribute here.

Hope this will work!!!


Thanks , 
Sagarika

All Answers

Nishant SharmaNishant Sharma
Replce this line:
 
ldkedit.setRedirect(true);

with below one, in your geteditormoz method.
 
ldkedit.setRedirect(false);

It wont clear data in your view state and you should be able to get data in another page after redirection.

When controller is same for 2 pages, it is salesforce behaviour to not to change URL. But that should not be a major problem for you, I believe.
Abdul RazzaqAbdul Razzaq

 

When I change it to "false" the Page is not being redirected to other Page.

Abdul RazzaqAbdul Razzaq
I mean to say, There is no change in behavior .
Sagarika RoutSagarika Rout
HI Abdul , 

Please try to remove the rendered Attribute from the command button , I think there is no use of rendered attribute here.

Hope this will work!!!


Thanks , 
Sagarika
This was selected as the best answer
Nishant SharmaNishant Sharma
Can you please replace your geteditormoz method with below
public PageReference geteditormoz(){
    Pagereference ldkedit = New PageReference('/apex/WrapperAccountlsteditera');
    system.debug('==== FIRST ====');
    selectedAccountsz= new List<Account>();
    for(cAccountz cCon : getAccountsz()) {
        if(cCon.selected == true){
            selectedAccountsz.add(cCon.con);
        }
    }
    system.debug('==== SECOND ====');
    ldkedit.setRedirect(false);
    system.debug('==== THIRD ====');
    return ldkedit;
}

And see what all debug are comings properly?
Abdul RazzaqAbdul Razzaq
I got all the three Debug Statements.
Abdul RazzaqAbdul Razzaq


USER_DEBUG|[37]|DEBUG|==== THIRD ====
SYSTEM_METHOD_EXIT|[37]|System.debug(ANY)
CODE_UNIT_FINISHED|WrapperAccountextension invoke(geteditormoz)
VF_APEX_CALL|j_id4|{!geteditormoz}|PageReference:/apex/WrapperAccountlsteditera
CODE_UNIT_STARTED|[EXTERNAL]|01p900000061C5g|WrapperAccountextension get(selectedAccountsz)
SYSTEM_MODE_ENTER|true
CODE_UNIT_STARTED|[EXTERNAL]|01p900000061C5g|selectedAccountsz
CODE_UNIT_FINISHED|selectedAccountsz
CODE_UNIT_FINISHED|WrapperAccountextension get(selectedAccountsz)
VF_SERIALIZE_VIEWSTATE_BEGIN|VF_SERIALIZE_VIEWSTATE_END
CUMULATIVE_LIMIT_USAGE

Abdul RazzaqAbdul Razzaq

Thanks Nishant for your Help. You really have been Helpful.

 

Nishant SharmaNishant Sharma
You are welcome Abdul.