Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6592871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:36:38+00:00 2026-05-25T17:36:38+00:00

I’m using JSF 2 and PrimeFaces 2.1 on GlassFish. I have a page that

  • 0

I’m using JSF 2 and PrimeFaces 2.1 on GlassFish.

I have a page that is intended to allow people to perform an action after following a callback URL (e.g. as link embedded in email or as callback URL parameter of some external authentication or payment service). In my case I need to reset the password. The callback URL has a token GET parameter like so:

http://example.com/app/resetPasswordForm.jsf?token=abc123

On page load of resetPasswordForm.jsf, I need to check if the token is valid and redirect to the main app screen if it’s not valid.

My thinking is to have a bean method like:

public String resetPasswordHandler.showResetForm(String token) {
  if /* token is valid */ {
    return "resetPasswordForm.jsf";
  } else {
    return "main.jsf";
  }
}

But how would I cause that method to get hit on page load?

Not sure how to proceed — suggestions are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:36:39+00:00Added an answer on May 25, 2026 at 5:36 pm

    Use <f:viewAction> to trigger a bean method before rendering of the view and simply return a navigation outcome (which will implicitly be treated as a redirect).

    E.g.

    <f:metadata>
        <f:viewParam name="token" value="#{authenticator.token}" />
        <f:viewAction action="#{authenticator.check}" />
    </f:metadata>
    

    with

    @ManagedBean
    @RequestScoped
    public class Authenticator {
    
        private String token;
    
        public String check() {
            return isValid(token) ? null : "main.jsf";
        }
    
        // Getter/setter.
    }
    

    If you’re not on JSF 2.2 yet, then you can use the <f:event type="preRenderView"> workaround in combination with ExternalContext#redirect().

    <f:metadata>
        <f:viewParam name="token" value="#{authenticator.token}" />
        <f:event type="preRenderView" listener="#{authenticator.check}" />
    </f:metadata>
    

    with

    @ManagedBean
    @RequestScoped
    public class Authenticator {
    
        private String token;
    
        public void check() throws IOException {
            if (!isValid(token)) {
                FacesContext.getCurrentInstance().getExternalContext().redirect("main.jsf");
            }
        }
    
        // Getter/setter.
    }
    

    See also:

    • Communication in JSF 2.0 – Processing GET request parameters
    • What can <f:metadata>, <f:viewParam> and <f:viewAction> be used for?
    • How do I process GET query string URL parameters in backing bean on page load?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.