You need to sign in to do that
Don't have an account?

Using updated value from SelectList
I have a select list where the user selects a number from 1 to 10:
<apex:outputText >New Laser Count? </apex:outputText>
<apex:selectList label="new Count?" value="{!newLaserCount}" size="1" >
<apex:selectOptions value="{!newLaserCounts}" />
</apex:selectList>
I then want to loop through, using that number to create the same number of new records for the user to popualate. Here is the part of the code where I am using the 'newLaserCount':
Integer LaserCount = integer.valueOf(newLaserCount);
for (Integer i = 0; i < LaserCount; i++) {
SLLNewList.add(new Laser__c());
}
If I hardcode the LaserCount field it gives me the correct number.. however, this does not work. The default value of teh seleclist is 1.. it always creates one record recardless of the value populated in the selectlist.
I've done this before without issue but for some reason, this is just not getting updated. Any help would be greatly appreciated!!!
Fred
<apex:outputText >New Laser Count? </apex:outputText>
<apex:selectList label="new Count?" value="{!newLaserCount}" size="1" >
<apex:selectOptions value="{!newLaserCounts}" />
</apex:selectList>
I then want to loop through, using that number to create the same number of new records for the user to popualate. Here is the part of the code where I am using the 'newLaserCount':
Integer LaserCount = integer.valueOf(newLaserCount);
for (Integer i = 0; i < LaserCount; i++) {
SLLNewList.add(new Laser__c());
}
If I hardcode the LaserCount field it gives me the correct number.. however, this does not work. The default value of teh seleclist is 1.. it always creates one record recardless of the value populated in the selectlist.
I've done this before without issue but for some reason, this is just not getting updated. Any help would be greatly appreciated!!!
Fred
Could you please post your controller code, so that I may be able to help you to resolve this issue.
Thanks,
Apoorv
the button calls this function:
public PageReference NewSLL() {
UpdateSLLSList();
Integer LaserCount = integer.valueOf(newLaserCount);
newSLL = true;
return null;
}
There is a pageblocktable that has the following: <apex:pageBlockTable width="100%" value="{!SLLNewList}" var="laser" rowClasses="">
There is a method called to update the list.. The problem is that the varialble newLaserCount) is not getting updated when it is changed on the page.
public void UpdateSLLSList() {
// Create a list of the related Stop Loss Laser Summaries
// to show onthe SL Lasers tab.
SLLSList = new List<SLLSCheckbox>();
SLLSPickListSelect = new List<SelectOption>();
SLLSPickListSelect.add(new SelectOption('', '-- No Value Selected --'));
newSLLS = false;
newSLL = false;
for (Laser_Summary__c ls : [
select ID, Name, Account__c, Lasers_Apply_To__c,
Start_Date__c, End_Date__c, Laser_Summary_Name_Copy__c,
(select Id, First_Name__c, Last_Name__c, Gender__c,
DOB__c, SSN__c, Relationship_Code__c, Attachment_Point_Amount__c, Laser_Type__c
from Lasers__r)
from Laser_Summary__c
where Account__c = : a.id
and Start_Date__c >= : startRenewalDate
and Start_Date__c < : activeGroup.masterUwi.End_Date__c
and End_date__c >= :startRenewalDate
order by Start_Date__c]) {
SLLSList.add(new SLLSCheckbox(ls));
SLLSPickListSelect.add(new SelectOption(ls.Id, ls.Name));
}
if (SLLSList.size() == 0) {
SLLSList = null;
SLLSPickListSelect = new List<SelectOption>();
SLLSPickListSelect.add(new SelectOption('', '-- No Lasered Summary Records Exist --'));
}
else {
selectedSLLS = SLLSList[0].laserSummary.id;
}
// Refresh the list of new laser records
SLLNewList = new List<Laser__c>();
// Set the number of cloned records to create
// for each original record that is cloned
Integer LaserCount = integer.valueOf(newLaserCount);
for (Integer i = 0; i < LaserCount; i++) {
SLLNewList.add(new Laser__c());
}
}
Have you tried debugging its value on button click?
public String newLaserCount{get;set;}
Now setup your debug logs from Setup.
Next, you can add debug statement in you method that gets called on button click, like this:
And then check your debug log that what value you are getting for 'newLaserCount' in controller when your method is called.
Hope this helps!