Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems in detect an exception thrown in the render response phase using a class that specializes ExceptionHandlerWrapper

I'm trying to implement a mechanism for global exception handling in JSF through specialization of the abstract classes ExceptionHandlerWrapper and ExceptionHandlerFactory. However, when an exception is thrown in the render response phase of the JSF lifecycle, it is not stacked (Phase.queueException is never called) and hence is not captured in the handle method of the class that specializes ExceptionHandlerWrapper.

The following code fragments summarize the situation where the mentioned problem occurs.

JSF:

<h:form id="formManterLider">
    <h:selectOneMenu>
        ...
        <p:ajax update=":formManterLider" listener="#{MB.atualizarListaLideresInstituicao}" />
        ...
    </h:selectOneMenu>

    <p:dataTable value="#{MB.lazyModel}" ... />
</h:form>

Java:

@ManagedBean
@ViewScoped
public class MB {
    ...
    private LazyDataModel<LiderVO> lazyModel = new LazyDataModel<LiderVO>() {
        @Override
        public List<LiderVO> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, String> filters) {
            ...
            List<LiderVO> lista = consultarLideresCandidatos(getInstituicaoSelecionada(), first, pageSize); // throws a RuntimeException
            return lista;
        }
    };
}

Changing the selection value in the h:selectOneMenu component through an AJAX request triggers the problem, because the statement update=":formManterLider" causes the method load to be invoked during the render response phase, and the method consultarLideresCandidatos, which is invoked within the load method, throws a RuntimeException.

I would like to know how to detect an exception thrown in the render response phase using a class that specializes ExceptionHandlerWrapper.

Note: I'm using Mojarra 2.1.12 and Primefaces 3.2.

like image 365
rodhersoa Avatar asked Nov 19 '25 22:11

rodhersoa


1 Answers

I had exactly the same issue (LazyDataModel + exception in the render phase). Try Mojarra 2.1.16 or greater. See http://java.net/jira/browse/JAVASERVERFACES-2179

like image 125
cerdoc Avatar answered Nov 22 '25 17:11

cerdoc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!