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
timarptimarp 

VF error : cannot convert value to the expected type

I have been stuck with this for over a day.

 

I am using a component. that was obtained from an unmanaged package,  in my visualforce page. It is complaining that one of the attributes is not getting the right type for its parameter.

 

Following is the attribute definition and controller variable

 

 

  <apex:attribute name="leftOptions"
    description="Options list for left listbox." type="SelectOption[]"
    required="true" assignTo="{!leftOptions}" />

 

public SelectOption[] leftOptions { get; set; }

 

In my VF page, this is how I have been using it and the corresponding extension code

 

My VF:

                    <apex:column headerValue="Dates of Service" >
                        <apex:variable var="dos1" value="{!s.multiLineEdit_tag__c}"/>                        
                        <c:MultiselectPicklist leftLabel="" leftOptions="{!leftOptionList[dos1]}" rightLabel="" rightOptions="{!rightOptionlist[dos1]}"  size="5" width="150px"/>                                
                     </apex:column>   

 

My Controller:

    public List <SelectOption[] > leftSideOptions = new List <List<SelectOption> >();   
    public List<SelectOption[] > getleftOptionList()
    {
        system.debug('leftSideOptions'+leftSideOptions);
        return leftSideOptions;
    }

 

It throws me a VF error as:

Cannot convert the value of '{!leftOptions}' to the expected type.

 


Could someone guide me as to what I am doing wrong?

 

Thank you.

Andrew WilkinsonAndrew Wilkinson

Is there any reason you are using a List of a list of selectOptions? And when you are referencing the list of lists...the array index should be an integer.

timarptimarp

Andrew,

 

I am using a List of List of selectoption because I have a list of OpportunityLineItems in my VF page, not just a single lineitem. The lineitems get added and removed dynamically by the user. A single lineitem maintains a list of selectoption which will change dynamically according to a picklist value.

 

As for using integer as array index, the opportunitylineitem has a field multilineedit_tag__c which is Number type. Therefore, according to my understanding the leftOptions attribute should be assigned a List<SelectOption> shouldnt it?

 

<apex:variable var="dos1" value="{!s.multiLineEdit_tag__c}"/>               

         
                        <c:MultiselectPicklist leftLabel="" leftOptions="{!leftOptionList[dos1]}" rightLabel="" rightOptions="{!rightOptionlist[dos1]}"  size="5" width="150px"/> 

 

 

Many thanks

 

shikher goelshikher goel
I am facing the same Issue ... Any body is able to resolve the issue
JagmohanJagmohan
Please refer the accepted answer on this Stackoverflow question

http://salesforce.stackexchange.com/questions/28062/passing-selectoption-to-multiselectpicklist-custom-component-results-in-cannot