Reputation: 129
I am trying to get samples running of the book "Java EE 7 Development with WildFly". Now I face the following question/problem:
TheatreInfo.java:
@Model
public class TheatreInfo {
...
@Produces
@Named
public Collection<Seat> getSeats() {
return Lists.newArrayList(seats);
}
...
}
Seat.java:
@Dependent
@Named
public class Seat {
...
public String getName() {
return name;
}
...
}
index.xhtml:
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
template="/WEB-INF/templates/default.xhtml">
<ui:define name="content">
<h1>TicketBooker Machine</h1>
<h:form id="reg">
<h:panelGrid columns="1" border="1" styleClass="smoke">
<h:dataTable var="_seat" value="#{seats}" rendered="#{not empty seats}" styleClass="simpletablestyle">
...
</h:dataTable>
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
beans.xml:
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
version="1.1" bean-discovery-mode="all/annotated">
</beans>
This perfectly works - I see a table of seats in my web-brower - as long as I use bean-discovery-mode="all" in my beans.xml. As soon as I use bean-discovery-mode="annotated" in my beans.xml I don't see the table of seats anymore in my browser respectively I see an empty table but no error occurs.
In the book they use bean-discovery-mode="all" but I prefer to see which classes are managed beans an which are not. To use bean-discovery-mode="annotated" I had to add @Dependent to some classes but I have not been able to fix the issue with the names producer method. Can anyone help?
Upvotes: 1
Views: 636
Reputation: 129
Hm, it runs if I use
@Named
@RequestScoped
public class TheatreInfo {
...
instread of
@Model
public class TheatreInfo {
...
Don't understand why, @Named and @RequestScoped is included in the @Model stereotype!? Does anyone know?
Thanks, Dominic
Upvotes: 0