Skip to main content
Fred Kampf (Horizon BCBSNJ) 님이 #Visualforce에 질문했습니다
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
답변 7개
  1. 2016년 10월 5일 오후 8:19
    Ok, first make sure you have declared 'newLaserCount' as an autoproperty ie. you should declare it as :

    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:

     

    public PageReference NewSLL() {

        system.debug('@@@---'+newLaserCount);

        UpdateSLLSList();  

        Integer LaserCount = integer.valueOf(newLaserCount);

            newSLL = true;       

            return null;

        }

    And then check your debug log that what value you are getting for 'newLaserCount' in controller when your method is called.

    Hope this helps!