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 8039811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:41:50+00:00 2026-06-05T03:41:50+00:00

In a previous question BalusC gave me good advice on how a button, in

  • 0

In a previous question BalusC gave me good advice on how a button, in place of a commandButton is useful for non ajax navigation. In particular it updates the destination address in the http: position which is useful for the user to bookmark a page.

I tried to use this information to my advantage until I came upon a problem. In a button I tried to use outcome=”#{backing.something}” to find out that it gives me a null result. This looks like a timing problem in that action=”#{}” is evaluated only when the button is pressed whereas outcome apparently wants a fixed string which gets checked when the page is loaded.

So I went back to commandButton with ajax=”false”. This has a problem that my navigation address is the page I came from, not the one I am navigating to. This is the wrong bookmark for the user.

I appreciate all the help I have received in stackoverflow on my learning exercise.
Ilan

  • 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-06-05T03:41:51+00:00Added an answer on June 5, 2026 at 3:41 am

    The <h/p:button outcome> is not intented to invoke a bean action method, but to contain the outcome string directly. Any EL in there is evaluated immediately as a value expression. So the method behind it would immediately be invoked when you just open the page containing the <h/p:button>.

    There are in your particular case basically two ways to invoke a bean action method on navigation. If you need to invoke it before the navigation takes place and the action isn’t intented to be re-invoked everytime when the enduser reopens/reloads the GET request, then make it a POST-Redirect-GET request. It’s a matter of adding faces-redirect=true to the outcome value in query string syntax.

    E.g.

    <p:commandButton action="#{bean.submit}" ... />
    

    with

    public String submit() {
        // ...
    
        return "nextpage?faces-redirect=true";
    }
    

    This way the browser will be redirected to the target page after POST, hence the enduser will see the target URL being reflected in the address bar.

    Or if you need to invoke the action everytime when the enduser reopens/reloads the GET request, do the job in the (post)constructor or preRenderView listener method of the request/view scoped backing bean instead.

    E.g.

    <p:button outcome="nextpage" ... />
    

    with

    @ManagedBean
    @RequestScoped
    public class NextpageBacking {
    
        public NextpageBacking() {
            // In constructor.
        }
    
        @PostConstruct
        public void onPostConstruct() {
            // Or in postconstructor (will be invoked after construction AND injection).
        }
    
        public void onPreRenderView() {
            // Or before rendering the view (will be invoked after all view params are set).
        }
    
        // ...
    }
    

    The pre render view listener method needs to be definied as follows in the nextpage

    <f:event type="preRenderView" listener="#{nextpageBacking.onPreRenderView}" />
    

    See also:

    • What can <f:metadata>, <f:viewParam> and <f:viewAction> be used for?
    • Communication in JSF 2.0 – Processing GET request parameters
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is directly related to my previous question ASP.NET AJAX Is it possible
In previous question of mine, someone had meantioned that using Semaphores were expensive in
This question is related to a previous question of mine That's my current code
This question follows on from a previous question, that has raised a further issue.
This question is related to my previous question How to generate Cartesian Coordinate (x,y)
This question is related to my previous question . The storyline: I have an
This question is a continuation of my previous question here zend models architecture (big
This question is in continuation to my previous question . I am trying to
This question is related to my previous question - MySQL query to show records
This question follows on from a previous question. However stackoverflow presents me from commenting

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.