+ Start a Discussion

Component's internal action and SelectList

I have a requirement to have a selectList on a custom component with a command button.


When everything works fine, but when i use my custom component along with other components which require validation, my command button inside the component will not fire the action because the validation of components on the parent page fails.


So I add the immidiate attribute to the command button, to force the action get fired without considering other components validation requirements in parent VF page.


As a result the selectList no longer maintains it's state or in other words "value" attribute is not set anymore!


here is my code:



<!-- Component Source -->
<apex:component controller="zTestComponent" >

<apex:outputPanel id="thepanel">

<apex:selectList value="{!Items}" multiselect="true">
<apex:selectOptions value="{!options}"> </apex:selectOptions>
<apex:commandButton value="submit" action="{!submitMethod}" rerender="thepanel" immediate="true"/>
<apex:outputLabel value="{!message}"></apex:outputLabel>




/* Component Controller */
public class zTestComponent {

private List<SelectOption> op = new List<SelectOption>();
public List<SelectOption> options {
get {
if (op.size() <= 0) {
// List<SelectOption> op = new List<SelectOption>();
op.add(new SelectOption('1','test 1'));
op.add(new SelectOption('2','test 2'));

return op;

public List<string> items = new List<String>();
public List<String> getItems() {
return items;
public void setItems(List<String> items) {
this.items = items;

public string message { get; set; }

public PageReference submitMethod() {
message = '';

if (items != null)
for(string item : items) {
message += item + ',';

return null;



  Parent VF Page:

<apex:page controller="someController">
<apex:form id="theform">
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="test" reRender="theform"/>
<apex:pageBlockSection >

<c:zTestComponent />
<apex:pageBlockSectionItem >
<apex:inputField value="{!NewTask.Subject}" required="true"/>

public class someController {
public Task NewTask { get; set; }
public someController()
NewTask = new Task();

 I really appreciate if you could provide me with a solution.


Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess

Don't use immediate that skips all bindings on the page.


take a look at < apex : actionRegion /> , with this you can get your portion of the page to operate independently of the other components that have validation.