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
Manoprabha PalpandianManoprabha Palpandian 

Please Can Anyone help me i am creating a wrapper class this is correct or not ?

<apex:page controller="Registrationcontroller" id="theRepeat" sidebar="false" showHeader="true">
    <apex:form >
        <apex:pageBlock id="pg1" >
            <apex:messages />
            <apex:pageBlockSection columns="1" >
                <apex:inputField label="FirstName" value="{!reg1.FirstName__c}"/>
                <apex:inputField label="LastName" value="{!reg1.LastName__c}"/>
                <apex:inputField label="Email" value="{!reg1.Email__c}"/>
                <apex:inputField label="Hotel Commands" value="{!hotel.Hotel_Commands__c}"/>
                <apex:inputField label="Air Commands" value="{!air.Air_Commands__c}"/>
                <apex:inputField label="CheckInDate" value="{!hotel.Check_In_Date__c}"/>
                <apex:inputField label="CheckOutDate" value="{!hotel.Check_Out_Date__c}"/>
                <apex:inputField label="Arrival" value="{!air.Arrival__c}"/>
                <apex:inputField label="Departure" value="{!air.Departure__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="save" action="{!saveaction}" rerender="pg1,theTable" />
                
            </apex:pageBlockButtons> 
        </apex:pageBlock>
        <apex:pageBlock >
            <apex:dataTable value="{!registerlist}" var="regvalue" id="theTable" width="100%">
                <apex:facet name="caption">Registration List</apex:facet>
                <apex:column headerValue="Reg ID"><apex:outputText value="{!regvalue.Name}" /> </apex:column>
                <apex:column headerValue="FirstName"><apex:outputText value="{!regvalue.FirstName__c}" /> </apex:column>
                <apex:column headerValue="LastName"><apex:outputText value="{!regvalue.LastName__c}" /> </apex:column>
                <apex:column headerValue="Email"><apex:outputText value="{!regvalue.Email__c}" /> </apex:column>
                <apex:repeat value="{!regvalue.Hotels__r}" var="c">
                    <apex:column headerValue="Hotel ID"> <apex:outputText value="{!c.Name}"/></apex:column>
                    <apex:column headerValue="CheckInDate"> <apex:outputText value="{!c.Check_In_Date__c}"/></apex:column>
                    <apex:column headerValue="CheckOutDate"><apex:outputText value="{!c.Check_Out_Date__c}"/></apex:column>
                    <apex:column headerValue="Hotel Commands"><apex:outputText value="{!c.Hotel_Commands__c}"/></apex:column>
                </apex:repeat>
                <apex:repeat value="{!regvalue.AirTravels__r}" var="d">
                    <apex:column headerValue="Air ID"><apex:outputText value="{!d.Name}"/></apex:column>
                    <apex:column headerValue="Arrival"><apex:outputText value="{!d.Arrival__c}"/></apex:column>
                    <apex:column headerValue="Departure"><apex:outputText value="{!d.Departure__c}"/></apex:column>
                    <apex:column headerValue="Air Commands"><apex:outputText value="{!d.Air_Commands__c}"/></apex:column>
                </apex:repeat>
                <apex:column >
                    <apex:pageBlock>
                        <apex:pageBlockButtons>
                            <apex:commandButton action="{!ProcessSelected}" value="Show Selected accounts" reRender="block2"/>
                        </apex:pageBlockButtons>
                        <apex:pageBlockSection columns="2">
                            <apex:pageBlockTable value="{!wraplist}" var="wrapl">
                                <apex:column>
                                    <apex:facet name="header">
                                        <apex:inputCheckbox />
                                    </apex:facet>
                                    <apex:inputCheckbox value="{!wrapl.isSelected}" id="InputId"/>
                                </apex:column>
                                <apex:column value ="{!wrapl.reg4.Name}"/>
                                <apex:column value ="{!wrapl.reg4.FirstName__c}"/>
                                <apex:column value ="{!wrapl.reg4.LastName__c}"/>
                                <apex:column value ="{!wrapl.reg4.Email__c}"/>
                                <apex:repeat value="{!wrapl.Hotels__r}" var="hotelwrap">
                                    <apex:column value ="{!hotelwrap.reg4.Name}"/>
                                    <apex:column value ="{!hotelwrap.reg4.Check_In_Date__c}"/>
                                    <apex:column value ="{!hotelwrap.reg4.Check_Out_Date__c}"/>
                                    <apex:column value ="{!hotelwrap.reg4.Hotel_Commands__c}"/>
                                </apex:repeat>   
                                <apex:repeat value="{!wrapl.AirTravels__r}" var="airwrap"> 
                                    <apex:column value ="{!airwrap.reg4.Name}"/>
                                    <apex:column value ="{!airwrap.reg4.Arrival__c}"/>
                                    <apex:column value ="{!airwrap.reg4.Departure__c}"/>
                                    <apex:column value ="{!airwrap.reg4.Air_Commands__c}"/>
                                </apex:repeat>
                                
                            </apex:pageBlockTable>
                            <apex:pageBlockTable value="{!selectedRegistration}" var="sa" id="block2">
                                <apex:column value="{!sa.Name}"/>
                                <apex:column value="{!sa.FirstName}"/>
                                <apex:column value="{!sa.LastName}"/>
                                <apex:column value="{!sa.Email}"/>
                                <apex:repeat value="{!sa.Hotels__r}" var="hotelsa"> 
                                    <apex:column value="{!hotelsa.Name}"/>
                                    <apex:column value="{!hotelsa.Check_In_Date__c}"/>
                                    <apex:column value="{!hotelsa.Check_Out_Date__c}"/>
                                    <apex:column value="{!hotelsa.Hotel_Commands__c}"/>
                                </apex:repeat> 
                                <apex:repeat value="{!sa.AirTravels__r}" var="airsa"> 
                                    <apex:column value="{!airsa.Name}"/>
                                    <apex:column value="{!airsa.Arrival__c}"/>
                                    <apex:column value="{!airsa.Departure__c}"/>
                                    <apex:column value="{!airsa.Air_Commands__c}"/>
                                </apex:repeat> 
                           </apex:pageBlockTable>   
                        </apex:pageBlockSection>
                    </apex:pageBlock>
                    
                    <apex:commandLink value="Edit" action="{!editfunction}" rerender="pg1">
                        <apex:param name="cid" value="{!regvalue.id}" assignto="{!editid}"/>
                    </apex:commandLink> || 
                    <apex:commandLink value="Delete" action="{!deletefunction}" rerender="pg1,theTable">
                        <apex:param name="cid" value="{!regvalue.id}" assignto="{!editid}"/>
                    </apex:commandLink> 
                </apex:column>
            </apex:dataTable>
        </apex:pageBlock>
    </apex:form>         
</apex:page>




public class Registrationcontroller {
    public Registration1__c reg1 {get;set;}
    public String editid {get;set;}
    public Hotel__c hotel {get;set;}
    public AirTravel__c air {get;set;}
    public list<regwrapper> wraplist {get;set;}
    public list<Registration1__c> reglist {get;set;}
    public list<Hotel__c> hotellist {get;set;}
    public list<AirTravel__c> airlist {get;set;}
    public list<Registration1__c> selectedRegistration {get;set;}
    public Registrationcontroller()
    {
        reg1 = new Registration1__c();
        hotel = new Hotel__c();
        air = new AirTravel__c();
        
        if(wraplist == null)
        {
            wraplist = new list<regwrapper>();
            for(Registration1__c reg3:[SELECT id,Name,FirstName__c,LastName__c,Email__c, (SELECT Id,Name, Check_In_Date__c, Check_Out_Date__c, Hotel_Commands__c FROM Hotels__r),
                                       (SELECT Id,Name, Arrival__c, Departure__c, Air_Commands__c FROM AirTravels__r) FROM Registration1__c])
            {
                wraplist.add(new regwrapper(reg3));
                
            }
            
            
        }
        
        
        
    }
    
    public void processSelected(){
        selectedRegistration = new list<Registration1__c>();
        for(regwrapper wrapobj:Wraplist){
            if(wrapobj.isSelected==true)
            {
                selectedRegistration.add(wrapobj.reg4);
            }
        }
    }
    
    public class regwrapper{
        public Registration1__c reg4{get;set;}
        
        public boolean isSelected{get;set;}
        
        public regwrapper(Registration1__c reg3)
        {
            reg4 = reg3;
            isselected = false;
        }
                
    }
       
    public List<Registration1__c> getregisterlist(){
        List<Registration1__c> listreg= new List<Registration1__c>();
        listreg=[SELECT Id, Name, FirstName__c, LastName__c, Email__c, (SELECT Id,Name, Check_In_Date__c, Check_Out_Date__c, Hotel_Commands__c FROM Hotels__r),
                 (SELECT Id,Name, Arrival__c, Departure__c, Air_Commands__c FROM AirTravels__r) FROM Registration1__c];
        return listreg;
    }
    public void editfunction() {
        system.debug('editfunction inside===>'+editid);
        reg1=[SELECT Id,Name, FirstName__c, LastName__c, Email__c, (SELECT Id,Name, Check_In_Date__c, Check_Out_Date__c, Hotel_Commands__c FROM Hotels__r),
              (SELECT Id,Name, Arrival__c, Departure__c, Air_Commands__c FROM AirTravels__r)
              FROM Registration1__c where id=:editid];
        
        
    }
    public void deletefunction() {
        system.debug('editfunction inside===>'+editid);
        
        List<Registration1__c>  reg2=[SELECT Id, Name, FirstName__c, LastName__c, Email__c
                                      FROM Registration1__c  where id=:editid];
        delete reg2;
        ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.INFO,'Record deleted successfully'));
    }
    
    
    public void saveaction()
    {
        system.debug('saveaction inside===>'+reg1);
        try{
            upsert reg1;
            if(reg1.Id !=null){
                ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.INFO,'Record saved successfully'));
                
                if(hotel != null)
                {
                    hotel.Registration1__c = reg1.id;
                    upsert hotel;
                }
                if(air != null)
                {
                    air.Registration1__c = reg1.id;
                    upsert air;
                }
                
            } else
            {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.ERROR,'Record not saved')); 
            }
            reg1 = new Registration1__c();
            hotel = new Hotel__c();
            air = new AirTravel__c();
        }
        Catch(Exception e)  
        {
            System.debug(e.getMessage());
        }
    }
}



Please help me its very urgent .
It showing an one error - Unknown property 'Registrationcontroller.regwrapper.Hotels__r'