1

Here comes a stripped down example to reproduce this error:

VF-Page:

<apex:page showHeader="false" sidebar="false" controller="D3Terror" >
<apex:form >
<apex:pageBlock html-width="100%">
<apex:commandButton value="Request" action="{!getDocuments}"/>
<apex:outputLabel value="Filter:" rendered="true" style="padding-right:5px"/>
<apex:selectList rendered="true" multiselect="false" size="1">
<apex:selectOptions value="{!doctypes}"/>
</apex:selectList>
</apex:pageBlock>
</apex:form>
</apex:page>

Apex Code:

public class Terror 
{
public Set<SelectOption> doctypes {get;set;}

public Terror()
{
// Picklist initialization
doctypes = new Set<SelectOption>();
}

public PageReference getDocuments()
{
system.debug('getDocuments');
doctypes.add(new SelectOption('all','all'));
return null;
}

}

For some reason, after the selectList get filled by the first button click, a second click doesnt make it to the method, no debug message is thrown.

I've no idea anymore to solve this problem.

2
  • Is it a typo that you have d3_doctypes in your markup and doctypes in your controller?
    – Adrian Larson
    Feb 17, 2016 at 16:41
  • change you method name i.e. getDocuments to fetchDocuments .. Don't use method name start with get...
    – Ratan Paul
    Feb 17, 2016 at 16:41

1 Answer 1

2

I believe you are receiving an error but it is not displayed on the page because you are missing <apex:pagemessages> tag.

When I added <apex:pagemessages>, I received an error.

Modified Page Code:

<apex:page showHeader="false" sidebar="false" controller="Terror" >
    <apex:form >
        <apex:pageBlock html-width="100%" id="val">
            <apex:pageMessages></apex:pageMessages>
            <apex:commandButton value="Request" reRender="val" action="{!getDocuments}"/>
            <apex:outputLabel value="Filter:" rendered="true" style="padding-right:5px"/>
            <apex:selectList id="List" rendered="true" multiselect="false" size="1">
                <apex:selectOptions id="Options" value="{!doctypes}"/>
            </apex:selectList>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Error:

Error Image

You are receiving an error because maybe Sales-force does not support Set as a value for <apex:selectOptions>(Didn't find a document which states this and I am skeptical as it renders correctly for first time so I cannot say much about it).

In every example by sales-force for Select-options, I found that a list is used. If we use a set, the above error is received.

Modified Controller Code works perfectly after replacing SET with LIST

public class Terror 
{
    public List<SelectOption> doctypes {get;set;}

    public Terror()
    {
        // Picklist initialization
        doctypes = new List<SelectOption>();
    }

    public PageReference getDocuments()
    {
        system.debug('getDocuments');
        doctypes.add(new SelectOption('all','all'));
        return null;
    }

}
1
  • Thanks a lot! This is the solution! I've changed nearly everything around except changing my SET to a List. Now for people who try to find the error with Google: val:List: Validation Error: Value not valid.
    – Nils Rosen
    Feb 17, 2016 at 19:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .