1

I want to invoke an EJB method when I click a link in my JSF website. At the moment I use an h:commandLink within an h:form tag to trigger the EJB method:

<h:form>
  <h:commandLink value="Logout" action="#{loginBean.logout}"/>
</h:form>

Is there a way to do the same without the need of an h:form tag?

Benny Code
  • 51,456
  • 28
  • 233
  • 198
  • 1
    Guess, your current solution is a good one. You could try calling a URL and via `f:viewParam` call the EJB from the xhtml-template - this is a theoretical possibility. Check out http://stackoverflow.com/questions/6377798 for details. – L-Ray Jan 08 '14 at 22:22

2 Answers2

1

if you don't want a form (but i don't get why) you can:

  1. navigate to a servlet and execute your code there.
  2. navigate to another jsf page and put your code inside a bean @PostContruct
  3. navigate to another jsf page and put your code inside a bean method and use <f:event type="preRenderView" listener="#{bean.listener}"/>
Michele Mariotti
  • 7,372
  • 5
  • 41
  • 73
-1

It has to be inside a form AFAIK.

Arash
  • 11,697
  • 14
  • 54
  • 81