• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

facelets and CDI

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic