function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
StenEStenE 

Visualforce and Map issue.

Guys,

 

I'm creating a page which has three nested apex:repeat.

 

the first is for severtal content blocks -- APEX;REPEAT

the second is a table -- PAGEBLOCKTABLE

The third is the number of COLUMNS -- APEX:REPAT

 

VISUALFORCE

<apex:repeat value="{!SuperMap}" var="O" id="MapRepeat">
	<apex:pageBlock title="Results for {!O}">
		<apex:pageBlockTable value="{!SuperMap[O]}" var="R" id="RecordRepeat">
			<apex:column headerValue="#"><apex:inputCheckbox value="{!R.rSelected}"/></apex:column>
			<apex:column headerValue="Score"><apex:outputText value="{!R.rScore}"/></apex:column>
			<apex:repeat value="{!FieldList[O]}" var="H" id="HeaderRepeat">
				<apex:column headerValue="{!H}"><apex:outputText value="{!R.rObject[H]}"/></apex:column>
			</apex:repeat> 
		</apex:pageBlockTable>
	</apex:pageBlock>
</apex:repeat>

 

APEX CONTROLLER

public class Result { 
	public String rId {get; set;}
	public Integer rScore {get; set;}
	public Boolean rSelected {get; set;}
	public sObject rObject {get; set;}
}

Map<String,List<Result>> SuperMap = new Map<String,List<Result>>();
Map<String,Map<String,String>> FieldList = new Map<String,Map<String,String>>();

// CONTENT FIELD LIST
// {OBJECT NAME,{FieldName,FieldLabel}}
// {Lead,{FirstName,First Name}},{Lead,{LastName,Last Name}}

// CONTENT SUPER MAP
// {OBJECT NAME,{{ID,SCORE,SELECTED,FULL OBJECT},{ID,SCORE,SELECTED,FULL OBJECT}}}
// {Lead,{{00034798,98,false,{Lead:{FirstName:peter,LastName:de hond}}},{00034756,97,false,{Lead:{FirstName:peter,LastName:de hond}}}}

 When i try to save this page it will crash with the following error.

 

Save error: Incorrect parameter for subscript. Expected Text, received core.apexpages.el.adapters.RuntimeTypeMetadataELAdapter   

 

This error is triggered via the {!R.rObject[H]} part.

 

Please help!

Best Answer chosen by Admin (Salesforce Developers) 
StenEStenE

I found the solution, workaround.

 

Instead of using the direct value of the {!H} map i used an extra visual force function.

 

Original :
{!R.rObject[H]}

Solution :

{!R.rObject[$ObjectType['Lead'].fields[H].LocalName]}

This worked for me.

All Answers

aballardaballard

You may have run into a bug.   I know there are some issues with dynamic references and maps.     Can you open a support case?

StenEStenE

I filed a report to Salesforce support. But as i don't have a premier support plan my bug report doesn't get looked at...

Only got a reference to http://boards.developerforce.com/t5/Visualforce-Development/Compile-Error-in-a-Visualforce-Page-apex-pageBlockTable-and-a/m-p/343645

 

As you were into that discussion as wel Aballard, do you have a suggestion?

 

Thanks,

Sten

 

 

StenEStenE

I found the solution, workaround.

 

Instead of using the direct value of the {!H} map i used an extra visual force function.

 

Original :
{!R.rObject[H]}

Solution :

{!R.rObject[$ObjectType['Lead'].fields[H].LocalName]}

This worked for me.

This was selected as the best answer