0

I have a dataTable which is iterating over lineItems which is a object of a class InvLineItem ,i need to call a action function which will take InvLineItem object as argument but its working. tested with some other data types like Sting or number,Its working with them, Please tell me if there is any way to do this??

Page

<apex:dataTable id="LineItem" value="{!lineItems}" var="lineItemSUT">  
<script>  
onChangeProduct(lineItemSUT);  
</script>   
</apex:dataTable>  
<apex:actionFunction name="onChangeProduct"  action="{!updateProductItem}" oncomplete="CODA.resumeQueueProcessing(); >   
    <apex:param name="lineItemSUTParam" assignTo="{!lineItem}" value="" />  
</apex:actionFunction>  

Controller

 InvLineItem lineItem{get;set;}

 public InvLineItem[] getLineItems()
 {
         lineItem.callOtherFunc();
 }

  public void updateProductItem()
  {

  }
Keith C
  • 135,775
  • 26
  • 201
  • 437
Vikas Khandelwal
  • 512
  • 1
  • 5
  • 15

1 Answers1

1

The apex:param documentation confirms that:

The value attribute must be set to a string, number, or boolean value.

A common approach is to pass an object ID (yeah the documentation doesn't mention that) and then in your Apex logic query for or otherwise find the matching object.

For your case where you are using an inner class, you will need to add some sort of ID that you populate to your LineItem inner class (could be as simple as an index number 0, 1, 2 3 etc) and then you can use code like this to find the matching item:

// apex:param sets this value
String lineItemId {get; set;}

// Keep hold of all the line items
InvLineItem[] lineItems {get; set;}

// Returns the selected item
InvLineItem lineItem {
     get {
         for (LineItem li : lineItems) {
             if (li.id == lineItemId) {
                 return li;
             }
         }
         return null;
     }
}
Keith C
  • 135,775
  • 26
  • 201
  • 437