You need to sign in to do that
Don't have an account?

Passing value from a visualforce page to a controller string variable.
Hi all,
I have created a visualforce page and wanted to pass current values from feilds of this page to the controller.
The scenario is like, on the screen we have three fields and the user puts in some value to those fields. Now this values entered in the fields should be passed to the variable in the controller. These fields are not binded to any object.
Now I able to pass the Static value to the controller for eg. <apex:param name="two" value="Vijosh" />. But how to pass Dynamic values from to the controller.
<apex:page controller="TestFieldPopulationController" id="pg">
<script type="text/javascript">
function userInput(){
var UInput=document.getElementById("{!$Component.pg.frm.in}").value;
return UInput;
}
</script>
<apex:form id="frm">
<apex:actionFunction name="hitMe" action="{!iWantMyJSValues}" rerender="jsvalues">
<apex:param name="one" value="" />
<apex:param name="two" value="Vijosh" />
<apex:param name="three" value="Keyboard" />
</apex:actionFunction>
<apex:outputPanel id="jsvalues">
<apex:panelGrid columns="2">
Value One:<apex:inputText id="in" value="{!valueOne}"/>
Value Two:<apex:inputText value="{!valueTwo}" />
Value Three:<apex:inputText value="{!valueThree}" />
<apex:commandButton value="Submit" onclick="hitMe(userInput())"/>
</apex:panelGrid>
</apex:outputPanel>
</apex:form>
</apex:page>
Regards,
Vijosh
I have created a visualforce page and wanted to pass current values from feilds of this page to the controller.
The scenario is like, on the screen we have three fields and the user puts in some value to those fields. Now this values entered in the fields should be passed to the variable in the controller. These fields are not binded to any object.
Now I able to pass the Static value to the controller for eg. <apex:param name="two" value="Vijosh" />. But how to pass Dynamic values from to the controller.
<apex:page controller="TestFieldPopulationController" id="pg">
<script type="text/javascript">
function userInput(){
var UInput=document.getElementById("{!$Component.pg.frm.in}").value;
return UInput;
}
</script>
<apex:form id="frm">
<apex:actionFunction name="hitMe" action="{!iWantMyJSValues}" rerender="jsvalues">
<apex:param name="one" value="" />
<apex:param name="two" value="Vijosh" />
<apex:param name="three" value="Keyboard" />
</apex:actionFunction>
<apex:outputPanel id="jsvalues">
<apex:panelGrid columns="2">
Value One:<apex:inputText id="in" value="{!valueOne}"/>
Value Two:<apex:inputText value="{!valueTwo}" />
Value Three:<apex:inputText value="{!valueThree}" />
<apex:commandButton value="Submit" onclick="hitMe(userInput())"/>
</apex:panelGrid>
</apex:outputPanel>
</apex:form>
</apex:page>
Regards,
Vijosh
http://salesforce.stackexchange.com/questions/14675/how-to-get-the-text-fields-values-in-the-controller-class-without-using-any-scri
So for your code:
class TestFieldPopulationController{
public String valueOne{get;set;}
public String valueTwo{get;set;}
public String valueThree{get;set;}
<and now use these values being passed in the controller>
.
.
}
All Answers
http://salesforce.stackexchange.com/questions/14675/how-to-get-the-text-fields-values-in-the-controller-class-without-using-any-scri
So for your code:
class TestFieldPopulationController{
public String valueOne{get;set;}
public String valueTwo{get;set;}
public String valueThree{get;set;}
<and now use these values being passed in the controller>
.
.
}
Appreciate your quick response.
Vijosh
Can you plz tell me
how we can compare input field value with String on VF page.
To answer your questions here:you can do try the following:
//get user to input the field on the VF page using this inputtext field
<apex:inputText value="{!inputValue}" id="theTextInput"/>
//Take this value to the controller through the following:
public String inputValue{get;set;}
//Compare it with the string in the controller using String method:
String myString = 'abcd'; //string to compare with
Integer result = inputValue.compareTo(myString); System.assertEquals(result, 1);
reference:http://www.salesforce.com/us/developer/docs/dbcom_apex250/Content/apex_methods_system_string.htm