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
AlbertoSMAlbertoSM 

Passing an input text value from visualforce to controller

Hi everyone,

I have this visualforce where I introduce a Postal Code here:
<apex:inputText id="idPostalCodeIntroduced" value="{!PostalCodeIntroduced}" style="height: 22px; width: 100%;"/>
and just the stores that have postal code are shown in this line (postal code and store have a master detail relationship)
<apex:selectList value="{!storeChoosen}" multiselect="false" size="1" id="idstoreChoosen"  style="height: 22px; width: 100%;">
                                            <apex:selectOptions value="{!relatedStore}"/>
                                        </apex:selectList>
Also I have this line:
window.location.href="/apex/IK_VF_Formulario?PostalCode="+PostalCodeIntroduced+" en Store&Language=es";

And the corresponding controller:
public with sharing class myController {
    public String PostalCodeIntroduced {get; set;}
    public myController(){
          PostalCodeIntroduced = ApexPages.currentPage().getParameters().get('PostalCode');
    }
 
    public List<SelectOption> getRelatedStore(){
        List<CP__c> lstRelatedStores = [SELECT Store__c, Name, Store__r.Name 
                                                          FROM CP__c WHERE Name =: PostalCodeIntroduced ];
        List<SelectOption> RelatedStores= new List<SelectOption>();
        RelatedStores.add(new SelectOption('', '--None--'));
            for(CP__c tiCP: lstRelatedStores ){
                RelatedStores.add(new SelectOption(tiCP.Store__r.Name, tiCP.Store__r.Name));
            }    
                 
       return RelatedStores;
    }
}
The issue comes when the value I put in visualforce is not passing to the controller. But the weird thing is, if I put by hand (in the code) the PostalCode (example 90001) in order to show the related stores to this one, it works!!!! 
Example: 
List<CP__c> lstRelatedStores = [SELECT Store__c, Name, Store__r.Name 
                                                          FROM CP__c WHERE Name =: 90001 ];
Name is the numbers you put in the postal code, for the moment no problem with that


Hope it is clear for you guys
Thanks a lot in advance
Cheers!
Alberto



 
AlbertoSMAlbertoSM
Example***=
List<CP__c> lstRelatedStores = [SELECT Store__c, Name, Store__r.Name FROM CP__c WHERE Name =: '90001' ];