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

Use Input in Wrapper Class
I need to use the value from an inputField to populate a variable in a wrapper class. How do I that?
Controller:
//Variable for input public String duration { get; set; } //Wrapper class needing variable public class TotalTerr { public String TerritoryName { get; set; } //Class variable that needs input public String Duration { get; set; } }
I could really use the help - thanks in advance!
HI,
The inputField tag is very powerful to use with sObject fields rather that inner class members (prmitive data types). If the duration variable is a field in any sObject then you can use inputfield. Otherwise, if you are using String as datatype, then you need to use inputText, selectList tag to collect user input.
E.g.: If the variable Duration is a custom field in Account SObject then you need to code the inner class as below
//Wrapper class
public class TotalTerr{
public String territoryName {get; set;}
public Account acc {get; set;}
}
in VF page
<apex:inputField value = "{!ttInstance.acc.Duration__c}"/>
where ttInstance is the public variable of type Wrapper class TotalTerr
Hope this example helps
Try out the sample code for how to use variables in wrapper class and bound with the variables :
<apex:repeat value="{!propLstQuesAns}" var="varLQA" id="textquesrp">
<p>{!varLQA.propQuesNo}{!varLQA.propQues}</p>
<apex:inputField value="{!varLQA.propAns}" id="textques"/>
</apex:repeat>
controller code:
public List<WrapperQueAns> lstQueAns = new List<WrapperQueAns>{};
public List<WrapperQueAns> propLstQuesAns { get { return lstQueAns; } set { lstQueAns = value; } }
List<Registration_Question__c> lstQues = [select Id, Order__c,Question__c from Registration_Question__c Order by Order__c asc] ;
if(lstQues != null && lstQues.size() > 0)
{
for(Integer i =0; i < lstQues.size(); i++)
{
WrapperQueAns wqa = new WrapperQueAns();
wqa.propQuesId = lstQues[i].Id;
wqa.propQuesNo = String.valueOf(i + 1) + '. ';
wqa.propQues = lstQues[i].Question__c;
wqa.propAns = '';
lstQueAns.add(wqa);
checkQues = 1;
}
}
// wrapper class:
public class WrapperQueAns
{
public String propQuesId{ get; set; }
public String propQuesNo{ get; set; }
public String propQues { get; set; }
public String propAns { get; set; }
}//End Class WrapperQueAns
Hope this helps.
Thanks for the speedy reply guys. I'm not sure if your solutions will work for me. I apologize for the brevity of my original email, I honestly thought the solution would have been a lot more obvious.
We have two custom objects - Territory and Trade. They are tied through a lookup on Territory Id. I have to create a Visualforce page that will sum up sales by Territory quarterly, yearly and for a date range provided by the end user; along with other date range specific data. The wrapper class is constructed off an AggregateResult:
Wrapper class:
The issue is when I need to have the following aggregate within the wrapper class:
I need to be able to retrieve to dates from my form to create a startDate and endDate. I had first thought I could just filter by date in initial totalTerr AggregateResult, but that only would work for my sales totals. I'm currently trying to send the startDate and endDate through the url by using:
but I'm not sure if I can even use this - hasn't worked yet.
I'm stuck, any help would be greatly appreciated. Thanks in advance.
Adriel