0

I'm having issues with passing parameters to my vf page. I've tried doing something similar with communicating between component and visualforce page in this example: How do I pass a parameter from component to a Visualforce page?

Here is snippets of code of what I've tried. And I'm not getting back anything.

DataClass: 
public with sharing class CLSearchDataClass {

    public account acctData{get; set;}
    public Id acctId {get; set;}
}

Page Controller init:
public with sharing class SGIConvertLeadClass {  
   public CLSearchDataClass theAcctSC{
        get{
            return theAcctSC; 
        }
        set;
    }
}

Component attribute and use:
<apex:component controller="AccountSearchController" >
    <apex:attribute type="CLSearchDataClass" name="accData" required="true" description="Account Data" assignTo="{!aData}"/>
        <apex:pageBlockTable value="{!acctWrapList}" var="acctWrap" align="top">
            <apex:column >
                <apex:inputCheckbox id="selectAccountRow" value="{!acctWrap.isSelected}" >
                    <apex:actionSupport event="onclick" action="{!selectAcct}" reRender="accountFieldPanel, convertLeadPanel"/>
                </apex:inputCheckbox>
            </apex:column>

//we have a seaerch function in the component that is populated through a wrapper class and we are able to select the returned search results through a list of wrappers in the pageBlockTable that can be selected

Component Controller: 
public with sharing virtual class AccountSearchController {

    // the soql without the order and limit
    private String soql {get;set;}
    // the collection of account to display
    public List<Account> accounts {get;set;}
    //WrapperClass list for accounts searched
    public List<accountWrap> acctWrapList {get; set;}
    //Data class to pass objects to another page/controller
    public CLSearchDataClass aData {get; set;}

    public void selectAcct(){
        aData = new CLSearchDataClass();
        for (accountWrap aWrapper : acctWrapList){
            if (aWrapper.isSelected ){
                system.debug(aData.acctId);
                system.debug(aWrapper.oAccount.Id);
               aData.acctId = aWrapper.oAccount.Id;
                aData.acctData = aWrapper.oAccount;
                system.debug(aData.acctId);
                system.debug(aData.acctData);
            }
            else{
                aData.acctId = null;
                aData.acctData= null;
                system.debug(aData.acctId);
                system.debug(aData.acctData);
            }
        }
    }

VF page pass the data class 
                <apex:outputPanel id="accountSearchPanel">
                    <apex:pageBlockSection title="Existing Account Search" columns="1" id="acctSearhSection" rendered="{!acctCreate}">
                        <apex:actionRegion >
                            <c:AccountSearchComponent accData="{!theAcctSC}" id="acctSearch" rendered="{!acctCreate}" idOfSection="SGIconvertLead.accountFieldPanel"></c:AccountSearchComponent>
                        </apex:actionRegion>
                    </apex:pageBlockSection>
                </apex:outputPanel>
0

I bet it's an issue with the order of execution. Note that the constructor is getting called before the setter methods. Have a look at this answer and I hope that will give you a better understanding of how the order of execution works in VF.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.