Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

facelets and CDI  RSS feed

 
Piter Smith
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand the classpath requirements for facelets and CDI on glassfish. I'm using Netbeans, and have the following:



when I look at javaee-api it has javax.enterprise.context.ApplicationScoped and javax.inject.Named which are the particular imports being used in the bean. The facelets part is working, the template navigates correctly. It deploys to Glassfish and runs, except...there's no output from the @Named bean:




from the page:



<!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"
>

<h:head></h:head>
<h:body>
This and everything before will be ignored
<ui:composition template="template.xhtml">
<ui:define name="navigation">
<ui:include src="menu.xhtml"/>
</ui:define>
<ui:define name="main">
<h1>bird</h1>
<p>
next #{nextClient.next}
</p>
</ui:define>
</ui:composition>
This and everything after will be ignored
</h:body>
</html>



Everything I read says to use CDI, that it's preferable now. I'm using EL, or more specifically, UEL, correctly, I believe. I'm largely following Facelets Essentials:

http://www.apress.com/9781430210498

and am just trying to get the template client to invoke NextClient.getNext() with the EL of nextClient.next, but nothing happens...there's no stacktrace or error in glassfish:




the page displays as:




well, now I'm baffled. Now it's working. I can't figure what I did for the life of me...that's the desired output, each time the page is accessed the counter increments.

Now it works. Is this on the right track? Way off base? I have an entity class from a database which I'd like to link up to this, and output the class.

I can inject the entity into NextClient? I'm trying to do the "R" for Read in a CRUD application with CDI and facelets (using templates).

I've found much reference material on EJB, but it seems a mishmash. I just want to use CDI. What am I doing right/wrong, or, besides the PDF from Oracle on Java EE 7, what are good CDI reference material's? Much of what's on the web is woefully out of date, or not applicable to using CDI.
 
Vijitha Kumara
Bartender
Posts: 3973
24
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... It deploys to Glassfish and runs, except...there's no output from the @Named bean: ...

If you meant just starting up the server where the app is deployed then you will not see any output unless you are printing to the console at the startup. You would need to access for example a page in order to see an output.

CDI is the way JEE environment used to inject & manage dependencies. If you packaged them properly they should be available to be accessed from within the in the application.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!