How to invoke an EJB method without an h:form tag in a JSF page

584 Views Asked by At

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?

2

There are 2 best solutions below

0
On

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}"/>
0
On

It has to be inside a form AFAIK.