• Edweek Shane
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
Hi everyone,

I just spent a couple of hours trying to debug this one, and now that I have, I'm not sure why my solution is working...and that's just not very satisfying.

I'm populating the values of map<ID, map<string, double>> inside a loop.  I'll refer to this one as "outerMap", and map<string, double> as "innerMap."

First, I check for the existence of an ID in outerMap's keyset.  
- If it's there, I update the values in innerMap like this:  outerMap.get(ID).put(string, double)
- If it isn't there, I clear the values in innerMap, (re)populate the values, and then add the entry to outerMap like this:  outerMap.put(ID, innerMap)

The data I'm testing with makes it so that there are two objects in the list that have the same value for the ID I'm testing for, and one that has a different ID.  So, the loop runs like this:

[0] -- ID isn't found in outerMap's keyset.  Add an entry to outerMap.
[1] -- ID is found.  Update the existing entry in outerMap.
[2] -- ID isn't found.  Add an entry to outerMap.

Here's what I'm seeing:

[0] -- The entry is added with no problem.
[1] -- The entry is updated with no problem.
[2] -- When the entry is added, the values inside innerMap are the same as they were in [0], despite having been changed during this loop.  I can see in the debug logs that the values in innerMap have indeed been changed.  (That was freakin' maddening!) 

I put in a debug message just before the code that added the new entry to outerMap:  
system.debug('outerMap = ' + outerMap); 

During loop [0], the output was: outerMap = {ID_1={key_1=value_1, key_2=value_2, key_3=value_3}}
During loop [2], the output was: outerMap = {ID_1={key_1=value_1, key_2=value_2, key_3=value_3}, ID_2=(already output)}

It seems like what's happening is that, even though the values have changed, the fact that I'm using the same instance of innerMap as I did the first time through, is making it so that the values for the new outerMap key added in [2] are the same as the values for the outerMap key added in [0].  When I create a new instance of innerMap instead of using innerMap.clear(), everything works great...but I don't understand why.

Anyone care to help me out with a (now) strictly academic question? 


Hi everyone,

I just spent a couple of hours trying to debug this one, and now that I have, I'm not sure why my solution is working...and that's just not very satisfying.

I'm populating the values of map<ID, map<string, double>> inside a loop.  I'll refer to this one as "outerMap", and map<string, double> as "innerMap."

First, I check for the existence of an ID in outerMap's keyset.  
- If it's there, I update the values in innerMap like this:  outerMap.get(ID).put(string, double)
- If it isn't there, I clear the values in innerMap, (re)populate the values, and then add the entry to outerMap like this:  outerMap.put(ID, innerMap)

The data I'm testing with makes it so that there are two objects in the list that have the same value for the ID I'm testing for, and one that has a different ID.  So, the loop runs like this:

[0] -- ID isn't found in outerMap's keyset.  Add an entry to outerMap.
[1] -- ID is found.  Update the existing entry in outerMap.
[2] -- ID isn't found.  Add an entry to outerMap.

Here's what I'm seeing:

[0] -- The entry is added with no problem.
[1] -- The entry is updated with no problem.
[2] -- When the entry is added, the values inside innerMap are the same as they were in [0], despite having been changed during this loop.  I can see in the debug logs that the values in innerMap have indeed been changed.  (That was freakin' maddening!) 

I put in a debug message just before the code that added the new entry to outerMap:  
system.debug('outerMap = ' + outerMap); 

During loop [0], the output was: outerMap = {ID_1={key_1=value_1, key_2=value_2, key_3=value_3}}
During loop [2], the output was: outerMap = {ID_1={key_1=value_1, key_2=value_2, key_3=value_3}, ID_2=(already output)}

It seems like what's happening is that, even though the values have changed, the fact that I'm using the same instance of innerMap as I did the first time through, is making it so that the values for the new outerMap key added in [2] are the same as the values for the outerMap key added in [0].  When I create a new instance of innerMap instead of using innerMap.clear(), everything works great...but I don't understand why.

Anyone care to help me out with a (now) strictly academic question? 


Hi All,

 

    I have a requirement where in i need to print a field called Appointment ID in VisualForce Page.  This field should be displayed with hyperlink, so that when we click on this field link, we should navigate to that particular Appointment.  Could any one suggest a solution for this problem.

 

 

 

Thanks & Regards

 

Arun

Hi,

 

I'm redirecting to new visualforce page in my class.

created URL look like.

https://xxx.visual.force.com/apex/NewPage?TestValue=value1&retURL=a0HS000000450UD

 

I'm trying to get TestValue into my Visualforce Page...

code of Page is here..

 

<apex:page standardController="XXX__c" extensions="EEE_Test">
    <apex:form >
        <apex:pageBlock >
        <apex:pageBlockSection columns="1">
             <apex:inputField value="{!CurrentPage.parameters.TestValue}"/>
    </apex:pageBlockSection>
        </apex:pageBlock>  
    </apex:form>
    </apex:page>

 

I'm getting "Save error: Field parameters does not exist. Check spelling."  during saving this page.

 

Please suggest how to get value from the URL in page InputField?

 

I have created a new custom object as "Automobile__c"

 

for the same object i have created a page and a controller to insert new record in to the same.

 

Visualforce Page:

 

<apex:page Controller="VolunteerRegisterContr" > <apex:sectionHeader title="Customer Opportunity" subtitle="Step 1"/> <apex:form > <apex:pageBlock title="Customer Information" mode="edit"> <apex:pageBlockButtons > <apex:commandButton action="{!Save}" value="Save" immediate="true"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Registration"/> <table> <tr><td> <apex:outputLabel >Name</apex:outputLabel></td><td> <apex:inputField id="accountName" value="{!auto.Last_Name__c}" required="false" /></td></tr> <tr><td><apex:outputLabel >Street</apex:outputLabel> </td><td> <apex:inputField id="accountSite" value="{!auto.Street__c}"/></td></tr> <tr><td> <apex:outputLabel >Organization Name</apex:outputLabel> </td><td><apex:inputField id="contactFirstName" value="{!auto.Organization__c}"/></td> </tr><tr><td> <apex:outputLabel >Education</apex:outputLabel> </td> <td> <apex:inputField id="contactLastName" value="{!auto.Education__c}"/></td></tr></table> </apex:pageBlock> </apex:form> </apex:page>

 

 

 

Class

 

Public class VolunteerRegisterContr{ public ApexPages.StandardController controller; //Public Account acc{get; set;} Public Automobile__c auto{get; set;} Public String aName {get; set;} Public String aManufactureNamec {get; set;} Public String aLName {get; set;} Public String aStreet {get; set;} Public String aEdu {get; set;} public VolunteerRegisterContr(ApexPages.StandardController Controller) { auto=(Automobile__c)Controller.getRecord(); this.controller=Controller; } public VolunteerRegisterContr(){} public PageReference Save() { insert auto; return null; } }