Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PhaseListener is called twice

RohitKFeb 10 2017 — edited Feb 10 2017

Hello,

I have implemented PagePhaseListener and Following is the beforePhase() method.

public void beforePhase(PagePhaseEvent pagePhaseEvent) {

        if (pagePhaseEvent.getPhaseId() == Lifecycle.PREPARE_MODEL_ID) {            

            if (!isPostback()) {               

               System.out.println("beforePhase() is called.");

            }           

        }

    }

private boolean isPostback() {

    FacesContext facesContext = FacesContext.getCurrentInstance();

    Application app = facesContext.getApplication();

    ExpressionFactory elFactory = app.getExpressionFactory();

    ELContext elContext = facesContext.getELContext();

    ValueExpression valueExp =

        elFactory.createValueExpression(elContext, "#{adfFacesContext.postback}", Object.class);

    return Boolean.TRUE.equals(valueExp.getValue(elContext));

but on page load I got this output in console.

beforePhase() is called.

beforePhase() is called.

as it is called twice.

I checked that I have not declared context parameter for faces-config.xml in deployment descriptor.

I have also checked by removing the af:resources which includes resource files in order to check absolute path problem but still beforePhase() is called twice.

I am using jDeveloper 11g.

Please advice on the same.

Thanks.

This post has been answered by Srini Mad on Feb 10 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 10 2017
Added on Feb 10 2017
2 comments
453 views