I have this Visualforce code snippet in a page:
<apex:outputLink value="javascript:if (window.confirm('Are you sure?')) DeleteQuoteLineItem('{!LineItem.QuoteLineItem.Id}');">
Del
</apex:outputLink>
<apex:actionFunction action="{!DeleteQuoteLineItem}" name="DeleteQuoteLineItem" reRender="content">
<apex:param value="test"/>
</apex:actionFunction>
The two methods I'm using for testing are:
public void DeleteQuoteLineItem(String RecordID)
{
System.debug('method with a paramater');
System.debug(RecordID);
}
public void DeleteQuoteLineItem()
{
System.debug('method without a parameter');
}
Everytime I click on the link to execute the apex:actionFunction
, it's calling the DeleteQuoteLineItem()
method without any parameter. I looked online and it seems like I need to create a class attribute and use assignTo=
in my apex:param
to populate it accordingly.
Is it possible to prevent this behavior and use standard method parameters, so I don't have to create class attributes? I want to work on a clean and optimized codebase, preventing unnecessary variable scope (so no class attribute when it's not required) and improve code re-usability by staying context agnostic.
Thanks
action:actionFunction
to be available in all the class, it's pointless :)!