in Education by
I have an JSF page backed by NewsBean.java which has as bean initializer. There is a button at the bottom of the page for sending comments which has: and is surrounded by an . When button is clicked, NewsBean.init() is always called. My bean scope is view. Is this a valid behavior (calling always init())? How can I prevent always calling init()? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
A preRender listener is always invoked on pre render event, regardless of if it's an initial request or a postback request. Every single request has a render response phase, regardless of if it's a normal request or ajax request. So this behaviour is by specification. You need to check yourself in the listener method if it's a postback request or not by checking FacesContext#isPostback(). public void sendComment() { if (!FacesContext.getCurrentInstance().isPostback()) { // ... } } The (where Xxx can be View or Component) is by the way in essence a "workaround approach" for the functional requirement of being able to invoke a bean action method after the view parameters are been processed on the initial request. In the upcoming JSF 2.2 a new tag will be introduced which should do exactly the job as intented: This tag supports an onPostback attribute which already defaults to false: JSF 2.2 will be released the first quart of 2012. Snapshot releases of JSF 2.2 are currently already available.

Related questions

0 votes
    I have an JSF page backed by NewsBean.java which has as bean initializer. There is a button at ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 9, 2022 in Education by JackTerrance
0 votes
    Which function is called when the following Python program is executed? f = foo() format(f) a) str() b) format() c) __str__() d) __format__()...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    Which function is called when the following Python program is executed? f = foo() format(f) a) str() b) format() c) __str__() d) __format__()...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    Considering this code, can I be absolutely sure that the finally block always executes, no matter what ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    Considering this code, can I be absolutely sure that the finally block always executes, no matter what ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    Considering this code, can I be absolutely sure that the finally block always executes, no matter what ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    Educating inscription then no other process can be executed in their critical section this condition is called Select the correct answer from above options...
asked Dec 20, 2021 in Education by JackTerrance
0 votes
    The square of the correlation coefficient r 2 will always be positive and is called the ________ (a) Regression ( ... of R Programming Select the correct answer from above options...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    What will be the output of log (-5.8) when executed on R console? (a) NAN (b) NA (c) Error ... Functions and Debugging of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    Simran write a code print: (“hello friends”)but when she executed there comes an error what was the error and why did it occur Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    _________ refers to an undesirable state when a system attempts to perform two or more operations, which should, ... condition 2. Optimistic locking 3. Locking 4. Transaction...
asked Apr 12, 2021 in Technology by JackTerrance
0 votes
    If you connect to a database or a file in a program you should always __________ it when you’re finished using it. Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    When working with Ajax applications, which is faster, XML or JSON? A. XML, because it is extensible B. JSON, ... D. JSON, because it is already parsed into a JavaScript object...
asked Mar 10, 2023 in Technology by JackTerrance
0 votes
    My question is a variant of the question here However, there are two differences: I don't know how ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
...