function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Enrico devEnrico dev 

Null Value for method called by command button

Following is my VF page:
<apex:page standardController="Case" extensions="ctrlClaim"> 
<!--read-->
<style>
 .customPopup{
            background-color: white; 
            border-style: solid;
            border-color: #1797c0;
            border-width: 2px;
            left: 50%;
            padding:10px;
            position: absolute; 
            z-index: 9999;
            /* These are the 3 css properties you will need to tweak so the pop 
            up displays in the center of the screen. First set the width. Then set 
            margin-left to negative half of what the width is. You can also add 
            the height property for a fixed size pop up.*/
            width: 500px;
            margin-left: -250px;

}
</style>
  <apex:form >

    <apex:pageBlock title="Case Detail">

      <apex:PageMessages escape="false"/>

        <!-- Selection PopUp -->
           <apex:outputPanel id="popup">
             <apex:outputPanel styleClass="customPopup" rendered="{!displayPopUp}">
                 <apex:pageBlock > 
                    <apex:pageBlockButtons location="bottom">
                     <apex:actionRegion >
                       <apex:commandButton value="Select" action="{!closePopUp}"/>  
                       <apex:commandButton value="Cancel" action="{!closePopUpCancel}"  rerender="popup"/>   
                     </apex:actionRegion>   
                    </apex:pageBlockButtons>                
                    <apex:pageBlockSection title="Production Order Number Selection" collapsible="false" columns="3">                             

                         <apex:pageBlockSectionItem >
                            <apex:selectList value="{!ProductionOrderNumber}" multiselect="false" >
                                <apex:selectOptions value="{!ProductionOrderNumbers}"/>                          
                            </apex:selectList>
                         </apex:pageBlockSectionItem>
                         <apex:pageBlockSectionItem />
                    </apex:pageBlockSection>
                 </apex:pageBlock>  
            </apex:outputPanel>
           </apex:outputPanel>
        <!-- end PopUp -->


        <apex:pageBlockSection title="Order Information"  columns="3">    
            <apex:inputfield value="{!case.Loading_ID__c}" id="loadingID"/>       
            <apex:commandButton action="{!FindProductionOrderNumber}" image="/img/func_icons/ispan12.gif" title="Search Production Order Numbers" immediate="true" rerender="popup"/>            
        </apex:pageBlockSection>   

    </apex:pageBlock>
  </apex:form>
</apex:page>
Apex controller:
public class ctrlClaim {
    public Boolean productCase { get; set; }
    public Boolean locked { get; set; }

    private Case claim;
    private String recordType;
    private String sfdcOverride;
    public String ProductionOrderNumber { get; set; }
    public String InsertedLoadingID { get; set; }
    public List<SelectOption> ProductionOrderNumbers { get; set; }
    public boolean displayPopUp { get; set; }



    public class OrderQueryException extends Exception {}

    public ctrlClaim( ApexPages.StandardController stdCtrl ) {
        claim = ( Case ) stdCtrl.getRecord();
        recordType = ApexPages.CurrentPage().getParameters().get( 'RecordType' );
        sfdcOverride = ApexPages.CurrentPage().getParameters().get( 'sfdc.override' );
        if ( sfdcOverride == '1' && recordType != null ) claim.RecordTypeId = recordType;
        productCase = ( claim.RecordTypeId == Schema.SobjectType.Case.getRecordTypeInfosByName().get( 'Product Case' ).getRecordTypeID() );
        locked = false; 
    }


      public PageReference FindProductionOrderNumber(){
        system.debug('claim'+claim);
        system.debug('loadingID'+claim.Loading_ID__c); 
        if (claim.Loading_ID__c!=null){
                system.debug('HERE');
                if (claim.Loading_ID__c=='1')            
                    ProductionOrderNumbers.add(new SelectOption('1','1'));
                else
                    ProductionOrderNumbers.add(new SelectOption('2','2'));       
       }

        displayPopUp = true;
        return null;
      }


      public void closePopUp(){
        displayPopUp = false;
      }


      public void closePopUpCancel(){
        displayPopUp = false;
      }   

      public PageReference ClonePreparation(){
        return null;
      }

}

Problem is that ,after inserted Loading_ID__c and pressed the button,i get null value for Loading_ID__c in the controller method FindProductionOrderNumber(). Do you know why?

Thanks in advantage for any advice
Best Answer chosen by Enrico dev
Enrico devEnrico dev
 issue - the immediate="true" on the commandButton.
Normally, the immediate="true" is used when you want to leave the page, such as in a cancel operation. So, eliminate the immediate="true" to send the user-entered value in the inputField

All Answers

Enrico devEnrico dev
I´ ve just tried adding in the page "
<apex:outputtext value="{!case.Loading_ID__c}" rendered="false"/>" but debug log still shows: loadingID=null
Enrico devEnrico dev
 issue - the immediate="true" on the commandButton.
Normally, the immediate="true" is used when you want to leave the page, such as in a cancel operation. So, eliminate the immediate="true" to send the user-entered value in the inputField
This was selected as the best answer