Basic prettyfaces trouble

Splash Forums PrettyFaces Users Basic prettyfaces trouble

This topic contains 4 replies, has 2 voices, and was last updated by  Christian Kaltepoth 6 years, 8 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #17871

    jon
    Participant

    Hello,

    I am trying to create rest like urls for my site using prettyfaces and jsf2.

    However I can’t seem to make it work, even a simple Hello World page. Can anyone point out what I’m doing wrong?

    I’m expecting myurl.com/hello/jon to output “Hello, jon”, but I only get the EL “#{theBean.hello}” in clear text, and no errors. Why?

    Bean:

    @RequestScoped
    @Named
    @URLBeanName("theBean")
    @URLMapping(id = "hello", pattern = "/hello/#{theBean.name}", viewId = "/hello.xhtml")
    public class TheBean {
    private String name;
    private String hello;

    @URLAction
    public String loadHello() {
    hello = "Hello, " + name;
    return null;
    }

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public String getHello() {
    return hello;
    }

    public void setHello(String hello) {
    this.hello = hello;
    }
    }

    hello.xhtml has: #{theBean.hello}

    pretty-config.xml only contains root tag as I’m using annotations

    Using PrettyFaces 3.2.0

    Any help would be great, thanks

    #20681

    I think you will have to change the viewId to something like /hello.jsf (depends on the mapping of the FacesServlet). It must contain a valid view ID like you would use in an application without PrettyFaces.

    #20682

    jon
    Participant

    The viewId is valid (I have mapped FacesServlet to *.jsf).

    Here’s my hello.xhtml:

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
    <title>Hello</title>
    </h:head>
    <h:body>
    <p>#{theBean.hello}</p>
    </h:body>
    </html>

    #20683

    jon
    Participant

    Oh sorry my bad, so the viewId must match the facesservlet mapping.

    Got it working now, thanks! :)

    #20684

    No problem! :-)

    Let us know if you have any other problem!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Comments are closed.