Reputation: 1898
I'm doing a simple logout and want to make sure i'm referencing correctly to the login root.
<h:form>
<h:commandLink value="Logout" action="#{request.contextPath}/#{userController.logout()}" />
</h:form>
but i get this error:
/topnav.xhtml @16,104 action="#{request.contextPath}/#{userController.logout()}" Not a Valid Method Expression: #{request.contextPath}/#{userController.logout()}
UPDATE
Right now I'm adding navigation rules from the logout link to the login page and since the logout link is on all pages i need to add rules to allow the transition back to the login page. that seems like a lot of configuration for a simple item. would prefer to just have the method called indicate that the login page the the final destination and hot have to place a navigation entry from all pages to the login page.
Upvotes: 0
Views: 1314
Reputation: 108969
From the documentation for commandLink:
Name Required Request-time Type
==============================================================
action false false javax.el.MethodExpression
The composite expression #{request.contextPath}/#{userController.logout()}
cannot be resolved as a MethodExpression.
The JSF 2.1 specification says of MethodExpressions:
Method expressions are a very similar to value expressions, but rather than supporting the dynamic retrieval and setting of properties, method expressions support the invocation (i.e. execution) of an arbitrary public method of an arbitrary object, passing a specified set of parameters, and returning the result from the called method (if any).
Upvotes: 5
Reputation: 4785
try
<h:form>
<h:commandLink value="Logout" action="#{userController.logout()}" />
</h:form>
beside the fact that you do not need context, you can not use #
twice the way you are using it.
Upvotes: 1