1

I have got a view and a bean, here is my problem? i try to make some jsf navigation? and add method that return navigation link? but when i click button it send request but method never invoked. I think i made very simple mistake but can't understand where please help me.

It is my view code:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="include/template/Layout.xhtml">
    <ui:define name="body">
        <h:outputText value="Test text"/>
        <h:outputText value="#{navigationBean.test}"/>
        <div/>
        <p:commandLink value="About Page" action="#{navigationBean.goToAbout}"/>
    </ui:define>
</ui:composition>

</html>

It us my bean code:

@ManagedBean(name = "navigationBean")
@SessionScoped
public class NavigationBean implements Serializable {

    public String goToAbout(){
        return "About?faces-redirect=true";
    }

    public  String getTest(){
        return "test";
    }

}

It is my output page:

Test texttest
About Page
Andrew
  • 266
  • 6
  • 18

1 Answers1

5

I think the error here is as simple as you said, you didn't define a form in your page, try:

<h:form>
  <h:outputText value="Test text"/>
  <h:outputText value="#{navigationBean.test}"/>
  <div/>
  <p:commandLink value="About Page" action="#{navigationBean.goToAbout}"/>
</h:form>
Laabidi Raissi
  • 3,263
  • 1
  • 22
  • 28