Skip to main content
Slight code reformat
Source Link
Keith C
  • 137.3k
  • 29
  • 218
  • 458

//This method loads all the instances for a page private void loadInstances() {

//This method loads all the instances for a page
private void loadInstances() {
       
    instancesMap =  new Map<Id, sObject>([SELECT Id, Name, Value__c, Type__C, content__c FROM sObject);
    //debug account ...
  
    for (sObject items: instancesMap.values()) {
        
        subClassObject subItem = new subClassObject(items.Name);

        subItem.Id = Item.Id;
        
                    
        if (items.Type__c.equals('Picklist') || adi.Type__c.equals('Multipicklist')) {
            
            subItem.pickList = createLists(content__c); //generates selection list based on values
        }
        
       if (item.Type__c.equals('String'))    
        {
            subItem.value = Item.value__c'
        }          
    }

}
// This method adds an instance from a selection list which the user chooses in the UI
public void addItem() {
    
    for (String id : selectedInstances) {
        
        //creates new sublcass object and adds it to the instanceMap
            
            instanceMap.put(subItem.Name, subItem);
           
            
        }
    }

}
public PageReference save() {
    Account account = (Account) controller.getRecord();
    List<sObject> sObjectList = new List<sObject>();
    subClass subItem; 
    for (subClass subItem : InstanceMap.Values()) {
        //Set all the fields for the sObject
        sObjectList.add(subItem);
    }

    upsert detailInstanceList;
    
    return ApexPages.currentPage();

}

//This method loads all the instances for a page private void loadInstances() {

    instancesMap =  new Map<Id, sObject>([SELECT Id, Name, Value__c, Type__C, content__c FROM sObject);
    //debug account ...
  
    for (sObject items: instancesMap.values()) {
        
        subClassObject subItem = new subClassObject(items.Name);

        subItem.Id = Item.Id;
        
                    
        if (items.Type__c.equals('Picklist') || adi.Type__c.equals('Multipicklist')) {
            
            subItem.pickList = createLists(content__c); //generates selection list based on values
        }
        
       if (item.Type__c.equals('String'))    
        {
            subItem.value = Item.value__c'
        }          
    }

}
// This method adds an instance from a selection list which the user chooses in the UI
public void addItem() {
    
    for (String id : selectedInstances) {
        
        //creates new sublcass object and adds it to the instanceMap
            
            instanceMap.put(subItem.Name, subItem);
           
            
        }
    }

}
public PageReference save() {
    Account account = (Account) controller.getRecord();
    List<sObject> sObjectList = new List<sObject>();
    subClass subItem; 
    for (subClass subItem : InstanceMap.Values()) {
        //Set all the fields for the sObject
        sObjectList.add(subItem);
    }

    upsert detailInstanceList;
    
    return ApexPages.currentPage();

}
//This method loads all the instances for a page
private void loadInstances() {
       
    instancesMap =  new Map<Id, sObject>([SELECT Id, Name, Value__c, Type__C, content__c FROM sObject);
    //debug account ...
  
    for (sObject items: instancesMap.values()) {
        
        subClassObject subItem = new subClassObject(items.Name);

        subItem.Id = Item.Id;
        
                    
        if (items.Type__c.equals('Picklist') || adi.Type__c.equals('Multipicklist')) {
            
            subItem.pickList = createLists(content__c); //generates selection list based on values
        }
        
       if (item.Type__c.equals('String'))    
        {
            subItem.value = Item.value__c'
        }          
    }

}
// This method adds an instance from a selection list which the user chooses in the UI
public void addItem() {
    
    for (String id : selectedInstances) {
        
        //creates new sublcass object and adds it to the instanceMap
            
            instanceMap.put(subItem.Name, subItem);
           
            
        }
    }

}
public PageReference save() {
    Account account = (Account) controller.getRecord();
    List<sObject> sObjectList = new List<sObject>();
    subClass subItem; 
    for (subClass subItem : InstanceMap.Values()) {
        //Set all the fields for the sObject
        sObjectList.add(subItem);
    }

    upsert detailInstanceList;
    
    return ApexPages.currentPage();

}
added 1663 characters in body
Source Link
ths
  • 111
  • 1
  • 10

//This method loads all the instances for a page private void loadInstances() {

    instancesMap =  new Map<Id, sObject>([SELECT Id, Name, Value__c, Type__C, content__c FROM sObject);
    //debug account ...
  
    for (sObject items: instancesMap.values()) {
        
        subClassObject subItem = new subClassObject(items.Name);

        subItem.Id = Item.Id;
        
                    
        if (items.Type__c.equals('Picklist') || adi.Type__c.equals('Multipicklist')) {
            
            subItem.pickList = createLists(content__c); //generates selection list based on values
        }
        
       if (item.Type__c.equals('String'))    
        {
            subItem.value = Item.value__c'
        }          
    }

}
// This method adds an instance from a selection list which the user chooses in the UI
public void addItem() {
    
    for (String id : selectedInstances) {
        
        //creates new sublcass object and adds it to the instanceMap
            
            instanceMap.put(subItem.Name, subItem);
           
            
        }
    }

}
public PageReference save() {
    Account account = (Account) controller.getRecord();
    List<sObject> sObjectList = new List<sObject>();
    subClass subItem; 
    for (subClass subItem : InstanceMap.Values()) {
        //Set all the fields for the sObject
        sObjectList.add(subItem);
    }

    upsert detailInstanceList;
    
    return ApexPages.currentPage();

}

//This method loads all the instances for a page private void loadInstances() {

    instancesMap =  new Map<Id, sObject>([SELECT Id, Name, Value__c, Type__C, content__c FROM sObject);
    //debug account ...
  
    for (sObject items: instancesMap.values()) {
        
        subClassObject subItem = new subClassObject(items.Name);

        subItem.Id = Item.Id;
        
                    
        if (items.Type__c.equals('Picklist') || adi.Type__c.equals('Multipicklist')) {
            
            subItem.pickList = createLists(content__c); //generates selection list based on values
        }
        
       if (item.Type__c.equals('String'))    
        {
            subItem.value = Item.value__c'
        }          
    }

}
// This method adds an instance from a selection list which the user chooses in the UI
public void addItem() {
    
    for (String id : selectedInstances) {
        
        //creates new sublcass object and adds it to the instanceMap
            
            instanceMap.put(subItem.Name, subItem);
           
            
        }
    }

}
public PageReference save() {
    Account account = (Account) controller.getRecord();
    List<sObject> sObjectList = new List<sObject>();
    subClass subItem; 
    for (subClass subItem : InstanceMap.Values()) {
        //Set all the fields for the sObject
        sObjectList.add(subItem);
    }

    upsert detailInstanceList;
    
    return ApexPages.currentPage();

}
added 54 characters in body
Source Link
ths
  • 111
  • 1
  • 10

I do not understand why my values keep getting switched. I think it assigns the value of the first input value box to the first item added and the value fields are not in order of the objects.

<apex <apex:outputPanel id="OutputBox"> <apex:inputText value="{!...}" rendered="{!OR(contains(...), contains(...))}"> </apex:inputText>

            <apex:inputCheckbox value="{!...}" rendered="{!contains(...)}">
            </apex:inputCheckbox>

            <apex:SelectList rendered="{!contains(...)}" size="1" value="{!...}">
                <apex:SelectOptions value="{!picklist}" />
            </apex:SelectList>

               
 </apex:outputPanel>
     //
     Sample Output First Save</apex:outputPanel>
     //

Sample Output when initially added

     Name          Value
     
     Object2        55   // Added Second datatype: String
     Object1        33   //Added First datatype: String
     
     Output after save button is clicked once
     
     Object1        33   
     Object2        55   
     

Output after clicking the save button is clicked again with no change, the values get switchedwill keep switching.

     Object2   Object1     33   //55 Added Second datatype: String
     Object1      Object2  55   //Added First datatype: String33
     
     //

Object are stored in a Map which is changed to a list using map.value() for displaying:

The list is of the subclass objects from below. public class AccountDetailInstance {

    public List<SelectOption> pickList {get; set;}
    public String textValue {get; set;}
    
    
 }
 

The list is saved into the salesforce object by duplicating the values and the list gets regenerated based off of the salesforce objects that were saved everytime.

I do not understand why my values keep getting switched. I think it assigns the value of the first input value box to the first item added and the value fields are not in order of the objects.

<apex:outputPanel id="OutputBox"> <apex:inputText value="{!...}" rendered="{!OR(contains(...), contains(...))}"> </apex:inputText>

        <apex:inputCheckbox value="{!...}" rendered="{!contains(...)}">
        </apex:inputCheckbox>

        <apex:SelectList rendered="{!contains(...)}" size="1" value="{!...}">
            <apex:SelectOptions value="{!picklist}" />
        </apex:SelectList>

               
 </apex:outputPanel>
     //
     Sample Output First Save
     
     Name          Value
     
     Object2        55   // Added Second datatype: String
     Object1        33   //Added First datatype: String
     

Output after save button is clicked again with no change, values get switched.

     Object2        33   // Added Second datatype: String
     Object1        55   //Added First datatype: String
     
     //

Object are stored in a Map which is changed to a list using map.value() for displaying:

I do not understand why my values keep getting switched. I think it assigns the value of the first input value box to the first item added and the value fields are not in order of the objects. <apex:outputPanel id="OutputBox"> <apex:inputText value="{!...}" rendered="{!OR(contains(...), contains(...))}"> </apex:inputText>

            <apex:inputCheckbox value="{!...}" rendered="{!contains(...)}">
            </apex:inputCheckbox>

            <apex:SelectList rendered="{!contains(...)}" size="1" value="{!...}">
                <apex:SelectOptions value="{!picklist}" />
            </apex:SelectList>

                   
     </apex:outputPanel>
     //

Sample Output when initially added

     Name          Value
     
     Object2        55   // Added Second datatype: String
     Object1        33   //Added First datatype: String
     
     Output after save button is clicked once
     
     Object1        33   
     Object2        55   
     

Output after clicking the save button again, the values will keep switching.

     Object1        55   
     Object2        33
     
     //

Object are stored in a Map which is changed to a list using map.value() for displaying:

The list is of the subclass objects from below. public class AccountDetailInstance {

    public List<SelectOption> pickList {get; set;}
    public String textValue {get; set;}
    
    
 }
 

The list is saved into the salesforce object by duplicating the values and the list gets regenerated based off of the salesforce objects that were saved everytime.

Source Link
ths
  • 111
  • 1
  • 10
Loading