Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

JSF 2 suggestions / auto-complete for Facelets pages not working for annotated @ManagedBean

BonanzaOneJul 29 2015 — edited Feb 18 2016

Hi,


I'm using Eclipse Mars 4.5 with latest OEPE plugin version 12.1.3.7.

Why annotated managed beans @ManagedBean (javax.faces.bean.ManagedBean) are not suggested by the plug-in when coding a facelet page?

I spent hours and the only way I managed to get the plugin suggestions was declaring it in the faces-config.xml.

Steps to simulate the problem:

  1. In Eclipse, create a new Dynamic Web Project - Servlet 2.5 (does not have to be Maven to simulated)
  2. Apply the JSF 2.0 to the project, and in the "further configuration" download the Oracle library 2.0.3 for JSF 2.0.
  3. Create a Java class and annotate it with @ManagedBean.
  4. Create a facelet (xhtml for example) and try to reference the managed bean.
  5. The editor will not suggest the created bean.

I tried a fresh Eclipse installation with no plugins and it worked. Once I installed OEPE (WebLogic Server Tools) the suggestions stopped working. The managed bean is listed in the project structure by AppXRay, but no suggestions.

Disabling AppXRay did not make any efffect.

Let's say I have the following managed bean:

import javax.faces.bean.ManagedBean;

import javax.faces.bean.SessionScoped;

@ManagedBean

@SessionScoped

public class CustomerBean {

  private String name;

  public String getName() {

       return name;

  }

  public void setName(String name) {

       this.name = name;

  }

}

The editor of the facelet will not suggest any beans, unless I declare in config file.

<!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:ui="http://java.sun.com/jsf/facelets"

  xmlns:h="http://java.sun.com/jsf/html"

  xmlns:f="http://java.sun.com/jsf/core">

<body>

  <!-- Here in the EL the bean should be listed, but the editor makes no suggestions -->

  <h:outputText value="#{}" />

</body>

</html>

This post has been answered by Ram V-Oracle on Feb 16 2016
Jump to Answer

Comments

Ian Trimble-Oracle

I agree that this works until OEPE is installed. I'm looking into this at present, to see what we do in OEPE that changes the behaviour.

- Ian

Ian Trimble-Oracle

OEPE replaces the collection of managed beans and other artifacts with its own implementation, driven off AppXray. It looks like AppXray doesn't collect annotated managed beans. I have logged a bug. I cannot see a workaround other than declaring the beans in faces-config (as you have discovered.)

- Ian

BonanzaOne

Adding some more information, I noticed today that beans provided by default like the "cc.attrs" for composite components are also not shown.

dvohra21

For autocomplete use the Ajax feature in JSF 2. Refer

JSF 2.0 for the Cloud, Part Two

BonanzaOne

Your answer has nothing to do with the problem I posted. Please read the question again.

I am talking about the suggestions provided by Eclipse with the EOPE plugin during the development of facelets.

BonanzaOne

Today version 12.1.3.8 was released but no love for this post issues. The problem still happens.

Waiting for 12.1.3.9.

BonanzaOne

Problem still happening after 12.1.3.8.1 release. Let's keep waiting.

Thanks for post this helpful post - Please visit for More information about -

Packers and Movers Bangalore @

http://www.expert5th.in/packers-and-movers-bangalore/

dvohra21

Seems like a bug in OEPE. The Eclipse JSF  editor is not registering the managed beans declared with annotation.

dvohra21

1. Right-click your Web project in Project Explorer, select Properties.

2. On the Properties dialog, highlight Project Facets node and select JavaServer Faces facet from the list.

What is the JSF facet version?  1.2 or 1.1, or 2.0?

BonanzaOne

JSF Facet version is 2.0.

Tested here, problem is still happening. Using Mars 4.1 and latest version of OEPE (8.4.0.201510191754).

The editor is still not displaying my annotated beans. If I declare it in the "faces-config.xml" it starts to suggest, but it should work without it.

appxray.png

dvohra21

An empty faces-config.xml is still required.

Refer

"@ManagedBean @SessionScoped public class DukesBday{ ... }

The above code snippet shows a bean that is managed by the JavaServer Faces implementation and is available for the length of the session. You do not need to configure the managed bean instance in the faces-config.xml file."

https://docs.oracle.com/javaee/6/tutorial/doc/girch.html

Isn't an empty faces-config.xml created if the JSF facet is selected?

BonanzaOne

I meant the declaration inside the faces-config.xml. Yes, the faces-config.xml file is created when the Facet is applied, and it is empty.

@Ian Trimble-Oracle already confirmed it is a bug.

Should this be solved already? Are you able to reproduce?

dvohra21

If a declaration had to be added to faces-config.xml for managed bean, it is a bug.

BonanzaOne

Unfortunately it's been almost 4 months and no fix for this. What is going on Oracle?

I made all the effort to describe the problem, made myself available for any test etc. No feedback. No bug code. No tracking.

Also the deploy of Web applications seems to be horrible regarding productivity, not sure why Facelets or JSPs are not hot-deployed, all the project is packaged for every change. Web Logic is a strong middleware, but these little bugs and lack of good support annoys me.

dvohra21

Was a service request submitted at https://support.oracle.com

BonanzaOne

Not that I know of. I don't have access to that. Someone said in this thread that a bug was opened in Oracle about this problem.

How can I gain access to that service so I can submit a service request?

dvohra21

Hi,

Sorry for the delay in responding to the thread. We are actively working to fix this. We will post an update soon.

-Raghu

BonanzaOne

Hi Rag, any news on the fix? Another version came out yesterday and the problem still happens.

Is there a date we can expect for it to be released?

Hi,

We have run into few issues while working on the fix and are working to resolve them. Unfortunately we can't share when it will be released.

Hope this helps.

-Raghu

Ram V-Oracle
Answer

Hi,

FYI, the annotated managed beans are supported in the latest OEPE release (12.2.1.2). Please download/update to the latest build from OTN.

-Ram

Marked as Answer by BonanzaOne · Sep 27 2020
BonanzaOne

Hi

I just downloaded the latest version (8.6.0.201602091418), but the plugin is still not giving suggestions. Release notes is not yet updated in the Oracle site.

As you can see below, I created a new Dynamic Web project, applied the JSF 2.0 Facet, the "Faces Configuration" recognizes the Managed Bean, but no suggestion is possible in the Facelet file.

Can you confirm this fix is delivered in this new release? Is there any procedure other than updating the Plugin that needs to be executed?

oepe.png

Ram V-Oracle

Hi,

I just tried the steps and it works fine.

- In a new workspace, create a JSF 2.0 project target to PS5 (10.3.6) RT

- Create a managed bean w/ view scope

- Create facelet page and i see managed bean in Project Explorer | Faces Configuration node, Data Palette | Managed Beans and in content assist

managedbean.png

Can you please try Project | Clean... to see if it helps?

Thanks,

Ram

Ian Trimble-Oracle

Is your project by any chance an ADF project (i.e., does it have an ADF web facet?) Annotated beans are not recognized in ADF projects (by design.)

BonanzaOne

Tried to clean it but it didn't work, still not showing in the content assist.

Restarting Eclipse and creating a new workspace also did no effect. I also tried with a fresh Eclipse installation.

My Managed Bean is not showing in the Palette View.

  • Which Eclipse distro are you using? I am running on Mars 1 (4.5.1).
  • What tools from the plugin did you install? I selected "Oracle WebLogic Server Tools", which installs Java EE and Coherence as dependencies as well.
  • How did you satisfied the JSF project dependencies? (I used the 2.0 library provided by WebLogic Runtime)
BonanzaOne

No, not using ADF.

I am using the standard "Dynamic Web Project" provided by Eclipse with the JSF 2.0 Facet. In production we use Maven projects (I'll test with it later as well)

Ram V-Oracle

Hi,

I was able to reproduce the issue and here is the workaround.

- In addition to "Oracle WebLogic Server Tools" plugin you also need to install "Oracle ADF Tools"

- After restarting Eclipse, touch your managed bean file and you should start seeing the bean entry in both Palette as well as in content assist

Please let us know if this resolves the issue.

Thanks,

Ram

BonanzaOne

Hi Ram

It worked for the "Dynamic Web Project" only. And for some reason it is duplicating the beans in the "Faces Configuration" area.

Note that the standard beans are still not shown, it is only showing my custom beans.

simple-jsf.png

It is not working for a Maven project. I also installed the "Oracle Maven Tools" but it did no effect.

The steps to reproduce:

  1. Install the following plugins: "Oracle WebLogic Server Tools" and "Oracle ADF Tools" (Oracle Maven Tools optionally, did no effect).
  2. Create a Maven Project with "WAR" packaging type.
  3. Configure it with JSF 2.0 (create "faces-config.xml" file and set the JSF dependencies in the "pom.xml").
  4. Create a @ManagedBean
  5. Create a facelet JSF file and try to use content assist to use the managed bean

As we can see the in the image, the Palette is empty, for some reason the managed bean is duplicated in the faces configuration node, and the content assist does not show my beans.

Also, note that the standard beans are still not shown, it is only showing my custom beans.

mvn-proj.png

Ian Trimble-Oracle

Duplication of annotated beans in the Project Explorer is a known issue that will be addressed soon.

For annotated managed bean support to work, the project must have the JSF facet and must not have the ADF web facet; please advise if your Maven project meets these requirements.

Thanks,

- Ian

BonanzaOne

Ian

My Maven project meet the requirements: JSF 2.0 Facet is enabled, Eclipse/Maven integration handle it since I've created the "faces-config.xml" file, and ADF is not added to the project.

Content Assist is not working for Maven Projects. Could you please simulate as well in order to confirm this scenario?

mvn-proj2.png

Ian Trimble-Oracle

A Maven project can take many forms, and there's nothing in the support that specifically cannot work when a web project is also a Maven project.

I'm curious now if your src/main/java folder is recognized by JDT as a source folder, since it is only in JDT source folders that annotated beans are located correctly.

I'm also curious if this current issue is limited to only annotated managed beans, or if the same behaviour is seen with beans declared in faces-config.

Thanks,

- Ian

Ram V-Oracle

Hi,

I am not able to reproduce the issue of missing content-assist in a maven project, it works for me and the annotated bean is listed at all the usual places - Project Explorer | Faces Configuration, Data Palette and by content assist.

- create a maven project with "war" package

- Project | Properties | Project Facets, check JSF 2.0 facet (configure library)

- create annotated bean in the source folder

- create facelet page and the bean is available

Please check the screen shot

maven-jsf.png

-Ram

Ram V-Oracle

Hi,

We found the issue, in your maven project you are trying content assist in an .html file which is not a valid JSF page (extension). Please retry your steps in an .xhtml (Facelet) page.

-Ram

BonanzaOne

Hi.

Well I am sorry I tried it again today and it worked...

I also tried without manually setting the library, but instead using POM dependencies and it worked as well. Also I pushed sources to GitHub, and it also is working after checking-out the project.

Thank you for your support, it seems the problem is fixed.

1 - 35
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 17 2016
Added on Jul 29 2015
35 comments
10,906 views