I am using inputText to capture user input and then this input needs to be passed to a URL as a parameter. I am using the following code:
<apex:form >
<apex:panelGrid columns="2" rendered="true">
<apex:inputText value="{!searchText}" id="textsearch" rendered="true" />
<apex:outputLink id="link" value="/apex/VFPageName">Search
<apex:param value="{!searchText}" name="searchParameter"/>
</apex:outputLink>
</apex:panelGrid>
Controller code
public string searchText{get;set;}
The problem here is that when I enter a value in the text box and press the link the redirect is being performed but the parameter value is blank.
Another strange thing is if I enter a value and press enter and then click on the link then the parameter is being passed with the correct value.
What I am looking out is for normal functionality to work i.e. user enters text and on click of the link the user is redirected with the parameter set correctly
Please advice
Best Answer
You can not pass searchText into your link, because it will be always blank when you load your page. I would do more something like :