Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Préparation de l'exercice

  • Loading branch information...
commit 4beb1f93a39049bb555c3efd51b3e00d95e33bd1 1 parent 5d375ee
@hasalex hasalex authored
View
1  Exercise/src/main/java/org/beginningee6/tutorial/IsbnGenerator.java
@@ -16,6 +16,7 @@
* --
* Simple IsbnGenerator Pojo with Managed Bean annotation
*/
+@ManagedBean
public class IsbnGenerator {
// ======================================
View
23 Exercise/src/main/java/org/beginningee6/tutorial/ItemBean.java
@@ -2,15 +2,16 @@
import java.io.Serializable;
import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
-import java.util.logging.Logger;
-import javax.enterprise.context.RequestScoped;
import javax.faces.event.ActionEvent;
import javax.inject.Inject;
-import javax.inject.Named;
/**
* @author Antonio Goncalves & Alexis Moussine-Pouchkine
@@ -20,21 +21,19 @@
* --
* A JSF Managed Bean
*/
-@Named("itemBean")
-@RequestScoped
+@ManagedBean @RequestScoped
public class ItemBean implements Serializable {
// ======================================
// = Attributes =
// ======================================
- @Inject @Premium
private Customer cust;
- @Inject
+ @EJB
private ItemEJB itemEJB;
- @Inject
+ @EJB
private LanguageSingleton languageSingleton;
private Book book = new Book();
@@ -85,11 +84,15 @@ public String doCreateCD() {
}
public Boolean getForbiddenToBuy() {
- return cust.canBuy() ? Boolean.FALSE : Boolean.TRUE;
+ return cust != null && cust.canBuy() ? Boolean.FALSE : Boolean.TRUE;
}
public String getBuyButtonLabel() {
- return cust.canBuy() ? "Buy me!" : "Sorry, can't buy";
+ if (cust == null) {
+ return "Not implemented";
+ } else {
+ return cust.canBuy() ? "Buy me!" : "Sorry, can't buy";
+ }
}
public String doBuy(ActionEvent event) {
View
3  Exercise/src/main/java/org/beginningee6/tutorial/ItemEJB.java
@@ -1,5 +1,6 @@
package org.beginningee6.tutorial;
+import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.interceptor.Interceptors;
import javax.persistence.EntityManager;
@@ -33,7 +34,7 @@
@PersistenceContext
private EntityManager em;
- @Inject
+ @Resource
private IsbnGenerator isbnGenerator;
// ======================================
View
4 Exercise/src/main/java/org/beginningee6/tutorial/LanguageSingleton.java
@@ -16,9 +16,7 @@
* --
* An EJB Singleton that caches a map of languages
*/
-@Startup
-@Singleton
-@Named("languages")
+@Startup @Singleton
public class LanguageSingleton {
// ======================================
View
1  Exercise/src/main/java/org/beginningee6/tutorial/SpecialCustomer.java
@@ -11,7 +11,6 @@
* --
* A simple POJO annotation with a CDI Qualifier
*/
-@Premium
public class SpecialCustomer implements Customer {
@Inject @ImportantOrder Event<OrderItem> order;
View
2  Exercise/src/main/webapp/newBook.xhtml
@@ -27,8 +27,6 @@
<h:outputLabel value="Language code : " styleClass="alabel"/>
<h:inputText value="#{itemBean.languageCode}" styleClass="ainput"/>
- <h:outputLabel value="*" styleClass="alabel"/>
- <h:outputLabel value="#{languages.listOfValues}" styleClass="ainput"/>
</h:panelGrid>
<!-- need a button to validate the form -->

0 comments on commit 4beb1f9

Please sign in to comment.
Something went wrong with that request. Please try again.