1

I understand that JSF 2.0 uses convention to locate a class for a managed bean.

<h:outputText value="#{productCode.productCode.prodCode}" title="ProdCode" />

In this code we will not know if the class ProductCode exists and if it has a member named productCode until execution time is in this page.

Is there any chance to know name issues in compilation time ?

JonathanVila
  • 169
  • 1
  • 11
  • 1
    Only using an IDE like NetBeans 7.x or Eclipse with JSF Tools. Still, the pages will compile with no problems but will give you a warning about missing managed beans/properties – Luiggi Mendoza May 25 '12 at 16:04

1 Answers1

2

This problem is not specific to JSF. This problem is specific to the development toolset used. It's unclear which one you're using. If you're using Notepad, you're really out of luck. But in case of Eclipse you'd like to install JBoss Tools. It offers among others EL autocompletion and Ctrl+Click navigation.

enter image description here

Assuming that you're using the current Indigo SR2 "Eclipse IDE for Java EE Developers", Go to Help > Install New Software and enter the following URL:

http://download.jboss.org/jbosstools/updates/indigo/SR2/

In the list, just pick "JBoss Web and Java EE Development" option (others are not required).

Note that it's not possible to force kind of an "compilation error" because the attributes can be programmatically manipulated. How smart an IDE also can be, it's hardly possible to detect that based on Java source code and that would only generate false negatives.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • We use Netbeans 7.1. I think it's a problem similar to JPQL queries inside Strings .... Just to resolve that we use LiquidForm to know in compilation time if there are members or classes name issues. I know that JPA 2 has now the criterias to solve this. – JonathanVila May 25 '12 at 20:18
  • We have little experience in JSF and this is a problem we think may happen. If someone creates a JSF page, using a managed bean, but in time someone changes the name of a member used in that page, we will not know until the customer goes to that page ... a situation we would like to avoid. – JonathanVila May 25 '12 at 20:34
  • That's exactly why unit testing was invented. Just create some JUnit/Selenium tests and throw it in the build process. – BalusC May 25 '12 at 20:40
  • IMHO Unit Testing is not intended to solve it....you can use it, but you are not doing UnitTesting with Selenium...you are Functional and Screen testing. It's the same as we were unable to see compile errors but only execution errors in our IDE.....it's not the way. – JonathanVila Jun 14 '12 at 07:53