0

I am trying to parametrize the action attribute of <h:commandLink> in an include file:

<ui:include src="template-file.xhtml">
     <ui:param name="actionToCall" value="actionSave" />
     <ui:param name="actionLabel" value="actionLabel" />
</ui:include>

Where the template-file.xhtml contains:

<h:commandLink action="#{actionToCall}" value="#{actionLabel}" />

but I am getting the following exception:

javax.el.ELException: /page.xhtml @17,45 action="#{actionToCall}": 
     Identity 'actionToCall' does not reference a MethodExpression instance, 
     returned type: java.lang.String

I want it to call the spring web flow transition action I put in the actionToCall variable.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Daniel Gray
  • 1,697
  • 1
  • 21
  • 41

1 Answers1

1

Add a .toString after the variable. This gives it a "method expression" (which it is looking for) and allows it to pass through and execute the desired call. The tag ends up looking like:

<h:commandLink action="#{actionToCall.toString}" value="#{actionLabel}" />
Daniel Gray
  • 1,697
  • 1
  • 21
  • 41
  • Clever trick. This works however only if you abuse POST for navigation. – BalusC Sep 16 '16 at 20:47
  • It's just an AJAX call to open an edition modal panel :) I have two tabs and two very similar tables but I wanted to call two different Spring WebFlow actions from each table. – Daniel Gray Sep 17 '16 at 10:18