This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 196873 - Code completion is not working for expression language
Summary: Code completion is not working for expression language
Status: RESOLVED WORKSFORME
Alias: None
Product: javaee
Classification: Unclassified
Component: Expression Language (show other bugs)
Version: 7.0.1
Hardware: PC Other
: P3 normal with 1 vote (vote)
Assignee: Marek Fukala
URL:
Keywords:
Depends on:
Blocks: 198042
  Show dependency tree
 
Reported: 2011-03-19 12:46 UTC by averri
Modified: 2012-10-10 13:26 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
EL code completion dialog example (44.46 KB, image/png)
2011-04-18 16:00 UTC, jfosterjr
Details

Note You need to log in before you can comment on or make changes to this bug.
Description averri 2011-03-19 12:46:16 UTC
I would like to report that the code completion is not working for expression language. For example, suppose the following code:

@Named
public class Message {
    public String getMessage() {return "Hi";}
}

Now, create a new XHTML file and invoke code completion inside a "#{}". Netbeans will not recognize the Message class anotated with '@Named'.

This works fine in Netbeans 6.9.1, but fails in latest nightly build.
Comment 1 Marek Fukala 2011-03-21 08:52:16 UTC
Works fine for me. Can you please specify in what kind of project this does happen? Or does this happen only in a particular project? If so, can you pack and attach it here? Thank in advance.
Comment 2 averri 2011-03-30 12:45:04 UTC
Hi!

The problem occurs with Maven based web projects.

Please, check it again:

Create a new Maven web project and do the steps described.



(In reply to comment #1)
> Works fine for me. Can you please specify in what kind of project this does
> happen? Or does this happen only in a particular project? If so, can you pack
> and attach it here? Thank in advance.
Comment 3 averri 2011-03-30 12:49:32 UTC
I forgot to mention: the problem affects Netbeans 7.0 RC1.




(In reply to comment #2)
> Hi!
> 
> The problem occurs with Maven based web projects.
> 
> Please, check it again:
> 
> Create a new Maven web project and do the steps described.
> 
> 
> 
> (In reply to comment #1)
> > Works fine for me. Can you please specify in what kind of project this does
> > happen? Or does this happen only in a particular project? If so, can you pack
> > and attach it here? Thank in advance.
Comment 4 Marek Fukala 2011-03-31 13:47:22 UTC
I've tried following scenario:
1) run the latest dev build w/ brand new userdir
2) create maven web project
3) built the project
4) created a new java class beans.MyBean
5) added javax.inject.Named annotation to the class
6) added public String getMessage() {} method
7) created a new xhtml file
8) put #{} inside
9) invoked completion inside the curly brackets
=> the completion offers "myBean" item properly.
10) completed the item
11) typed . and invoked the completion again
=> the completion properly offers "message" item

I'm sorry but since I cannot reproduce the issue I cannot do much for you. Could you please try to follow exactly all the steps above and report any differencies in the flow?

I'd also like to ask our quality engineer Vlada for evaluation of the problem.
Comment 5 Vladimir Riha 2011-04-04 07:56:11 UTC
Works for me too, in both dev and rc2 build
Comment 6 jfosterjr 2011-04-18 16:00:24 UTC
Created attachment 107817 [details]
EL code completion dialog example
Comment 7 jfosterjr 2011-04-18 16:03:39 UTC
Code completion appears to work for me for bean properties and action methods although the code completion dialog now has everything in alphabetical order as opposed to the application specific named beans first then the implicit attributes following.  I am seeing what I perceive as an issue with EL code completion with regards to resource bundles.  

Given a properties file with a FQN of test.Messages and content including:

TEST_MESSAGE=This is a test message

Add a Faces Configuration file as follows:

<?xml version='1.0' encoding='UTF-8'?>

<faces-config version="2.0"
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">

    <application>
        <locale-config>
            <supported-locale>en</supported-locale>
            <default-locale>en</default-locale>
        </locale-config>
        <resource-bundle>
            <base-name>test.Messages</base-name>
            <var>msg</var>
        </resource-bundle>
    </application>
    
</faces-config>

Spice up the web app with a named bean as follows:

package test;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

@Named(value = "myBean")
@RequestScoped()
public class MyBean {

    private String testString1;

    public String getTestString1() {
        return testString1;
    }

    public void setTestString1(String testString1) {
        this.testString1 = testString1;
    }

    private String testAction() {
        return null;
    }
}

I then add an index.xhtml file as follows:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        Hello from Facelets
        <h:form id="f" prependId="false">
            <h:inputText id="it1" value="#{myBean.testString1}"/>
            <h:outputText value="#{msg['TEST_MESSAGE']}"/>
        </h:form>
    </h:body>
</html>

This will render just fine.  The problem is that during development the code completion dialog, when invoked to the right of the open EL bracket, will show an entry properly named "myBean" but the resource bundle shows up as "test.Messages" rather than the var name ("msg") given in the faces-config file.

Screen capture of code completion dialog attached.
Comment 8 tosamoodnowa 2011-04-19 10:45:58 UTC
(In reply to comment #4)
> I've tried following scenario:
> 1) run the latest dev build w/ brand new userdir
> 2) create maven web project
> 3) built the project
> 4) created a new java class beans.MyBean
> 5) added javax.inject.Named annotation to the class
> 6) added public String getMessage() {} method
> 7) created a new xhtml file
> 8) put #{} inside
> 9) invoked completion inside the curly brackets
> => the completion offers "myBean" item properly.
> 10) completed the item
> 11) typed . and invoked the completion again
> => the completion properly offers "message" item
> 
> I'm sorry but since I cannot reproduce the issue I cannot do much for you.
> Could you please try to follow exactly all the steps above and report any
> differencies in the flow?
> 
> I'd also like to ask our quality engineer Vlada for evaluation of the problem.

The problem occurs when you change pom.xml 
from:
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
to:
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>

maybe it will help in solving the problem
Comment 9 Marek Fukala 2012-10-10 13:22:37 UTC
(In reply to comment #7)
> an entry properly named "myBean" but the resource bundle shows up as
> "test.Messages" rather than the var name ("msg") given in the faces-config
> file.
> 
> Screen capture of code completion dialog attached.
I've checked in latest dev build and it works fine - the completion list shows item "msg   test.Messages" and "msg" is completed if you press enter on the completion item.
Comment 10 Marek Fukala 2012-10-10 13:26:45 UTC
> The problem occurs when you change pom.xml 
> from:
>         <dependency>
>             <groupId>javax</groupId>
>             <artifactId>javaee-web-api</artifactId>
>             <version>6.0</version>
>             <scope>provided</scope>
>         </dependency>
> to:
>         <dependency>
>             <groupId>javax</groupId>
>             <artifactId>javaee-api</artifactId>
>             <version>6.0</version>
>             <scope>provided</scope>
>         </dependency>
> 
> maybe it will help in solving the problem

Works fine in 7.3 dev even if I do what you mentioned.