You need to sign in to do that
Don't have an account?
Soumya Srivastava 1
Not able to do Dynamic binding using map with visualforce page.
Hi,
I am not able to bind map values on my Vf page perfectly I am getting related list name only not its fields that too dynamically i am getting those data.
Now the problem is with the binding.
<apex:pageBlock>
<apex:form>
<apex:repeat value="{!mapOfRelatedListFields}" var="key">
<apex:outputText value="{!key}"/> <br/>
<apex:repeat value="{!mapRelatedList[key]}" var="dd">
<apex:outputText value="{!dd}"/> <br/>
</apex:repeat>
</apex:repeat>
</apex:pageBlock>
</apex:form>
for(String s:mapOfRelatedListFields.keySet()){
String relatedFields = string.ValueOf(mapOfRelatedListFields.get(s)).removeStart('(').removeEnd(')');
System.debug('relatedFields====='+relatedFields);
commaSepratedFields = commaSepratedFields +', (select ' + relatedFields + ' from ' + s +' )';
strList.add(s);
}
/* ----------- making the query to execute ---------- */
query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Where ID = \''+ String.escapeSingleQuotes(obj)+'\'';
System.debug(query);
recDetail = Database.query(query);
system.debug('The record details are:-'+recDetail);
mapRelatedList = new Map<String, List<sObject>>();
for(String str: strList){
if(recDetail.getSObjects(str) == null){
mapRelatedList.put(str, new List<sObject>());
}
else{
mapRelatedList.put(str, recDetail.getSObjects(str));
}
Please let me know if anybody has an idea about it.
Thanks,
Soumya
I am not able to bind map values on my Vf page perfectly I am getting related list name only not its fields that too dynamically i am getting those data.
Now the problem is with the binding.
<apex:pageBlock>
<apex:form>
<apex:repeat value="{!mapOfRelatedListFields}" var="key">
<apex:outputText value="{!key}"/> <br/>
<apex:repeat value="{!mapRelatedList[key]}" var="dd">
<apex:outputText value="{!dd}"/> <br/>
</apex:repeat>
</apex:repeat>
</apex:pageBlock>
</apex:form>
for(String s:mapOfRelatedListFields.keySet()){
String relatedFields = string.ValueOf(mapOfRelatedListFields.get(s)).removeStart('(').removeEnd(')');
System.debug('relatedFields====='+relatedFields);
commaSepratedFields = commaSepratedFields +', (select ' + relatedFields + ' from ' + s +' )';
strList.add(s);
}
/* ----------- making the query to execute ---------- */
query = 'select ' + commaSepratedFields + ' from ' + SobjectApiName + ' Where ID = \''+ String.escapeSingleQuotes(obj)+'\'';
System.debug(query);
recDetail = Database.query(query);
system.debug('The record details are:-'+recDetail);
mapRelatedList = new Map<String, List<sObject>>();
for(String str: strList){
if(recDetail.getSObjects(str) == null){
mapRelatedList.put(str, new List<sObject>());
}
else{
mapRelatedList.put(str, recDetail.getSObjects(str));
}
Please let me know if anybody has an idea about it.
Thanks,
Soumya