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
MundMund 

display list in visual force page - ***URGENT****

Hi Everyone

 

I have created a user Registration page with 3 object

1. User   with custom fields like designation__c, Primary_Speciality__c, Additional_Speciality__c

2. Medical_license  with lookup field USER_ID__C to USER, Medical_License_Number__c, State__c

3. office_location  with lookup field USER_ID__C to USER and office address

 

I have 1 to Many relationship b/w user and Medical License and office location

that is 1 user = n medical license and so on

 

My Create/ Insert code using visual force page is  as below : Can I use the same controller which I have below for showing the same details for edit and adding any new medical license numbers or office address in the edit page.

 

Please help on this as I am stuck in this for quite some time. Please help me with the code.

 

Controller  :

 

public  with sharing class DemoRegExtn{

//Declare all the properties:
    Public boolean displayList {get;set;}
    public String name {get; set;}
    public String email {get; set;}
    public String password {get; set {password = value == null ? value : value.trim(); } }
    public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }
    public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }
    Public String AddlSpl1 {get;set;}
    Public String AddlSpl2 {get;set;}
    //public string desig {get; set;}
   public string designation {get; set;}

    public string primspl {get;set;}
    public string licensenum {get;set;}
    public string state {get;set;}
    public string medlic {get;set;}
    public string offname {get;set;}
    public string addr1 {get;set;}
    public string addr2 {get;set;}
    public string fax {get;set;}
    public string city {get;set;}
    public string prefix {get;set;}
    public string fname {get;set;}
    public string lname {get;set;}
    public string mini {get;set;}
    public List<Office_Location__c> offloc {get; set;}
    private List<Office_Location__c> offList = new List<Office_Location__c>();
    public String visible{get;set;}
    Public string visibleaddlspecl {get;set;}
    public string visiblemailaddr {get;set;}
    public string visibledeladdr {get;set;}
   
    String userId{get;set;}
   
   string yesorno ='true';
   public boolean disableDeliveryAddress{get;set;}
        
     private final ApexPages.StandardController userSupportController;
    
     public List<Office_Location__c> getOffList(){
        System.debug('--Inside get Office List--'+offList);
            return offList;
    }
    public void Del()
    {
        system.debug('selected row index---->'+selectedRowIndex);
        lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
        count = count - 1;
        
    }/*End del*/
     // PORTAL_ACCOUNT_ID is the account on which the contact will be created on and then enabled as a portal user.
        
    private static Id PORTAL_ACCOUNT_ID = '0019000000F9aBl';
    
     public List<medical_license__c>lstMLC  = new List<medical_license__c>();
        //list of the inner class
    public List<innerClass> lstInner
    {   get;set;    }
    
    //will indicate the row to be deleted
    public String selectedRowIndex
    {get;set;}  
    
    //no. of rows added/records in the inner class list
    public Integer count = 1;
    
       
    public void Adding()
    {   
    System.Debug('++++++++++++ INSIDE aDD METHOD++++++');
        count = count+1;
        addMore();      
    }
    
    public void Add()
    {   
    System.Debug('++++++++++++ INSIDE aDD METHOD++++++');
        count = count+1;
        addMore();      
    }
    
    //Add office location declaration
    
       public void Del6()
    {
        system.debug('selected row index---->'+selectedRowIndex6);
        if(Integer.valueOf(selectedRowIndex6) > 0)
        {
        lstInner6.remove(Integer.valueOf(selectedRowIndex6)-1);
        }
        offcount = offcount - 1;
        
    }/*End del6*/

    
    public List<Office_Location__c>lstOLC  = new List<Office_Location__c>();
        //list of the inner class
    public List<innerClass6> lstInner6
    {   get;set;    }
    
    //will indicate the row to be deleted
    public String selectedRowIndex6
    {get;set;}  
    
    //no. of rows added/records in the inner class list
    public Integer offcount = 1;
    
    public void Add6()
    {   
    System.Debug('++++++++++++ INSIDE aDD6 METHOD++++++');
        offcount = offcount+1;
        addMore6();      
    }
    
       
       private boolean isValidPassword() {
        return password == confirmPassword;
    }

    
    public pagereference mysave () {
    if (!isValidPassword()) {
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, Label.site.passwords_dont_match);
            ApexPages.addMessage(msg);
            return null;
        }    
        User u = new User();
        u.Username = lname;
        u.Email = email;
        u.CommunityNickname = lname;
        u.LastName = lname;
        u.Alias = lname;
       //u.Designation__c = designation;
        u.Primary_Specialty__c = primspl;
        u.Additional_Speciality1__c = AddlSpl1;
        u.Additional_Speciality2__c = AddlSpl2;
        
        Medical_License__c ml = new Medical_License__c();
        ml.Medical_License_Number__c = medlic ;
              
        Office_Location__c ol = new Office_Location__c();
        ol.Office_Name__c = offname ;
           
        String accountId = PORTAL_ACCOUNT_ID;
        System.debug('-------Create Portal User -------'+ lname);
        // lastName is a required field on user, but if it isn't specified, we'll default it to the username
        userId = Site.createPortalUser(u, accountId, password);
        System.debug('-------Inside medical license insert1-------'+userId);

        if (userId != null) {
           // if (password != null && password.length() > 1) {
                System.debug('-------Inside medical license list size-------'+ lstInner.size());
                
                 for(Integer j = 0;j<lstInner.size();j++)
                    {
                      medical_license__c  obj=((innerClass) lstInner[j]).MLC;
                      System.debug('-------Inside medical license insert2-------'+ userId);
                      
                        lstMLC.add(lstInner[j].MLC);
                            
                    }
                
        insert lstMLC;
        
        //adding the insert login for office address - starts
        
       for(Integer i = 0;i<lstInner6.size();i++)
        {
          Office_Location__c  obj=((innerClass6) lstInner6[i]).OLC;
          System.debug('-------Inside Office location -------'+ userId);
          
            lstOLC.add(lstInner6[i].OLC);
                
        }
       
        insert lstOLC;
        
        //adding the insert login for office address - ends


        
        System.debug('-------Inside medical license insert3-------'+ userId);
        
        for(medical_license__c mlin:lstMLC ){
           
            mlin.User_ID__c= userId ;
            System.debug('-------Inside medical license insert4-------'+ userId);
             update mlin;
            
             }
             
             //adding the update of userid in office location object - starts
            
             for(Office_Location__c olin:lstOLC ){
           
            olin.User_ID__c= userId ;
            System.debug('-------Inside office location -------'+ userId);
             update olin;
            
             }

             
             //adding the update of userid in office location object - ends
             
             //                return Site.login(username, password,null);
            System.debug('-------Page redirect to NovaLoginpage - hurray-------');

                return Site.login(lname,password,'/Novaloginpage');
                
           /* }
            else {
            
                 PageReference page = System.Page.SiteRegisterConfirm;
                page.setRedirect(true);
                return page;
            } */
        }
          System.debug('-------Page redirect to My info-------');
          
          string result = UserInfo.getUserId();
          System.debug('-------Page redirect to My info2-------'+result);




        PageReference pr = new PageReference('/Novaloginpage');
         pr.getParameters().put('userId', userId);
        pr.setRedirect(false);
       
        System.debug('-------Testing User Id-------'+ User.Id);
        
        string result1 = UserInfo.getUserId();
          System.debug('-------Page redirect to My info3-------'+result1);


        
         return pr;
           // return null;
        
     }    
   
     public void addMore()
    {
    
    System.Debug('#####inside addmore####');
//    count = count+1;
        //call to the iner class constructor
        innerClass objInnerClass = new innerClass(count);
        
        //add the record to the inner class list
        lstInner.add(objInnerClass);  
         
      
        system.debug('lstInner---->'+lstInner);            
    }/* end addMore*/
    
    
      public void addMore6()
    {
    
    System.Debug('#####inside addmore6####');
//    count = count+1;
        //call to the iner class constructor
        innerClass6 objInnerClass6 = new innerClass6(offcount);
        
        //add the record to the inner class list
        lstInner6.add(objInnerClass6);  
         
      
        system.debug('lstInner6---->'+lstInner6);            
    }/* end addMore*/

   // private final User usr;

    public DemoRegExtn (ApexPages.StandardController controller) {
    userSupportController = controller;
   // this.usr = (User)controller.getRecord();
   
   System.Debug('#####inside controller####');
    lstInner = new List<innerClass>();
        addMore();
        selectedRowIndex = '0';
   //---------------------------------
   lstInner6 = new List<innerClass6>();
        addMore6();
        selectedRowIndex6 = '0';

    
    offloc= new List<Office_Location__c>();
        offloc.add(new Office_Location__c());
    }
    
   /*Public boolean getRenderMedLic(){
      if (usr.Designation__c =='') {
      return true;
       } return false;
        
    }*/
    
    public PageReference Test(){
            visible = 'hi';
            return null;
        }
        
        public PageReference Test1(){
                     visible = 'hello';
                     return null;
                }
        
        public PageReference ShowHideAdditionalSpecialities(){
                     visibleaddlspecl = 'ShowAdditionalSpecialities';
                     return null;
                }
              
        public PageReference togglemailingaddress(){
                     visiblemailaddr = 'ShowRequiredOptionalMailAddr';
                     return null;
                }

        public PageReference togglemailingaddress1(){
                     visiblemailaddr = 'ShowRequiredMailAddr';
                     return null;
                }

       public PageReference toggledeladdress(){
                     visibledeladdr = 'ShowRequiredOptionaldelAddr';
                     return null;
                }

        public PageReference toggledeladdress1(){
                     visibledeladdr = 'ShowRequireddelAddr';
                     return null;
                }

       public List<SelectOption> getYesNo() {
        List<SelectOption> options = new List<SelectOption>();
         options.add(new SelectOption('true', 'Yes'));
         options.add(new SelectOption('false', 'No'));
        return options;
    }
    
       public string getyesorno(){
       return yesorno;
       }
       public void setyesorno(string yesorno){
       this.yesorno = yesorno;
       }
       

       public PageReference getdisableDeliveryAddress(){
        
        String devliveryValue=Apexpages.currentPage().getParameters().get('devliveryValue');

                system.debug('some value:'+devliveryValue);
                
               // Integer bs  = [SELECT count() FROM Incident_Approver__c where Site_Information__r.Name= :SiteName and Approver__c=:UserInfo.getUserId() and Division__c='EH&S Manager'];
                
                if(devliveryValue == 'false'){
                    
                    displayList = TRUE;
                  
                }
                else{
                  
                    displayList = FALSE;
                
                
                }
                
                return null;
        }

   public class innerClass
    {       
        /*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
        public String recCount
        {get;set;}
        
        
        public medical_license__c MLC
        {get;set;}
        
        /*Inner Class Constructor*/
        public innerClass(Integer intCount)
        {
            recCount = String.valueOf(intCount);        
            
            /*create a new account*/
            MLC= new medical_license__c();
            
        }/*End Inner class Constructor*/    
    }
    
    
    //this class is for office location
    
     public class innerClass6
    {       
        /*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
        public String recCount6
        {get;set;}
        
        
        public Office_Location__c OLC
        {get;set;}
        
        /*Inner Class Constructor*/
        public innerClass6(Integer intCount6)
        {
            recCount6 = String.valueOf(intCount6);        
            
            /*create a new account*/
            OLC= new Office_Location__c();
            
        }/*End Inner class Constructor*/    
    }
    
}

 

Thanks

Mund.