CaptainB
CaptainB

Reputation: 51

Primefaces - Cant find method when passing parameter to action

I am trying to pass parameters to my backing bean using action (testPlan and rowIndex). But when I run the code it says it can't find the method.

<p:commandLink update=":scriptGroupPopupID" ajax="true"
               action="#{workloadScripts.initCurrentGroup(testPlan, rowIndex)}"
               immediate="true"
               oncomplete="PF('scriptGroupPopup').show();">
    <f:param name="insertIndex" value="#{rowIndex}" /> 
</p:commandLink>
public void initCurrentGroup(String testPlan, String rowIndex) {
    ...
}

However, if I remove the parameters from initCurrentGroup method only, it does work. What is going on here?

Upvotes: 0

Views: 244

Answers (1)

Jasper de Vries
Jasper de Vries

Reputation: 20253

The type of the rowIndexVar variable is an int. You must use a matching method signature. Assuming testPlan is indeed a String, you should use:

public void initCurrentGroup(String testPlan, int rowIndex) {
    ...
}

Which you can use like:

<p:commandLink update=":scriptGroupPopupID"
               action="#{workloadScripts.initCurrentGroup(testPlan, rowIndex)}"
               process="@this"
               oncomplete="PF('scriptGroupPopup').show();" />

Please note that I've removed ajax="true" (which is default), and replaced immediate="true" with process="@this".

See also:

Upvotes: 1

Related Questions