1

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?

hawkeye
  • 34,745
  • 30
  • 150
  • 304
  • Show us code for MyBean class – Xorty Jan 14 '12 at 09:02
  • My point is - without looking at the class - is there a way to get Mojarra to spit out the errors it has in trying to resolve el issues. – hawkeye Jan 14 '12 at 09:29
  • I understand now. Everything is OK but after you click on link you'll get something like PropertyNotFoundException because such a bean doesn't exist. And you are trying to prevent having unresolved beans. – Xorty Jan 14 '12 at 10:03
  • That's correct - but I don't get the PropertyNotFoundException. I'm not getting a stacktrace and I'm trying to know what would throw it. – hawkeye Jan 14 '12 at 10:22

1 Answers1

1

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.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555