+ Start a Discussion
B2000B2000 

Wrapper Class and SelectList Problem

I have a wrapper class with a getter/setter string, a selectOptions list, and a method to be executed after the getter string is populated. I can't get the string setter to work with a selectList when I have a list of the wrapper.  If I use a single wrapper element the code works fine. I have tried using a PARAM statement without success. I would appreciate any assistance.  Thank you.

 

 

public with sharing class tClass
{
List <wClass> wClassList {get;set;}
wClass testWClass {get;set;}
string leftSelected {get;set;}

 public tClass() { testWClass = new wClass(new Account(name="Test Account 0')); wClassList = new List<wClass>(); wClassList.add(new Account(name='Test Account 1)); wClassList.add(new Account(name='Test Account 2')); } public class wClass { public Account a {get;set;} public string leftSelected {get;set;} public list<selectOption> leftSelectOptionList {get;set;} public wClass(Account a){this.a = a; ….code to build leftSelectOptionList} public pageReference selectClick(){String s = leftSelected; LEFTSELECTED IS SET TO NULL WHEN I CHECK WITH DEBUG STATEMENTS WHEN THERE ARE A LIST OF WRAPPER ELEMENTS} } } VF Page <apex:repeat value="{!wClassList}" var="PCOI"> <apex:selectList styleClass="inputText" value="{!PCOI.leftSelected}" size="3"> <apex:actionSupport event="onclick" action="{!PCOI.selectClick}" reRender="Form"> <!-- <apex:param assignTo="{!PCOI.leftSelected}" value="{!leftSelected}" name="left"/> --> </apex:actionSupport> <apex:selectOptions value="{!PCOI.leftSelectOptionList}"/> </apex:selectList> <apex:repeat >

VF PAGE WORKS FINE IF I REMOVE THE REPEAT AND USE testWClass.

 

 

RonakPatel.ceRonakPatel.ce

Update your class with this code

------------------------------------------------------------------------------------------------------------------

public with sharing class tClass
{
List <wClass> wClassList {get;set;}
wClass testWClass {get;set;}
string leftSelected {get;set;}

public tClass()
{
testWClass = new wClass(new Account(name="Test Account 0'));
wClassList = new List<wClass>();
wClassList.add(testWClass);
wClassList.add(new wClass(new Account(name='Test Account 1')));
wClassList.add(new wClass(new Account(name='Test Account 2')));

}

public class wClass
{
public Account a {get;set;}
public string leftSelected {get;set;}
public list<selectOption> leftSelectOptionList {get;set;}

public wClass(Account a){this.a = a; ….code to build leftSelectOptionList}
public pageReference selectClick(){String s = leftSelected; LEFTSELECTED IS SET TO NULL WHEN I CHECK WITH DEBUG STATEMENTS WHEN THERE ARE A LIST OF WRAPPER ELEMENTS}
}
}