• water
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Hello all -

 

I am trying to render a multi-level Map consisting of a single custom type (ProjectView objects) in my visualforce page.  The multi-level Map's structure is as follows:  Map<ProjectView, Map<ProjectView, List<ProjectView>>>

 

My visualforce page renders the multi-level Map successfully when only one key is present at each level (i.e., one key at Map<ProjectView, ...>>> and one key at Map<..., Map<ProjectView, ...>>>.  I receive an error message when I introduce more than one key at either level in the Map.  The visualforce error is as follows:  "This map cannot be used in an iteration because the keys cannot be sorted."

 

I provide an implementation of the equals method and the hashCode method, as instructed in the salesforce documentation article "Using Custom Types in Map Keys and Sets" (link: Using Custom Types in Map Keys and Sets).

 

My implementation of the equals method:

public Boolean equals(Object obj) {
        System.debug('=== entered the equals method...');
        // Your implementation
        if (obj instanceof ProjectView) {
            ProjectView p = (ProjectView)obj;
            System.debug('=== equals method: (projViewId == p.projViewId) ' + (projViewId == p.projViewId));
            System.debug('=== equals method: (p.projViewId == projViewId) ' + (p.projViewId == projViewId));
            System.debug('=== equals method: projViewId = ' + projViewId + ', p.projViewId = ' + p.projViewId);
            return (projViewId == p.projViewId);
        }
        System.debug('=== equals method: obj is NOT an instance of ProjectView...');
        return false;
    }

 My implementation of the hashCode method:

public Integer hashCode() {
        // Your implementation
        System.debug('=== this.projViewId.hashCode(): ' + this.projViewId.hashCode());
        System.debug('=== projViewId.hashCode(): ' + projViewId.hashCode());
        System.debug('=== *this* keyword in the hashCode() method: ' + this);
        return this.projViewId.hashCode(); 
/**
each ProjectView object corresponds to a single source custom object record in the salesforce database; projViewId corresponds to the source record's unique 18-digit salesforce Id, so I assume this is guaranteed to be unique for every ProjectView object
**/ }

 

According to the debug logs, it appears multiple keys at either level in the Map are added to the Map successfully and are accessible/retrievable when I run the following lines of code (projectSubProjectMap.keySet() corresponds to all of the keys in the second-level Map corresponding to a single key in the first-level/outer Map):

 

Set<ProjectView> keysInSubMap = new Set<ProjectView>();

// the following variable assignment line prints out the multiple keys to the debug log, as I expect

 

keysInSubMap = projectSubProjectMap.keySet();

// the debug log printout of the above line's variable_assignment (notice two keys are present-- Proj-12483, Proj-12480):

 

VARIABLE_ASSIGNMENT|[206]|keysInSubMap|{"serId":1,"value":[{"projId":"a1LR00000002NX9MAM","projName":"Proj-12483","projProjectTitle":"PROJECT 2","projViewId":"a1LR00000002NX9MAM"},{"projId":"a1LR00000002NM0MAM","projName":"Proj-12480","projProjectTitle":"testing","projViewId":"a1LR00000002NM0MAM"}]}|0x3a31daa0

// the following line, however, prints out only one of the multiple keys to the debug log, whereas I expect it to print out all of the multiple keys...

 

System.debug('=== List of all the keys in the sub Map: ' + keysInSubMap);

// the debug log printout of the above line (notice only one key is present-- Proj-12483 --where I expect two keys to be present):

 

USER_DEBUG|[207]|DEBUG|=== List of all the keys in the sub Map: {ProjectView:[compType=null, componentDueDate=null, componentGcEndDate=null, componentGcStartDate=null, componentId=null, componentName=null, gcActive=null, gcConsultantType=null, gcCurrentlyEmployed=null, gcId=null, gcName=null, gcProjCount=null, gcSubProjCount=null, projCdGrants=null, projCdResearch=null, projId=a1LR00000002NX9MAM, projInternalDueDate=null, projMcd=null, projName=Proj-12483, projProjectTitle=PROJECT 2, projViewId=a1LR00000002NX9MAM, projectCount=null, userId=null, userName=null]}

 
Interestingly, when I comment out my visualforce page's html responsible for rendering the returned multi-level Map, and simply reference the multi-level Map using {!ConsultantsX} (the method in my controller class responsible for returning the multi-level Map is getConsultantsX()), the visualforce page renders the following--

 

{ProjectView=common.apex.runtime.impl.MapValue@81a39192, ProjectView=common.apex.runtime.impl.MapValue@764147e4, ProjectView=common.apex.runtime.impl.MapValue@320bcc0e}

 

--which I assume corresponds to the three unique keys that I expect to be present at the main-level/outermost returned Map (the eight-character MapValue@ changes with every refresh of the visualforce page; the three MapValue@s rendered are always unique, so I'm thinking the visualforce page recognizes to some extent the outermost Map's multiple unique keys)...

 

I think I may (though I could be completely wrong) have run into a possible bug which would require salesforce.com to address via a patch or something...  I came across a somewhat similar, known issue that salesforce.com recently addressed (involved Maps with Id used as the key):  Maps with ID used as the key cannot be used in an iteration and fail with error 'This map cannot be used in an iteration because the keys cannot be so...

 

I would appreciate some guidance.  Please let me know if there is anything else I should provide in order to present a clearer picture of this matter.  Thank you in advance!

 

  • July 09, 2013
  • Like
  • 1

Hello all -

 

I am trying to render a multi-level Map consisting of a single custom type (ProjectView objects) in my visualforce page.  The multi-level Map's structure is as follows:  Map<ProjectView, Map<ProjectView, List<ProjectView>>>

 

My visualforce page renders the multi-level Map successfully when only one key is present at each level (i.e., one key at Map<ProjectView, ...>>> and one key at Map<..., Map<ProjectView, ...>>>.  I receive an error message when I introduce more than one key at either level in the Map.  The visualforce error is as follows:  "This map cannot be used in an iteration because the keys cannot be sorted."

 

I provide an implementation of the equals method and the hashCode method, as instructed in the salesforce documentation article "Using Custom Types in Map Keys and Sets" (link: Using Custom Types in Map Keys and Sets).

 

My implementation of the equals method:

public Boolean equals(Object obj) {
        System.debug('=== entered the equals method...');
        // Your implementation
        if (obj instanceof ProjectView) {
            ProjectView p = (ProjectView)obj;
            System.debug('=== equals method: (projViewId == p.projViewId) ' + (projViewId == p.projViewId));
            System.debug('=== equals method: (p.projViewId == projViewId) ' + (p.projViewId == projViewId));
            System.debug('=== equals method: projViewId = ' + projViewId + ', p.projViewId = ' + p.projViewId);
            return (projViewId == p.projViewId);
        }
        System.debug('=== equals method: obj is NOT an instance of ProjectView...');
        return false;
    }

 My implementation of the hashCode method:

public Integer hashCode() {
        // Your implementation
        System.debug('=== this.projViewId.hashCode(): ' + this.projViewId.hashCode());
        System.debug('=== projViewId.hashCode(): ' + projViewId.hashCode());
        System.debug('=== *this* keyword in the hashCode() method: ' + this);
        return this.projViewId.hashCode(); 
/**
each ProjectView object corresponds to a single source custom object record in the salesforce database; projViewId corresponds to the source record's unique 18-digit salesforce Id, so I assume this is guaranteed to be unique for every ProjectView object
**/ }

 

According to the debug logs, it appears multiple keys at either level in the Map are added to the Map successfully and are accessible/retrievable when I run the following lines of code (projectSubProjectMap.keySet() corresponds to all of the keys in the second-level Map corresponding to a single key in the first-level/outer Map):

 

Set<ProjectView> keysInSubMap = new Set<ProjectView>();

// the following variable assignment line prints out the multiple keys to the debug log, as I expect

 

keysInSubMap = projectSubProjectMap.keySet();

// the debug log printout of the above line's variable_assignment (notice two keys are present-- Proj-12483, Proj-12480):

 

VARIABLE_ASSIGNMENT|[206]|keysInSubMap|{"serId":1,"value":[{"projId":"a1LR00000002NX9MAM","projName":"Proj-12483","projProjectTitle":"PROJECT 2","projViewId":"a1LR00000002NX9MAM"},{"projId":"a1LR00000002NM0MAM","projName":"Proj-12480","projProjectTitle":"testing","projViewId":"a1LR00000002NM0MAM"}]}|0x3a31daa0

// the following line, however, prints out only one of the multiple keys to the debug log, whereas I expect it to print out all of the multiple keys...

 

System.debug('=== List of all the keys in the sub Map: ' + keysInSubMap);

// the debug log printout of the above line (notice only one key is present-- Proj-12483 --where I expect two keys to be present):

 

USER_DEBUG|[207]|DEBUG|=== List of all the keys in the sub Map: {ProjectView:[compType=null, componentDueDate=null, componentGcEndDate=null, componentGcStartDate=null, componentId=null, componentName=null, gcActive=null, gcConsultantType=null, gcCurrentlyEmployed=null, gcId=null, gcName=null, gcProjCount=null, gcSubProjCount=null, projCdGrants=null, projCdResearch=null, projId=a1LR00000002NX9MAM, projInternalDueDate=null, projMcd=null, projName=Proj-12483, projProjectTitle=PROJECT 2, projViewId=a1LR00000002NX9MAM, projectCount=null, userId=null, userName=null]}

 
Interestingly, when I comment out my visualforce page's html responsible for rendering the returned multi-level Map, and simply reference the multi-level Map using {!ConsultantsX} (the method in my controller class responsible for returning the multi-level Map is getConsultantsX()), the visualforce page renders the following--

 

{ProjectView=common.apex.runtime.impl.MapValue@81a39192, ProjectView=common.apex.runtime.impl.MapValue@764147e4, ProjectView=common.apex.runtime.impl.MapValue@320bcc0e}

 

--which I assume corresponds to the three unique keys that I expect to be present at the main-level/outermost returned Map (the eight-character MapValue@ changes with every refresh of the visualforce page; the three MapValue@s rendered are always unique, so I'm thinking the visualforce page recognizes to some extent the outermost Map's multiple unique keys)...

 

I think I may (though I could be completely wrong) have run into a possible bug which would require salesforce.com to address via a patch or something...  I came across a somewhat similar, known issue that salesforce.com recently addressed (involved Maps with Id used as the key):  Maps with ID used as the key cannot be used in an iteration and fail with error 'This map cannot be used in an iteration because the keys cannot be so...

 

I would appreciate some guidance.  Please let me know if there is anything else I should provide in order to present a clearer picture of this matter.  Thank you in advance!

 

  • July 09, 2013
  • Like
  • 1

Hello all -

 

I am trying to render a multi-level Map consisting of a single custom type (ProjectView objects) in my visualforce page.  The multi-level Map's structure is as follows:  Map<ProjectView, Map<ProjectView, List<ProjectView>>>

 

My visualforce page renders the multi-level Map successfully when only one key is present at each level (i.e., one key at Map<ProjectView, ...>>> and one key at Map<..., Map<ProjectView, ...>>>.  I receive an error message when I introduce more than one key at either level in the Map.  The visualforce error is as follows:  "This map cannot be used in an iteration because the keys cannot be sorted."

 

I provide an implementation of the equals method and the hashCode method, as instructed in the salesforce documentation article "Using Custom Types in Map Keys and Sets" (link: Using Custom Types in Map Keys and Sets).

 

My implementation of the equals method:

public Boolean equals(Object obj) {
        System.debug('=== entered the equals method...');
        // Your implementation
        if (obj instanceof ProjectView) {
            ProjectView p = (ProjectView)obj;
            System.debug('=== equals method: (projViewId == p.projViewId) ' + (projViewId == p.projViewId));
            System.debug('=== equals method: (p.projViewId == projViewId) ' + (p.projViewId == projViewId));
            System.debug('=== equals method: projViewId = ' + projViewId + ', p.projViewId = ' + p.projViewId);
            return (projViewId == p.projViewId);
        }
        System.debug('=== equals method: obj is NOT an instance of ProjectView...');
        return false;
    }

 My implementation of the hashCode method:

public Integer hashCode() {
        // Your implementation
        System.debug('=== this.projViewId.hashCode(): ' + this.projViewId.hashCode());
        System.debug('=== projViewId.hashCode(): ' + projViewId.hashCode());
        System.debug('=== *this* keyword in the hashCode() method: ' + this);
        return this.projViewId.hashCode(); 
/**
each ProjectView object corresponds to a single source custom object record in the salesforce database; projViewId corresponds to the source record's unique 18-digit salesforce Id, so I assume this is guaranteed to be unique for every ProjectView object
**/ }

 

According to the debug logs, it appears multiple keys at either level in the Map are added to the Map successfully and are accessible/retrievable when I run the following lines of code (projectSubProjectMap.keySet() corresponds to all of the keys in the second-level Map corresponding to a single key in the first-level/outer Map):

 

Set<ProjectView> keysInSubMap = new Set<ProjectView>();

// the following variable assignment line prints out the multiple keys to the debug log, as I expect

 

keysInSubMap = projectSubProjectMap.keySet();

// the debug log printout of the above line's variable_assignment (notice two keys are present-- Proj-12483, Proj-12480):

 

VARIABLE_ASSIGNMENT|[206]|keysInSubMap|{"serId":1,"value":[{"projId":"a1LR00000002NX9MAM","projName":"Proj-12483","projProjectTitle":"PROJECT 2","projViewId":"a1LR00000002NX9MAM"},{"projId":"a1LR00000002NM0MAM","projName":"Proj-12480","projProjectTitle":"testing","projViewId":"a1LR00000002NM0MAM"}]}|0x3a31daa0

// the following line, however, prints out only one of the multiple keys to the debug log, whereas I expect it to print out all of the multiple keys...

 

System.debug('=== List of all the keys in the sub Map: ' + keysInSubMap);

// the debug log printout of the above line (notice only one key is present-- Proj-12483 --where I expect two keys to be present):

 

USER_DEBUG|[207]|DEBUG|=== List of all the keys in the sub Map: {ProjectView:[compType=null, componentDueDate=null, componentGcEndDate=null, componentGcStartDate=null, componentId=null, componentName=null, gcActive=null, gcConsultantType=null, gcCurrentlyEmployed=null, gcId=null, gcName=null, gcProjCount=null, gcSubProjCount=null, projCdGrants=null, projCdResearch=null, projId=a1LR00000002NX9MAM, projInternalDueDate=null, projMcd=null, projName=Proj-12483, projProjectTitle=PROJECT 2, projViewId=a1LR00000002NX9MAM, projectCount=null, userId=null, userName=null]}

 
Interestingly, when I comment out my visualforce page's html responsible for rendering the returned multi-level Map, and simply reference the multi-level Map using {!ConsultantsX} (the method in my controller class responsible for returning the multi-level Map is getConsultantsX()), the visualforce page renders the following--

 

{ProjectView=common.apex.runtime.impl.MapValue@81a39192, ProjectView=common.apex.runtime.impl.MapValue@764147e4, ProjectView=common.apex.runtime.impl.MapValue@320bcc0e}

 

--which I assume corresponds to the three unique keys that I expect to be present at the main-level/outermost returned Map (the eight-character MapValue@ changes with every refresh of the visualforce page; the three MapValue@s rendered are always unique, so I'm thinking the visualforce page recognizes to some extent the outermost Map's multiple unique keys)...

 

I think I may (though I could be completely wrong) have run into a possible bug which would require salesforce.com to address via a patch or something...  I came across a somewhat similar, known issue that salesforce.com recently addressed (involved Maps with Id used as the key):  Maps with ID used as the key cannot be used in an iteration and fail with error 'This map cannot be used in an iteration because the keys cannot be so...

 

I would appreciate some guidance.  Please let me know if there is anything else I should provide in order to present a clearer picture of this matter.  Thank you in advance!

 

  • July 09, 2013
  • Like
  • 1

 

 

PageReference pr = Site.login(emailAddress,p.regPassword,'/PersonalDetails');

 

 

Above piece of code generates following URL

 

 

https://zebra.force.com/asia/secur/frontdoor.jsp?cshc=0000000xrYf0000000HGIN&portalId=060T00000004f1h&refURL=https%253A%252F%252Fzebra ....

 

 

On debugging, I found that an extra "25" is added at multiple locations. If I remove all the instances of "25", it works perfectly fine and I am able to login to customer portal

Correct URL

https://zebra.force.com/asia/secur/frontdoor.jsp?cshc=0000000xrYf0000000HGIN&portalId=060T00000004f1h&refURL=http%3A%2%2Fzebra...                                    

 

What can be the reason for this extra "25"?
Anything specific to user locale? (Current Locale : United Kingdom)