You need to sign in to do that
Don't have an account?

Urgent-----Help required on using map on VF using apex:repeat?
Hi,
I need a help on using Map on VF page .
public Map<Integer, String> bucketOrderMap{get;set;}
String bucketQuery = 'select Id, Name, Tutorial_Bucket_Unique_Name__c, Sort_Order__c from Tutorial_Bucket_Order__c where Name like \''+ tCategory.getName() +'\'';// and sort_order__c >='+ (currentBucket.sort_order__c - 1) + ' and sort_order__c <= '+currentBucket.sort_order__c + 1 ;
bucketOrderMap = new Map<Integer, String>();
for(Tutorial_Bucket_Order__c curr:Database.query(bucketQuery)) {
bucketOrderMap.put(Integer.valueOf(curr.sort_order__c), curr.Tutorial_Bucket_Unique_Name__c);
}
ON VF=========
<ul>
<apex:repeat value="{!bucketOrderMap}" var="c">
<apex:outputLabel value="{!c.Label}" />
<!-- <li id="buck_{!c.}">{!c.Label}</li> -->
</apex:repeat>
</ul>
In Vf page i got prob. can any body help me how to do it on this withour <apex:pageblock table>
thanks,
kp
Hello,
As a rule, a map is not sorted. Event though you put the order as the key in a map, it will be traversed randomly only.
If you need to maintain the order, use lists and sort in the soql query itself.
and in VF page
This should give you the list sorted. Please make sure of any syntax errors / variable naming errors before running this.
Hope this helps.
Regards,
Ritika
All Answers
Though am not sure what exactly you want to ask. But I have prepared a sample for you, please use this and let me know if it doesn't resolves your problem.
VFP:
Class :
Read the comments on visualforce page.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Thanks For the reply.. But its not solving my prob...
Actualy my prob is .. I created a map as follows..
map is giving me the correct value like...
============bucketOrderMap========={1=Manage_Tags, 2=Manage_Channels}
now my prob is how to show these values on a VF page.
if i run the commented part than it will run ok bt the prob is its not giving me the sorted order of the tutorials..
so because of sorting i used map and know i dnt knw how to use this in VF page...
I hope now i explain myself..
if still have any doubt .. i will explain it more..
Thanks,
Crist
Hello,
As a rule, a map is not sorted. Event though you put the order as the key in a map, it will be traversed randomly only.
If you need to maintain the order, use lists and sort in the soql query itself.
and in VF page
This should give you the list sorted. Please make sure of any syntax errors / variable naming errors before running this.
Hope this helps.
Regards,
Ritika
Thanks for the reply...
I also try this after this post and it works and when m going to write this your reply is there...
Thanksssssss alot....