+ Start a Discussion
PaulATPimptastiPaulATPimptasti 

<apex:param> Assigning to Date Values Sends Null

Hi All,

I have a very odd problem.  I am using an <apex:param> in a <apex:commandLink> to send the details of a payment which consists of strings, numbers and a date to a controller to assign to an sObject.  I had wanted to use the <apex:param> to directly assign an sObject on the Visualforce page direct to the Controller but that caused an error. 

All values apart from the date are recieved and are assigned to the sObject in the controller.

Any assistance would be greatly appreciated as I can't find any information on this error anywhere.

Kind regards

Paul

 

Visualforce Code:

<apex:column >
<apex:commandLink value="Create Invoice" action="{!refreshQuickCreateForm}" rerender="myPanel" status="PageStatus" onclick="YAHOO.foration.com.showMe();">
<apex:param name="payAccount" assignTo="{!QuickInvoicePayment.Payment_Account__c}" value="{!pay.Payment_Account__c}"/>
<apex:param name="payAmount" assignTo="{!QuickInvoicePayment.Payment_Amount__c}" value="{!pay.Payment_Amount__c}"/>
<apex:param name="payDescription" assignTo="{!QuickInvoicePayment.Payment_Description__c}" value="{!pay.Payment_Description__c}"/>
<apex:param name="payDate" assignTo="{!QuickInvoicePayment.Payment_Date__c}" value="{!pay.Payment_Date__c}"/>
<apex:param name="payId" assignTo="{!QuickInvoicePayment.for__Related_Invoice__c}" value="{!pay.Related_Invoice__c}"/>
</apex:commandLink>
</apex:column>

 Controller Code:

public for__Invoices__c quickCreateInvoice = new for__Invoices__c();
public for__Invoice_Line_Item__c quickCreateLineItem = new for__Invoice_Line_Item__c();
public for__Payments__c QuickInvoicePayment {get;set;}

public boolean showQuickCreateLineItems = false;

public for__Invoices__c getQuickCreateInvoice()
{
if(QuickInvoicePayment == null)
{
QuickInvoicePayment = new for__Payments__c();
}

system.debug('Payment = ' +QuickInvoicePayment);

if(quickCreateInvoice.for__Account__c != null)
{
Account tmpAcc = [SELECT for__payment_terms__c FROM Account WHERE Id = :quickCreateInvoice.for__Account__c LIMIT 1];
quickCreateInvoice.for__Invoice_Payment_Terms__c = tmpAcc.for__payment_terms__c;
quickCreateInvoice.for__Invoice_Description__c = dateTime.Now().format();
quickCreateInvoice.for__Invoice_Date__c = QuickInvoicePayment.for__Payment_Date__c;

quickCreateLineItem.for__Opportunity__c = null;
quickCreateLineItem.for__Expenditure_Type__c = null;

showQuickCreateLineItems = true;

}
/*
if(QuickInvoicePayment.for__Related_Invoice__c != null && quickCreateInvoice.for__Account__c == null)
{
system.debug('looking up invoice details');

for__Invoices__c tmpInv = [SELECT Id, for__Account__c, for__Account__r.Name, for__Invoice_Payment_Terms__c, for__Invoice_Description__c, for__Invoice_Date__c, for__Invoice_Type__c FROM for__Invoices__c WHERE Id = :QuickInvoicePayment.for__Related_Invoice__c LIMIT 1];
quickCreateInvoice = tmpInv;

showQuickCreateLineItems = true;

}
*/
system.debug(quickCreateInvoice);

quickCreateLineItem.for__Line_Item_Description__c = QuickInvoicePayment.for__Payment_Description__c;
quickCreateLineItem.for__Line_Item_Unit_Price__c = QuickInvoicePayment.for__Payment_Amount__c;
quickCreateLineItem.for__Line_Item_Unit_Sale_Price__c = QuickInvoicePayment.for__Payment_Amount__c;
quickCreateLineItem.for__Line_Item_VAT_PCT__c = 0;

return quickCreateInvoice;
}

I have also made sure that the values are acutally being rendered to the browser, below is a copy of the page source for the command link.

 

YAHOO.foration.com.showMe();;A4J.AJAX.Submit('_viewRoot','j_id0:j_id114',event,{'status':'j_id0:PageStatus','similarityGroupingId':'j_id0:j_id114:UnassignedPayments:j_id145:2:j_id169','parameters':{'payId':'','payDescription':'WEEDEN P H PAYMENT','myTmpVeryTmpUniqueDate':{'date':11,'day':5,'hours':0,'minutes':0,'month':8,'seconds':0,'time':1252627200000,'timezoneOffset':0,'year':109} ,'payDate':{'date':11,'day':5,'hours':0,'minutes':0,'month':8,'seconds':0,'time':1252627200000,'timezoneOffset':0,'year':109} ,'j_id0:j_id114:UnassignedPayments:j_id145:2:j_id169':'j_id0:j_id114:UnassignedPayments:j_id145:2:j_id169'} ,'actionUrl':'https://for.na5.visual.force.com/apex/matchInvoicePayments'} );return false;

As you can see the date is present, however the debug log only show this:

getQuickCreateInvoice: line 172, column 9: Payment = for__Payments__c:{for__Payment_Amount__c=0, for__Payment_Account__c=, for__Payment_Description__c=, for__Related_Invoice__c=}

Any help would be greatly appreciated.

 

 

 

Message Edited by PaulATPimptasti on 09-17-2009 07:11 AM
Message Edited by PaulATPimptasti on 09-17-2009 07:12 AM
Cool_DevloperCool_Devloper

Hi There,

 

maybe you can pass the values using the Value="" attribute in the page and then get the page parameters in your controller....

 

Cool_D

PaulATPimptastiPaulATPimptasti

Hi Cool_D

 

Yes, I tried that but unfortunately you then have to convert a string to a date which isn't ideal.

 

What I managed to do in the end was to create an indexed list and then pass in the index as a <apex:param> and retrieve the data that way.

 

Found that this was the most reliable way to do it as opposed to having to convert strings using date.newInstance(year,month,day) after splitting the string and converting the string to an integer.

 

Don't suppose you have a more elegant way to do it!

 

Paul