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

passing a parameter from visualforce to apex
I'm trying to change a public variable (every function and variable I use are public) :
public Integer indexs{get{return index;}set{index= value;}}
from my visualforce page with (only this one):
<apex:param name="opt" value="0" />
I try to update the variable indexs within this function:
public string gethtmltags(){
if (index==null){index=0;}
String indexs =ApexPages.currentPage().getParameters().get('opt');
index = integer.valueof(indexs);
toOpp ='https://na4.salesforce.com/' + oppList[index].Id;
coo = ((978-21)*(((opplist[index].Amount-Amountcheck)/(maxamount-Amountcheck)))+21)+','+((282-35)*(1-(oppList[index].Probability)/100)+35)+',6';
return null;}
but when I output the content of indexs it's always null.
I would like to know if some of you knows a good way to change a public variable from a visualforce page.
thanks
Here you dont need to give the name attribute of param tag because it will not work.
Instead use the "assignTo" attribute of the "<apex: param>". Give the variable, in the controller to which you want to assign the value, in the form of merge field. In your case it is indexs. And in the "value" attribute give the value.
For example:
<apex:param assignTo="{!indexs}" value="0"/>