问题
You are analyzing the Facelets code of a very large JSF web application written by others (e.g. during a production incident) and you want to find the bean class that is implementing a bean, knowing its name as it comes in EL expression.
You didn't write it and the bean's name does not match any Java class in the project.
You can't assume that the class is annotated.
While there are several methods to reach to the same result, I hope this question can document the best practices to solve this problem.
NOTE: This question is not about how to enable an IDE option to do so, it is about how to deal with it, without IDE support. I have made many searches and haven't found this question in StackOverflow, in the terms expressed here.
回答1:
Print it!
(-) Requires to redeploy.
- Edit the XHTML file to write out the class' name
<!-- #{msg.getClass().getSimpleName()} -->
Redeploy the modified XHTML file
Reload the page
Look for Annotations
(-) Not always works
- Search for the annotation ("@ManagedBean") across the workspace and find the annotation.
Look in Face-Config
- Search in faces-config.xml (e.g. ResourceBundles)
IDE Support
- E.g. Eclipse with JBoss Tools EL proposals / autocomplete / code assist in Facelets with Eclipse
来源:https://stackoverflow.com/questions/48608449/finding-a-jsf-managed-bean-implementation-class-while-analyzing-facelets-code