• Mund
  • NEWBIE
  • 25 Points
  • Member since 2012

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 6
    Replies

Hello ,

 

Please help me with the code for the below page  Really in need of it.

I am having a pageblock table to display some information on the VF page. I need the rows that are being displayed in the pageblock table to be edited one by one on click of an edit button which will be available in each of the rows of the table

 

For example

Add row

office name    office address1  office state  

xyz                     address 1             state1                 del    edit

abc                    address 2            state 2                 del    edit

So on click of edit , that particular row has to be available for editing, (that is initially the values need to be set as non editable )

 

 The code what I have for displaying the page with Add  and delete link  is as below :

 

VF Page :

 

<apex:page controller="userMyInfoController" action="{!loadInfoDetails}" showHeader="false" sidebar="false" >

<apex:form >
<apex:outputLink value="{!$Site.Prefix}/secur/logout.jsp" rendered="{!NOT(ISPICKVAL($User.UserType,'Guest'))}">{!$Label.site.logout}</apex:outputLink>
<apex:pageBlock >
<apex:pageblock title="My Info">
<apex:pageblocksection title="Personal Details">
<apex:pageblocksectionitem >
    <apex:outputLabel for="txtUName">User Name</apex:outputLabel>
    <apex:inputText id="txtUName" value="{!objUser.Username}"/>
</apex:pageblocksectionitem>
<apex:pageblocksectionitem >
    <apex:outputLabel for="txtEmail">User Email</apex:outputLabel>
    <apex:inputText id="txtEmail" value="{!objUser.Email}"/>
</apex:pageblocksectionitem>
<apex:pageblocksectionitem >
    <apex:outputLabel for="txtLastName">Last Name</apex:outputLabel>
    <apex:inputText id="txtLastName" value="{!objUser.LastName}"/>
</apex:pageblocksectionitem>
</apex:pageblocksection>
<br> </br>

<apex:pageBlock mode="edit" title="Office Locations" id="OfficeLocations">

<!--Add more office locations-->
    <apex:commandLink value="Add Office Location" action="{!addOfficeLocation}"/> <br> </br>
    <apex:pageBlockTable columns="1" value="{!objOfficeLocations}" var="officeLoc" >
       <apex:column >
           <apex:outputLabel for="txtoffName"><b>Office Name</b></apex:outputLabel>&nbsp;
           <apex:inputText id="txtoffName" value="{!officeLoc.Office_Name__c}"/>
              
       </apex:column>
      
       <br> </br>
       <apex:column >
           <apex:outputLabel for="txtstate"><b>State</b></apex:outputLabel>&nbsp;
           <apex:inputText id="txtstate" value="{!officeLoc.Mailing_Address_State__c}"/>
       </apex:column>
       <apex:column >
           <apex:commandLink value="Delete" action="{!deleteOfficeLocation}" reRender="OfficeLocations">
                   <apex:param value="{!officeLoc.Office_Name__c}" name="delOfficeName"/>
            </apex:commandLink>
       </apex:column>
       <apex:column >
           <apex:commandLink value="Set as Primary" rendered="{!(NOT(officeLoc.Is_Office_Primary__c))}" action="{!changeOfficePrimary}"  >
               <apex:param value="{!officeLoc.Office_Name__c}" name="CurrentOfficeName"/>
            </apex:commandLink>
       </apex:column>
       </apex:pageBlockTable>
</apex:pageblock>

 

    </apex:pageblock>

</apex:pageBlock>
<apex:commandButton value="Save" action="{!SaveData}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlock>
</apex:form>

</apex:page>

 

and in controller, i have the logic to add office location:

 

// Add more office locations
public void addOfficeLocation(){

    objOfficeLocations.add(new QUOD_Office_Location__c(User_ID__c=UserInfo.getUserId()));
   
}

public pageReference saveData(){
   
    upsert objOfficeLocations;
    
    //Delete office locations from the database
    if(toDelOfficeLocations.size() > 0)
    {
        delete toDelOfficeLocations;
    }

 

public pageReference deleteOfficeLocation(){
    string OfficeName = ApexPages.CurrentPage().getParameters().get('delOfficeName');
    for(Integer i = 0; i < objOfficeLocations.size(); i++)
    {
        if((objOfficeLocations[i].Office_Name__c == OfficeName) ) //|| (objOfficeLocations.get(i).get('id') == OfficeName.get('id'))
            {
                toDelOfficeLocations.add(objOfficeLocations.remove(i));
            }
    }
   
    return null;
}

 

 

  • October 02, 2012
  • Like
  • 0

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.

  • September 25, 2012
  • Like
  • 0

Hi All,

 

I have 2 objects :

1. Standard object USERS

2. Custom object : Medical License

 

I need to have 1 to many relationship with medical license.

 

Limitations :

 

I cannot create master-detail relationship on medical license object with the user object.

 

 

I am creating a user and it is getting saved in the user object but when i want to save the user id in the medical license object as well.  how can i do it ? please help on this issue and please help me with a sample code.

 

 

Thanks

Mpm

  • September 13, 2012
  • Like
  • 0

Hi All,

 

I have a requirment in the VF page as :

required+Optional is a link and on clicking on which the 5 fields mentioned below need to be re rendered.

by default office name , Address 1 , city and state would be seen. After clicking on Required+optional link, the page should show Address2  and the link name should get changed to "Required Only". And another click on the          "Require Only" link should changed back to "Required+Optional" Can someone please help me with the code. All the fields are created in a object called Office Location.

 

                                 Required+optional

 


Office name

Address 1                                                                            -- This field will have to be shown only when link is clicked

Address 2

City

State

 

 

Thanks

Manju

  • September 12, 2012
  • Like
  • 0

Hi,

 

I have created a visual force page for registration and have added that under sites and have enabled self registration and customer portal as well. I am getting an error while using the authenticated site as

 

Error:

Username: Required fields are missing: [Username, Last Name, E-mail, Alias, Community Nickname, Time Zone, Locale, Email Encoding, Profile, Language].

 

I am using most of the standard SiteRegister functionality , and it works fine with SiteRegister page, but my custom visual force page is not working.

 

Please help me with the issue.

 

Thanks

Manju

  • September 11, 2012
  • Like
  • 0

Hi All,

 

In the standard "siteregister" visual force page registration page, i have to save the fields in 3 objects namely

1. User

2. medical license

3. Location

 

In my visual force page, I need to show multiple location values in the format ( basically columns appearing like rows).

There should be a custom link on the top with a (+) symbol and on clicking on it, another instance of the location containing office name, address city should be shown and when clicked on (-) symbol, it should remove the latest one added. Please help me with the code. I am really in urgent need of this code sample. Please Help. Thanks Mumd

 

Office location object which needs to be displayed on visual force page and saved in the object ( office location )

Please not that I need to display the columns one below the other , I am not sure we can use datatable for this. Please help me with some code examples. I need to display in the format as below. which are all input fields. I also need to have an option of adding similar set of fields when clicked on a custom link . basically need to add rows on a click of a link. Please Help on the issue.

 

office name :

 

address :

 

City :

 

All of them are input fields on the visual force page.

 

 

Please help me with the code

 

Cheers

Mund

  • September 10, 2012
  • Like
  • 0

Hi All,

 

In my visual force page registration page, , i have to save the fields displayed in 3 objects namely

1. User

2. medical license

3. Location

 

In my visual force page, I need to show multiple location values in the format ( basically columns appearing like rows).

There should be a custom link on the top with a (+) symbol and on clicking on it, another instance of the location containing office name, address city should be shown and when clicked on (-) symbol, it should remove the latest one added. Please help me with the code. I am really in urgent need of this code sample. Please Help. Thanks Mumd

 

Office location object which needs to be displayed on visual force page and saved in the object ( office location )

 

office name :

 

address :

 

City :

 

All of them are input fields on the visual force page.

 

 

Please help me with the code

 

Cheers

Mund

  • September 09, 2012
  • Like
  • 0

Hi All,

 

In my visual force page registration page, , i have to save the fields displayed in 3 objects namely

1. User

2. medical license

3. Location

 

In my visual force page, I need to show multiple location values in the format ( basically columns appearing like rows).

There should be a custom link on the top with a (+) symbol and on clicking on it, another instance of the location containing office name, address city should be shown and when clicked on (-) symbol, it should remove the latest one added. Please help me with the code. I am really in urgent need of this code sample. Please Help. Thanks Mumd

 

Office location object which needs to be displayed on visual force page and saved in the object ( office location )

 

office name :

 

address :

 

City :

 

All of them are input fields on the visual force page.

 

 

Please help me with the code

 

Cheers

Mund

  • September 09, 2012
  • Like
  • 0

Hi All,

 

In my visual force page registration page, , i have to save the fields displayed in 3 objects namely

1. User

2. medical license

3. Location

 

In my visual force page, I need to show multiple location values in the format ( basically columns appearing like rows).

There should be a custom link on the top with a (+) symbol and on clicking on it, another instance of the location containing office name, address city should be shown and when clicked on (-) symbol, it should remove the latest one added. Please help me with the code. I am really in urgent need of this code sample. Please Help. Thanks Mumd

 

Office location object which needs to be displayed on visual force page and saved in the object ( office location )

 

office name :

 

address :

 

City :

 

All of them are input fields on the visual force page.

 

 

Please help me with the code

 

Cheers

Mund

  • September 09, 2012
  • Like
  • 0

Hi All,

 

In my visual force page registration page, , i have to save the fields displayed in 3 objects namely

1. User

2. medical license

3. Location

 

In my visual force page, I need to show multiple location values in the format ( basically columns appearing like rows).

There should be a custom link on the top with a (+) symbol and on clicking on it, another instance of the location containing office name, address city should be shown and when clicked on (-) symbol, it should remove the latest one added. Please help me with the code. I am really in urgent need of this code sample. Please Help. Thanks Mumd

 

Office location object which needs to be displayed on visual force page and saved in the object ( office location )

 

office name :

 

address :

 

City :

 

All of them are input fields on the visual force page.

 

 

Please help me with the code

 

Cheers

Mund

  • September 09, 2012
  • Like
  • 0

Hi All,

 

In my visual force page registration page, , i have to save the fields displayed in 3 objects namely

1. User

2. medical license

3. Location

 

In my visual force page, I need to show multiple location values in the format ( basically columns appearing like rows).

There should be a custom link on the top with a (+) symbol and on clicking on it, another instance of the location containing office name, address city should be shown and when clicked on (-) symbol, it should remove the latest one added. Please help me with the code. I am really in urgent need of this code sample. Please Help. Thanks Mumd

 

Office location object which needs to be displayed on visual force page and saved in the object ( office location )

 

office name :

 

address :

 

City :

 

All of them are input fields on the visual force page.

 

 

Please help me with the code

 

Cheers

Mund

  • September 09, 2012
  • Like
  • 0

Hi All,

 

I have a requirment in the VF page as :

required+Optional is a link and on clicking on which the 5 fields mentioned below need to be re rendered.

by default office name , Address 1 , city and state would be seen. After clicking on Required+optional link, the page should show Address2  and the link name should get changed to "Required Only". And another click on the          "Require Only" link should changed back to "Required+Optional" Can someone please help me with the code. All the fields are created in a object called Office Location.

 

                                 Required+optional

 


Office name

Address 1                                                                            -- This field will have to be shown only when link is clicked

Address 2

City

State

 

 

Thanks

Manju

  • September 12, 2012
  • Like
  • 0