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
BellaBella 

Multiselect param not working

I'm trying to dynamically populate the multiselect param on a custom apex:selectList. When I explicitly set it to true or false, it works. However when I pass the boolean from the controller, it always acts as if it's false.

Here is the section of the visual force page:

<apex:selectList value="{!es.inputText}" size="{!es.sizeList}" multiselect="{!es.multiselectVal}">
<apex:selectOptions value="{!es.picklist}">
</apex:selectOptions>
</apex:selectList>

This is in a list. es.sizeList is either 1 or 3 depending on whether the object is a regular picklsit or a multiselect picklist. This gets set and rendered correctly. I've tested it out, and all the multiselects come up with a size of 3 while all the regular ones come up with a size of one. In the same part of the controller I'm also setting the es.multiselectVal boolean (true for multiselect, false otherwise). When I print out the value next to the list, it reads true and false as expected. However all my lists still come up as single select picklists

 

Any ideas? Is there something special about that param that it can't use a boolean from the controller?

Best Answer chosen by Admin (Salesforce Developers) 
Starz26Starz26

As I think about this more:

 

If you are not using the component in any javascript on the page,

 

You could create two different selectlist components, one multiselect and one not multiselect, then use the parameter in the rendered property. This would be eaiser than creating a dynamic component just for this purpose.

All Answers

Starz26Starz26

try

 

<apex:selectList value="{!es.inputText}" size="{!es.sizeList}" multiselect="{!if(es.multiselectVal=ture,true,false)}">

BellaBella

Just tried it with no luck :( same bahavior. It's really weird because when I print out es.multiselectVal, it prints correctly, but when I pass it to the multiselect param, it's almost like it's being completely ignored.

BellaBella

Another experiment: I put in a global boolean in the controller (not one conencted to the objects in the lists), set it to true in the constructor, and tried using it. Still the picklists all behave as if it's false :( I even tried casting it as an apex:variable and then using that varaiable, but still nothing.

Starz26Starz26
aballardaballard

I think the page generator makes the decision about whether it is single-or-multi select too soon to use the controller property.    I think this is a bug (the page generator should either support it, or not allow you to use an expression for that property). If you have access to Salesforce support, you should open a case.

 

Starz26's suggestion would be a possible workaround.  

 

 

Starz26Starz26

As I think about this more:

 

If you are not using the component in any javascript on the page,

 

You could create two different selectlist components, one multiselect and one not multiselect, then use the parameter in the rendered property. This would be eaiser than creating a dynamic component just for this purpose.

This was selected as the best answer
aballardaballard

Good point.  That is a better workaround.

BellaBella

Perfect! That was it! Thank you so much!