Wednesday, August 6, 2014

Call a method in Backing Bean prior to page rendering


A view is rendered by JSF engine in "Render Response Phase". In order to invoke a method right before a View is rendered in the "Render Response Phase", you can use jsf 2.0 <f:event>. This tag is defined in in the meta definition section of a page as follows

<f:metadata>
  <f:event type="preRenderView" listener="#{person.init()}"/>
</f:metadata>

The attributes "listener" and "type" of <f:event> define which method to invoke for an event.
 listener: EL method expression i.e. method to invoke. e.g.#{person.init()}
 type: Name of the event for which to install a listener.

As a result of the above <f:event> declaration, JSF run-time invokes person.init() prior to rendering the components.

The init method (in the "Person" BackingBean) is shown as follows:

public void init() {        
  // do something like get List of persons from database
}

The JSF run-time invokes the method defined by listener, as per the event "type". "type" attribute can take one of the following values

  1. postAddToView:  runs right after the component is added to view during view build time (which is usually during restore view phase, but can also be during render response phase, e.g. navigation).
  2. preValidate:  runs right before the component is to be validated (which is usually during validations phase, but can also be apply request values phase if immediate="true").
  3. postValidate: runs right after the component is been validated (which is usually during validations phase, but can also be apply request values phase if immediate="true").
  4. preRenderView: runs right before the view is rendered during render response phase.
  5. preRenderComponent: runs right before the component is rendered during render response phase.
Note: Above list is from Balusc response on StackOverFlow(http://stackoverflow.com/questions/13999099/jsf-execution-order-of-fevents)


13 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Nice Article. We are authorised support partner in Quickbooks Payroll. If you required any help for Quickbooks Payroll Support Phone Number 1-800-986-4607 if you are Expand your business to a new hike, with progressive approach. Seeking for the best accounting software? Then, get quickbooks installed in your system. The software proves to be more profitable to the business

    ReplyDelete
  3. I did not understand how this information can greatly affect my work, https://www.findwritingservice.com/blog/really-good-online-coursework-writing-services-at-low-cost because it is already clearly defined.

    ReplyDelete
  4. Everything has been interpreted in a proper manner, thank you for publishing such a post! Hope to be provided with more details in the nearest future!

    ReplyDelete
  5. HVAC & Plumbing Services
    Air Star Heating guarantees reliability and quality for all equipment and services.

    Air Star Heating specialists always try to deliver the most excellent quality of services to our customers at an affordable price. It is understood that every client has different needs and different problems. We try to accomplish the needs of every client according to their requests. We are having considerable experience in this field. Our specialists understand very well how things work. It doesn’t matter in which field of industry you are looking for services.
    Plumbing & HVAC Services in San Diego. Call now (858) 900-9977 ✓Licensed & Insured ✓Certified Experts ✓Same Day Appointment ✓Original Parts Only ✓Warranty On Every Job.
    Visit:- https://airstarheating.com

    ReplyDelete
  6. köp ketamin
    comprare la ketamina
    買氯胺酮
    ketamint vásárolni
    kupiti ketamin
    Ketamin kaufen
    comprar cetamina
    pirkti ketamino
    osta ketamiini
    osta ketamiini veebis
    pirkti ketamino internete
    comprar cetamina online
    kup ketaminę online
    Ketamin online kaufen
    comprar cetamina online
    купить кетамин онлайн
    kjøp ketamin online
    köp ketamin online
    buy online ketamine
    buy ketamine
    order ketamine online
    ut ketamine online
    beställ ketamin online
    bestill ketamin online
    заказать кетамин онлайн
    Ketamin online bestellen
    online ketamine bestellen
    pedir ketamina en línea




    call/text/whatsapp<<<<<<<< +1(505)257-5355

    email...bcvsgea1124@gmail.com

    ReplyDelete
  7. I need to to thank you for this great read!! I definitely loved every bit of it.
    EVERYTHING YOU NEED TO KNOW ABOUT BLUE COOKIES STRAIN I have got you bookmarked to look at new stuff you

    ReplyDelete
  8. Wishing my love, who loves to wrap me in a bear hug, a happy teddy day! · I wish my teddy bear will always be happy and merry all through life.. Teddy Bear Friendship Quotes

    ReplyDelete