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

Help needed with update of Custom object with input values from Apex page
I have a payment object that has 2 properties amount and date. I have the following code in the Apex page and Controller that displays existing payments. I want to update amount of one payments and save it. What scode should i write in the save method to acheive this. I know i have to call update payment on the save method but i am not able to retrieve the user input from the page in my controller.
public with sharing class PaymentDetailsController
{
public Decimal amount_c{get; set;}
public Datetime date_c{get; set;}
public PageReference save()
{
Payment__c pc = new Payment__c();
pc.Amount__c = amount_c;
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'Amount - '+ pc.Amount__c ); ApexPages.addMessage(myMsg);
return null;
}
List<Payment__c> payments = new List<Payment__c>();
public PaymentDetailsController()
{
processLinkClick();
}
public void processLinkClick()
{
payments = [SELECT Id , Payment__c.Contact__c, Amount__c, Date__c FROM Payment__c WHERE Amount__c > 0 and Payment__c.Contact__c =: ApexPages.currentPage().getParameters().get('contactid')];
}
public List<Payment__c> GetPaymentDetails()
{
return payments;
}
}
<apex:page controller="PaymentDetailsController" tabStyle="Payment__c" >
<apex:form >
<h1>{!$CurrentPage.parameters.contactid}</h1>
<apex:pageBlock title="Payment Details">
<apex:pageblockSection >
<h1>Page Messages:</h1>
<apex:pageMessages showDetail="true" id="msg"/>
</apex:pageblockSection>
<apex:pageBlockTable value="{!PaymentDetails}" var="pd">
<apex:column HeaderValue="Amount">
<apex:inputField value="{!pd.Amount__c}" id="amount_c" />
</apex:column>
<apex:column headerValue="Date">
<apex:inputField value="{!pd.Date__c}" id="date_c"/>
</apex:column>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
Please check this out... this will work for your requirements.
Controller:
Visualforce Page
All Answers
Please check this out... this will work for your requirements.
Controller:
Visualforce Page
Thanks alot. It worked perfectly...