user2061913
user2061913

Reputation: 920

How to add navigation to backing bean

A simple issue, but can't remember how to do it best. What I want is to automatically send the user to another page "/lecturer/marking/marking-section-two" after a code section is run.

Is there a way of doing this in the backing bean that won't effect the ajax message displayed before it ?

This is the code i am running

public void markSectionOne() {
    //supposing the data in markSectionOne is filled...
    this.markingFacade.create(markSectionOne);
    this.setMessage("Mark Saved");
    //after saving...
    markSectionOne = new Marking();
    // now navigating to the next page
} 

and once it's run I want to navigate automatically to a new page.

Thanks guys

Upvotes: 0

Views: 57

Answers (1)

LaurentG
LaurentG

Reputation: 11757

You can change your method to return a String which will be interpreted as the next navigation outcome.

public String markSectionOne() {
    // ... unrelevant code
    return "/lecturer/marking/marking-section-two";
}

If the method returns null, then JSF will stay on the same page.

Upvotes: 2

Related Questions