+ Start a Discussion
nagachandra knnagachandra kn 

selectcheckboxes tag

Hi All,

I am writing a basic program by using selectcheckboxes tag. But Once i click the button and panel is rerendered. the below is list is not displaying the selected values. what i m missing?


VF Page
 
<apex:page controller="selectcheckcon">
    <Apex:form>
    <apex:pageBlock title="Select checkboxes">
        <apex:pageMessages  id="page" />
        <apex:pageBlockSection title="Demo of select checkboxes">
            <apex:outputLabel value="Select the countries"/>
            <apex:selectCheckboxes value="{!countries}">
                <apex:selectOptions value="{!items}">
                </apex:selectOptions>
            </apex:selectCheckboxes>
        </apex:pageBlockSection>
        
       
        <apex:pageBlockButtons>
            <apex:commandButton action="{!test}" rerender="out,page" status="status" value="Click me!"></apex:commandButton>
        </apex:pageBlockButtons>
        
        
    </apex:pageBlock>
</Apex:form>

 <apex:outputPanel id="out">
                <apex:actionStatus startText="Fetching Data..."  id="status">
                <apex:dataList value="{!countries}" var="con">
                    {!con}
                </apex:dataList>
                </apex:actionStatus>
            </apex:outputPanel>
</apex:page>

Controller class:
 
public class selectcheckcon {
    
    public String[] countries = new String[]{};
    
    
    public String[] getcountries(){
        
        return countries;
    }
    
    public void setcountries(string[] country){
        
        countries = country;
    }
    
    
    public selectcheckcon(){
        
       
    }
    
    public list<selectoption> getItems(){
        
        list<selectoption> options =  new list<SelectOption>();
        
        options.add(new SelectOption('USA','USA'));
        options.add(new SelectOption('INDIA','INDIA'));
        options.add(new SelectOption('AUS','AUS'));
    
        return options;
    }
    
    public pageReference test(){
        
        return null;
    }

}

 
nagachandra knnagachandra kn
Solved it. Actionstatus tag was creating the issue.
Nagendra Prasad ChNagendra Prasad Ch
Hi Naga Chnadra,

One observation is u kept table in side Actionstatus. It needs to be out of Actionstatus and that panel should be rendered on Click.
Here is the corrected code.


<apex:page controller="selectcheckcon">
    <Apex:form>
        <apex:pageBlock title="Select checkboxes">
            <apex:pageMessages  id="page" />
            <apex:pageBlockSection title="Demo of select checkboxes">
                <apex:outputLabel value="Select the countries"/>
                <apex:selectCheckboxes value="{!countries}">
                    <apex:selectOptions value="{!items}">
                    </apex:selectOptions>
                </apex:selectCheckboxes>
            </apex:pageBlockSection>
            
            
            <apex:pageBlockButtons>
                <apex:commandButton action="{!test}" rerender="conPanel,page" status="status" value="Click me!"></apex:commandButton>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </Apex:form>
    
    <apex:outputPanel id="out">
        <apex:actionStatus startText="Fetching Data..."  id="status">                
        </apex:actionStatus>
    </apex:outputPanel>
    
    <apex:dataList value="{!countries}" var="con" id="conPanel">
        {!con}
    </apex:dataList>

    
</apex:page>

Let me know whether I have answered ur question ?