You need to sign in to do that
Don't have an account?
jmarinchak
inputfield - passing values to controller
I'm probably doing something very wrong that is obvious to others but, it's not obvious to me. Have a look and let me know if you see the problem. I'm trying to do a quick quota calculation based on orders in the system (we use Scribe to pull orders from our ERP system). In the user interface, the sales person just enters their quota amount and variable salary.
Key problem is that the inputfield does not seem to be getting values from the user.
Thanks.
First my controller -
Now the visualforce page:
Jeff
Key problem is that the inputfield does not seem to be getting values from the user.
Thanks.
First my controller -
Code:
public class MyCommissionController { public Commission__c MyComm {get; set;} public Commission__c getMyComm() { return MyComm; } //Our collection of the class/wrapper objects cCommission private List<cCommission> CommissionList {get; set;} public List<cCommission> getCommission(){ return CommissionList; } //This method uses a simple SOQL query to return a List of Contacts public PageReference getNumbers(){ if(CommissionList == null){ CommissionList = new List<cCommission>(); for(SCRB_Salesorder__c c : [Select Customer_PO_Number__c, Name, Amount__c FROM SCRB_SalesOrder__c WHERE DocumentDate__c > 2008-10-01]){ /* As each contact is processed we create a new cContact object and add it to the contactList */ CommissionList.add(new cCommission(c)); } } return null; } /* New wrapper class */ public class cCommission{ public SCRB_Salesorder__c corder {get; set;} public Double Commission_Amount{get; set;} /*This is the contructor method. When we create a new cCommission object we pass a SCRB_Salesorder_c that is set to the corder property. We also set the Commission_Amount value to zero*/ public cCommission(SCRB_Salesorder__c c){ corder = c; //if (myquota > 0) { /* Commission_Amount = c.Amount__c * myvariable / myquota; */ Commission_Amount = c.Amount__c * 0.10; //} else { // Commission_Amount = 0.0; // } } } }
Now the visualforce page:
Code:
<apex:page controller="MyCommissionController"> <apex:form > <apex:pageBlock title="Inputs" id="WholePage"> <p><b>Report for {!$User.FirstName} {!$User.LastName}</b></p> <br /> <b>Quota </b> <apex:inputField value="{!MyComm.Quota__c}" /> <br /> <b>Variable Salary </b> <apex:inputField value="{!MyComm.Variable_Salary__c}" /> <br /><br /> <apex:commandButton action="{!getNumbers}" value="Calculate" rerender="WholePage" status="status"/> <br /> <apex:pageMessages ></apex:pageMessages> </apex:pageBlock> <apex:actionStatus startText="Updating..." id="status"/> <apex:pageBlock title="Orders" rendered="{!NOT(ISNULL(MyComm.Quota__c))}" > <apex:dataTable value="{!Commission}" var="aOrder" width="100%"> <apex:column> <apex:facet name="header"><b>PO Number</b></apex:facet> {!aOrder.corder.Customer_PO_Number__c} </apex:column> <apex:column > <apex:facet name="header"><b>Name</b></apex:facet> {!aOrder.corder.Name} </apex:column> <apex:column > <apex:facet name="header"><b>Amount</b></apex:facet> {!aOrder.corder.Amount__c} </apex:column> <apex:column > <apex:facet name="header"><b>Commission</b></apex:facet> {!aOrder.Commission_Amount} </apex:column> </apex:dataTable> </apex:pageBlock> </apex:form> </apex:page>
Jeff
Also, if you want this property to be public then I don't think you need the getter method that returns this property, i.e. you can remove this:
as you can bind directly to properties which has the same behavior as a getter method.
Message Edited by mtbclimber on 01-11-2009 12:45 PM
I've added your change. Now, I've uncommented the references to MyComm in my code but, I get this error:
Error: Compile Error: Variable does not exist: MyComm.Variable_Salary__c at line 47 column 50.
My custom object Commission__c includes Variable_Salary__c and Quota__c.
Can I access the MyComm values throughout the controller?
Jeff