Rewrite, JSF2 ActionListener navigation

Splash Forums Rewrite Users Rewrite, JSF2 ActionListener navigation

This topic contains 2 replies, has 2 voices, and was last updated by  tohu 1 month, 1 week ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #27417

    tohu
    Participant

    Hi,
    I currently am deploying websphere application with Jsf 2.2.1 and Rewrite 2.0.12, along with the rewrite integration for faces.

    I’m looking at a commandLink something like this:

    <h:commandLink value="Do a thing" actionListener="#{bean.doThat}">
        <f:attribute name="something" value="#{somevalue}"></f:attribute>
    </h:commandLink>

    With a matching action listener method in the bean like so

    
    public void doThat(ActionEvent e) throws IOException
    {
        Object o = e.getComponent().getAttribute().get("something");
         
        FacesContext.getCurrentInstance().getExternalContext().redirect("/nextPage");
    }
    

    My application configuration has this rule:

    .addRule(Join.path("/nextPage")).to("/faces/directory/subdirectory/nextPage.xhtml"))

    Which all works, that’s great….but..

    Is there a nicer way to do this? I really like how action methods work by returning Navigation objects.

    I’ve tried returning a Navigation object with the actionListener, but that didn’t work. Likewise returning a string “/nextPage”, or even “/directory/subdirectory/nextPage.xhtml” does not work. They all simply act as post backs and “refresh” the page.

    So if there is anyway to make the actionListener navigation a little more like an action navigation, I would be very pleased to find out.

    #27418

    I agree that this way of navigating isn’t very nice. But why do you use actionListener and not a standard action? As actionListener don’t allow do trigger navigation directly, things are getting dirty. 😉

    You COULD perhaps use the JSF NavigationHandler for navigation. In this case you could even use the Navigate class, but that could may be even more ugly.

    #27419

    tohu
    Participant

    Yes you are right, I think this was a habit picked up from jsf 1.2 and richfaces.

    There is definitely several other means of doing what we want here, so I’ll just change it up.

    Thanks.

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

You must be logged in to reply to this topic.

Comments are closed.