[SalesForce] Pass a variable from an apex:inputText to controller

in my Vf page I have an apex:inputText:

<div Class="OtherVendor">      
    <apex:outputPanel id="otherPanel">
        <div Class="Other">
            <apex:inputText id="othervendor" value="{!otherVendor}" rendered="{!vendor=='Other'}">   
            <b> Other: </b>
            </apex:inputText>
        </div>
    </apex:outputPanel>  
    </div> 

In my controller I need to use the variable "othervendor" inside one of controller's method. I had defined:

public String otherVendor{get; set;}//Vendor Name

But when I use it inside the method, the variable is null and is not equal to the inserted Text. The method:

public void createProducts(){
System.debug('vendor '+ vendor);
System.debug('othervendor '+ otherVendor); //just to spect the value
}

In which cases this could happen? How could I solve it?
Thank you

Best Answer

I use this code and it works:

<apex:outputPanel id="otherPanel">


<div Class="Other">
        <apex:inputText id="othervendor" value="{!otherVendor}" rendered="{!vendor=='Other'}">   
        <apex:actionSupport event="onchange" reRender="import"  action="{!specifyVendor}"/>
        <b> Other: </b>
        </apex:inputText>
    </div>
</apex:outputPanel> 

action:

public PageReference specifyVendor(){
    System.debug('specifyVendor');    
    displaySelectedText  = vendor;
    System.debug(vendor);
    System.debug(otherVendor); 
    return null; 
    }

specyfyVendor let me spect in the debug the variable's value.