Question

I have the following line in a JSF page:

<h:commandLink action="#{myBean.test}" value="Wizard Step"></h:commandLink>

I expect that when the page is loaded, the Bean corresponding to myBean will be instantiated (and I'll be able to see this in the eclipse debugger).

The rest of the JSF is working correctly, but this bean is not resolving (without any error).

How do I get the errors from the el failing to resolve the bean?

Was it helpful?

Solution

If there are EL errors, you will surely get an exception of javax.el package:

  • ELException: Represents any of the exception conditions that can arise during expression evaluation.
  • MethodNotFoundException: Thrown when a method could not be found while evaluating a MethodExpression.
  • PropertyNotFoundException: Thrown when a property could not be found while evaluating a ValueExpression or MethodExpression.
  • PropertyNotWritableException: Thrown when a property could not be written to while setting the value on a ValueExpression.

In your case, the managed bean is not constructed on initial request. This can only mean that the managed bean is not referenced elsewhere in the view. The EL in action attribute is only evaluated when the form is submitted. So the bean will only be constructed when the action is invoked. As a test, just put #{myBean} somewhere in the view. You'll see that it get constructed on initial request.

Your real problem is that command button action is simply not invoked, so the EL in its action attribute is simply not evaluated at all. The problem cannot be debugged nor nailed down in the EL side. There are a lot of possible causes for the button action not being invoked. You can find them all here: commandButton/commandLink/ajax action/listener method not invoked or input value not updated. The most common cause among starters is that the button is inside an repeating component like <h:dataTable> whose value is not properly preserved and returns a completely different value during the form submit request, or that the component or one of its components has a rendered attribute which is not properly preserved and defaults to false.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top