JSF doesn't report undefined beans

I started learning Java, JSF2, and JPA2, and started using the Pet Catalog sample project. I am using Eclipse + Glassfish.

So, I have a JSF view page with the following line:

<h:outputText value="Item #{catalog.pagingInfo.firstItem + 1} .. #{cataloTYPO.pagingInfo.lastItem} of #{catalog.pagingInfo.itemCount}"/> 

cataloTYPO does not exist, it is not a bean, not a class, nothing. The problem is that the JSF seems to be fully satisfied with this and displays "Item 1 .. of 29". I expect this to throw an exception, or at least write a problem to register, but nothing happens.

I tried to solve this problem, but no one sees it.

Thanks for the help.

EDIT: alternatively is this normal behavior?

+4
source share
1 answer

This does not apply to JSF. This is specific to EL (those #{} things). It was designed as unsafe. If there is nothing in the area, i.e. This is null , then it simply will not take any further action. It does not print anything and a NullPointerException will not be NullPointerException . This is especially useful when the empty situation is resolved.

If you still want to throw exceptions or warn reports, you will have to write your own ELResolver , which does this when the allowed value is null . A good article on implementing your own ELResolver for JSF can be found here .

+6
source

Source: https://habr.com/ru/post/1338173/


All Articles