SlideShare a Scribd company logo
1 of 87
Digital Java EE 7 with JSF
Conversations, Flows, and
CDI Scopes
Peter Pilgrim
JavaOne - CON5211
29th October 2015
Digital Java EE 7
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 2
About me
▪ Java Champion
▪ Java programming since 1998
▪ Independent contractor, LTD UK
▪ Java EE developer, designer and book author
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 3
Agenda
▪ Java EE 7 modern architecture
▪ CDI Scopes
▪ Conversation scoped beans
▪ Faces-Flows and flow scoped beans
▪ Bootstrap your enterprise
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 4
"Nobody is madder than me
about the fact that the
website isn't working”
President Obama
Rose Garden Speech, 21th October 2013
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 5
Demonstration
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 6
Digital Java EE application
Digital Java EE 7 Platform
▪ Java EE 7 is standard architecture for
building enterprise Java solutions
▪ Transactions, persistence, management
▪ Dynamic content: Servlets, JSP, JSF and
MVC
▪ Remote endpoints EJB, JAX-RS, JMS
WebSocket and JCA
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 7
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 8
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 9
EJB Container
Poolable managed remote end points with transactions and
concurrency , which are application wide
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 10
EJB Beans
@Stateless
class ProductQueryService { ... }
@Stateful
class ShoppingCartDao { ... }
@MessageDriven
class OrderProcessor implements
MessageListener { ... }
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 11
CDI Container
Dependency Injection with lifecycle and contextual information
managing POJO instances in an enterprise web application
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 12
CDI Beans
@Named @RequestScoped
class LivePriceController { ... }
@Named @SessionScoped
class ShoppingCart implements Serializable {
... }
@ApplicationScoped
class Utility implements Serializable { ... }
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 13
Servlet Container
A specific container to manage Java Servlets, Filters and Context
Listeners for a web application HTTP
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 14
Web Infrastructure Beans
@WebServlet(“/prices/live”)
class LivePriceServlet extends HttpServlet {
... }
@WebFilter(“/prices”)
class PriceEnricher implements Filter { ... }
@WebListener
class UserSecurityRemover implements
HttpSessionListener,
HttpSessionAttributeListener { ... }
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 15
Request Scope
Session Scope
Application
Scope
Arrow ofTime
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 16
Context & Dependency
Injection 1.1
▪ Different lifespans for stateful objects
▪ Typesafe dependency injection
▪ Can decorate injected objects
▪ Can interpret methods
▪ Event notification model
▪ Portable extensions mechanism through SPI
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 17
Injection from CDI container
interface PaymentIssuer {
void allocate( int id );
}
@ApplicationScoped
public class CreditCardTicketTrackerImpl {
@Inject PaymentIssuer issuer;
/* ... */
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 18
CDI Qualifiers
import java.inject.Qualifier;
import java.lang.annotation.*;
import static java.lang.annotation.ElementType.FIELD;
@Qualifier
@Retention(RUNTIME)
@Target({FIELD}
public @interface Premier { }
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 19
Use CDI Qualifiers #1
@Premier
class StellarPaymentImpl implements PaymentIssuer {
void allocate( int id ) { ... }
}
@Standard
class BasicPaymentImpl implements PaymentIssuer {
void allocate( int id ) { ... }
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 20
Use CDI Qualifiers #2
@ApplicationScoped
public class SmartCreditCardTicketTracker() {
@Premium @Inject PaymentIssuer issuer1;
@Standard @Inject PaymentIssuer issuer2;
public void processTickets() {
if (nightTime) { ... } else { ... }
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 21
Injection from EJB container
@Stateless public class OrderDAO {
List<Order> findByCustomer( int custId ) {...}
}
@SessionScoped
public class CustomerOrderProcessor {
@EJB OrderDao orderDao;
/* ... */
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 22
Injection from Servlet
container
class LivePriceServlet
extends HttpServlet { ... }
@Named @RequestScoped
class EntryController {
@Inject LivePriceServlet servlet;
// This does not work!
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 23
CDI: Inject a long lifespan
bean to a short lifespan bean
@ApplicationScoped class Utility { ...
}
@Named @RequestScoped
class DeliveryController {
@Inject Utility utility;
/* ... */
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 24
CDI: Inject a long lifespan
bean to a short lifespan bean
@ApplicationScoped class Utility
implements Serializable { ... }
@Named @SessionScoped
class ShoppingCartController implements
Serializable {
@Inject Utility utility;
/* ... */
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 25
CDI: Inject a short lifespan
bean to a long lifespan bean
@RequestScoped class SecureDomain {
... }
@Named @SessionScoped
class ShoppingCartController ... {
@Inject SecureDomain secDomain;
public void doAction() { ... }
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 26
CDI: Inject a short lifespan
bean to a long lifespan bean
@RequestScoped class SecureDomain { ... }
@Named @SessionScoped
class ShoppingCartController ... {
@Inject SecureDomain secDomain;
public void doAction() {
secDomain.invoke(...);
/* YMMV - it might work because of proxies */
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 27
CDI Events – Define a domain
value object
public class LivePriceEvent {
private String product;
private double price;
public LivePriceEvent(String product, double price)
{ ... }
public String getProduct() { ... }
public double getPrice() { ... }
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 28
CDI Event Source
@ApplicationScoped
public class PriceUpdater {
@Inject Event<LivePriceEvent> events;
public void announce() {
events.fire(new LivePriceEvent(
"Digital Java EE", 45.0 ));
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 29
CDI Event Target
@ApplicationScoped public class PriceListener {
public void listenAndReport(
@Observes LivePriceEvent event ){
System.out.printf("event.product = %sn",
event.getProduct());
System.out.printf("event.price = %sn",
event.getPrice());
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 30
Demonstration
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 31
View Scoped Form
JSF View Scoped Controller #1
▪ @ViewScoped belongs to JSF specification
▪ Retains the scope lifespan for current page view
▪ If the controller navigates away to a different page
view the bean is de-scoped
▪ Therefore view-scope is great for form validation
and richAJAX request and response sequences!
▪ #Fail for HTTP POST-REDIRECT-GET idiom
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 32
JSF View Scoped Controller #2
@Named @ViewScoped class ContactDetailController {
@EJB ContactDetailService dao;
ContactDetail contactDetail = new ContactDetail();
public String createContact() {
dao.add(contactDetail);
contactDetail = new ContactDetail();
return "index.xhtml";
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 33
Flash Scope #1
▪ JSF supports a flash map collection for controllers
▪ Only accessible through FacesContext
1. JSF places the flash data temporarily into the
HttpSession before it creates the Faces Response.
2. A special flash cookie is set before sending a
redirect HTTP response.
3. A HTTP client resends the flash cookie in a Faces
Request. JSF removes the flash cookie.
4. JSF copies the flash session data to request scope
and them removes it from the session scope.
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 34
Flash Scope #2
@Named @ViewScoped class FrenchSuitController {
private String firstName, lastName;
public String doAction() {
Flash flash = FacesContext.getCurrentInstance().
getExternalContext().getFlash();
flash.put("firstName",firstName);
flash.put("lastName",lastName);
return "/jsf-validation/french-suit-
complete?redirect=true";
} ...
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 35
Flash Scope #3
<ui:define name="mainContent">
<h1> House of Cards with JSF Validation</h1>
<div class="jumbotron">
Terrific! You completed the French suite action.
Your first name is <b>#{flash['firstName']}</b> and
your last name is <b>#{flash['lastName']}</b> and
you chose <b>#{flash['suit']}</b> as the suit.
</div> ...
</ui:define>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 36
JSF 2.2 supports HTML5 content!
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 37
HTML5 friendly markup in JSF
2.2
▪ In JSF 2.2, by default XHTML are rendered with
HTML5 <DOCTYPE html>
▪ Pass-through attributes
▪ Pass-through elements
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 38
Pass-through attributes
<html xmlns="http://www.w3.org/1999/xhtml" ...
xmlns:p="http://xmlns.jcp.org/jsf/passthrough">
<div class="col-sm-9">
<h:inputText p:type="date"
class="form-control" id="birthday"
value="#{customerController.birthday}"
p:placeholder="1977-10-25” />
</div>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 39
Pass-through elements
<html xmlns="http://www.w3.org/1999/xhtml” ...
xmlns:jsf="http://xmlns.jcp.org/jsf">
<head jsf:id="head"> ... </head>
<body jsf:id="body">
<form jsf:id="vacationForm">
...
<input type="text" jsf:id="companyId"
placeholder="Your company identity number”
jsf:value="#{vacationController.companyNo}” />
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 40
Conversations
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 41
Demonstration
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 42
Instant Smart Secure
Conversation scope
▪ A lifespan sits between a Http Request scope and
Http Session scope
▪ Maintains state for the unique interaction
▪ Works for individual tab in web browsers
▪ Better than @ViewScoped bean controllers
▪ Application defined lifespan
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 43
Conversation scoped bean #1
public interface Conversation {
void begin();
void begin(String id);
void end();
String getId();
long getTimeout();
void setTimeout(long milliseconds);
boolean isTransient();
} // import javax.enterprise.context.*;
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 44
Conversation scoped bean #2
@Named @ConversationScoped
public class LendingController
implements Serializable {
@EJB ApplicantService applicantService;
@Inject Conversation conversation;
@Inject Utility utility;
public String doConfirm() { ... }
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 45
Conversation scoped bean #3
@Named @ConversationScoped class LendingController ... {
public void checkAndStart() {
if ( conversation.isTransient()) conversation.begin();
recalculatePMT();
}
public void checkAndEnd() {
if (!conversation.isTransient()) conversation.end();
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 46
Conversation scoped bean #4
@Named @ConversationScoped
class LendingController ... {
public String doLandingPage() {
checkAndStart();
return "your-details?faces-redirect=true";
}
...
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 47
Conversation scoped bean #5
@Named @ConversationScoped
class LendingController ... {
public String doCancel() {
checkAndEnd();
return "index.xhtml?faces-redirect=true";
}
...
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 48
Conversation scope
conclusions
Pros
▪ Conversation scope is great for “wizards”
▪ Linear sequence of pages
▪ Conversation is unique per tab
▪ Application defines the entry & exit points
Cons
▪ Explicitly termination of conversation
▪ Customer jumps away and back again
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 49
JSF 2.2 Faces Flows
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 50
Flow scope #1
▪ Brand new scope in JSF 2.2 and Java EE 7
▪ Modular in execution
▪ Concept of nodes
▪ Associated with a URI path
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 51
Flow scope #2
▪ Flows can nested; a flow can invoke another
▪ Parameters and data can pass to and back through
Flow scope map collection
▪ package javax.faces.flow.*
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 52
Flow scope #3
▪ A Flow is a folder name in your web context
application
▪ A Flow must have a Flow Definition XML file that
matches the folder name
▪ <Flow-Name>/<Flow-Name>-flow.xml
▪ This file can be blank – implicit flow navigation
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 53
Flow node types
▪ View – represents any JSF page view
▪ Method Call – method invocation through EL
(expression language)
▪ FlowCall – invocation of another flow with inbound
and outbound parameters
▪ Flow Return – return to the calling flow
▪ Switch – navigation selection through EL
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 54
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 55
sector-flow
carbon-footprint-flow
Start
End
Demonstration
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 56
Flow scope application
Flow layout project
src/main/webapp/sector/
src/main/webapp/sector/sector-flow.xml
src/main/webapp/sector/sector.xhtml
src/main/webapp/sector/sector-page-1a.xthml
src/main/webapp/sector/sector-page-1b.xthml
src/main/webapp/sector/sector-page-1c.xthml
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 57
Flow layout project #2
src/main/webapp/footprint/
src/main/webapp/footprint/footprint-flow.xml
src/main/webapp/footprint/footprint.xhtml
src/main/webapp/footprint/footprint-page-1a.xml
src/main/webapp/endflow.xhtml
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 58
Flow scoped controller #1
@Named @FlowScoped("sector")
public class SectorFlow
implements Serializable {
@Inject UtilityHelper utilityHelper;
@Inject CarbonFootprintService service;
public SectorFlow() { ... }
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 59
Flow scoped controller #2
@Named @FlowScoped("sector")
public class SectorFlow
implements Serializable {
@Inject UtilityHelper utilityHelper;
@Inject CarbonFootprintService service;
public SectorFlow() { ... }
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 60
Flow scoped controller #4
public class SectorFlow ...{
@PostConstruct
public void initialize() {
footprint.setApplicationId(
utilityHelper.getNextApplicationId());
}
...
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 61
Flow scoped controller #5
public class SectorFlow ...{
public String gotoEndFlow() {
return "/endflow.xhtml";
}
public String saveFootprintRecord() {
service.add(footprint);
return "sector-page-1c.xhtml";
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 62
Flow definition XML file #1
<faces-config version="2.2" ...>
<flow-definition id="sector">
<flow-return id="goHome">
<from-outcome>/index</from-outcome>
</flow-return>
...
</flow-definition>
</faces-config>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 63
Flow definition XML file #2
<faces-config version="2.2" ...>
<flow-definition id="sector">
<flow-return id="endFlow">
<from-outcome>#{sectorFlow.gotoEndFlow()}
</from-outcome>
</flow-return>
<flow-call id="callFootprintFlow”>...</flow-call>
</flow-definition> ...
</faces-config>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 64
Flow definition XML file #3
<flow-call id="callFootprintFlow">
<flow-reference><flow-id>footprint</flow-id>
</flow-reference> ...
<outbound-parameter>
<name>param3FromSectorFlow</name>
<value>#{sectorFlow.footprint}</value>
</outbound-parameter>
</flow-call>
</flow-definition>
</faces-config>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 65
Nested flow scope #1
@Named @FlowScoped("footprint")
public class FootprintFlow implements Serializable {
private CarbonFootprint footprint;
@PostConstruct public void initialize() {}
Map<Object,Object> flowMap =
FacesContext.getCurrentInstance()
.getApplication().getFlowHandler()
.getCurrentFlowScope();
footprint = (CarbonFootprint) flowMap.get("param3Value");
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 66
Nested flow scope #2
@Named @FlowScoped("footprint")
public class FootprintFlow ... {
public String exitFromFootprintFlow() {
return ”/sector";
}
. . .
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 67
Nested flow scope #3
@Named @FlowScoped("footprint")
public class FootprintFlow ... {
. . .
public String gotoPage2() {
return "footprint-page-1a";
}
}
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 68
Nested Flow definition XML
file #1
<faces-config version="2.2" ...>
<flow-definition id="footprint-flow">
<flow-return id="goHome">
<from-outcome>/index</from-outcome>
</flow-return>
...
</faces-config>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 69
Nested Flow definition XML
file #2
<faces-config version="2.2" ...>
<flow-definition id="footprint"> ...
<flow-return id=”exitToCallerFlow">
<from-outcome>#{footprintFlow.exitFromFootprintFlow}
</from-outcome>
</flow-return>
<flow-return id="exitToSectorFlow">
<from-outcome>/sector-flow</from-outcome>
</flow-return>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 70
Nested Flow definition XML
file #3
<flow-definition id="footprint"> ...
<inbound-parameter>
<name>param1FromSectorFlow</name>
<value>#{flowScope.param1Value}</value>
</inbound-parameter> ...
<inbound-parameter>
<name>param3FromSectorFlow</name>
<value>#{flowScope.param3Value}</value>
</inbound-parameter>
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 71
Flow scope bean conclusions
Pros
▪ Conversation scope is great for “wizards”
▪ Flow node demarcated by URI folder convention
▪ Nestable flow customer journeys
Cons
▪ Handling REDIRECT is difficult (JSF 2.3 perhaps?)
▪ Flow scope parameter passing can be peculiar
▪ Only one START NODE and not configurable
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 72
Choosing a scope for a
managed bean controller
▪ Sharing data, utility and information for all users,
prefer @ApplicationScoped
▪ Sharing information and behavior for an individual
customer, prefer @SessionScoped
▪ Customer journey restricted to a specific set of page
views, choose @FlowScoped
▪ Defined customer journey and custom application
entry and exit points, choose @ConversationScoped
▪ Basic rich validation entry and exit point, prefer
@ViewScoped
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 73
Adding Finesse
▪ Consider CSS framework such as Bootstrap
(http://getbootstrap.com) or Foundation
(http://foundation.zurb.com/ )
▪ Consider SASS or LESS for CSS templates
▪ Learn JavaScript programming
▪ Maybe learn aboutTranspilers
▪ Consider RequireJS (http://requirejs.org/) for
organising JavaScript modules
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 74
Design considerations
▪ Evolution of object oriented JavaScript leads to rich
frameworks inside the client’s web browser
▪ JSF lends itself to page view navigation
▪ Hybrid design is possible with JSF and adopting
JavaScript controller
▪ JSF 2.2 Faces Flows is a major feature worthy of
investigation
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 75
Non-Functional Requirement
HealthCare.gov site must
handle 10,000 customers at
once.
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 76
It failed with just a few
hundred users.
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 77
HealthCare.gov (USA)
Website cost $300 million price tag
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 78
Don’t worry USA!
British NHS IT system was abandoned after 10 years
and cost the tax payer £10bn so far
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 79
▪ Innovate with optionality
▪ Constraints
▪ Build fast, fail fast
▪ Communication
▪ Technology == evolution
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 80
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 81
Executive Summary
Hints and tips and where to go next
Conclusions
▪ Leverage Java EE 7 platform
▪ Choose scope by lifespan of the bean
▪ Prefer Faces Flows for digital customer journeys
▪ Otherwise Conversation-Scoped beans
▪ Prefer HTML5 friendly markup of Facelets views
▪ Prefer CDI
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 82
Conclusions #2
▪ Protect your from UX changes
▪ Keep action controller methods short
▪ Delegate complex logic to business logic
▪ Use DOMAIN MODEL CONTEXT objects
▪ Avoid methods with long parameter lists!
▪ Inject DOMAIN MODEL LOGIC
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 83
Contacts
▪ Follow me onTwitter @peter_pilgrim
▪ Read my blog http://xenonique.co.uk/blog/
▪ Books from Packt Publishing
–Digital Java EE 7
–Java EE 7 Developer Handbook
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 84
Photo credits (cc) 2016
▪ by Joshua Earle https://unsplash.com/joshuaearle
▪ By Lili Popper https://unsplash.com/lili_popper
▪ By Rowan Heuvel https://unsplash.com/insolitus
▪ By David Marcu https://stocksnap.io/author/302
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 85
Photo credits (cc) 2016
▪ By Gemma Bou (hand fractal)
https://www.flickr.com/photos/gemmabou/
▪ By Nicole Hanusek (luggage)
https://www.flickr.com/photos/nhanusek/
▪ By Navaneeth KN (group photo painted stork)
https://www.flickr.com/photos/navaneethkn/
▪ By Ruben Schade (container ship in the Straits of
Singapore) https://www.flickr.com/photos/rubenerd/
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 86
Photo credits (cc) 2016
▪ Joel Cooper (big face 1)
https://www.flickr.com/photos/origamijoel/
▪ Nullfy from nullfy.com! (Ring of Power!)
https://www.flickr.com/photos/130197050@N04/
▪ philippe leroyer (Student Demonstration (46) - 27Nov07, Paris
(France)) https://www.flickr.com/photos/philippeleroyer/
▪ philippe leroyer (Pupil's Demonstration (10) - 10Apr08, Paris
(France)) https://www.flickr.com/photos/philippeleroyer/
JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 87

More Related Content

What's hot

Extending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss ForgeExtending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss ForgeAntoine Sabot-Durand
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Antoine Sabot-Durand
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitAriya Hidayat
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesMert Çalışkan
 
Clean Pragmatic Architecture - Avoiding a Monolith
Clean Pragmatic Architecture - Avoiding a MonolithClean Pragmatic Architecture - Avoiding a Monolith
Clean Pragmatic Architecture - Avoiding a MonolithVictor Rentea
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New FeaturesAli BAKAN
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13Fred Sauer
 
Choosing a Java Web Framework
Choosing a Java Web FrameworkChoosing a Java Web Framework
Choosing a Java Web FrameworkWill Iverson
 
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...Matt Raible
 
Guice tutorial
Guice tutorialGuice tutorial
Guice tutorialAnh Quân
 
Functional Reactive Programming in the Netflix API
Functional Reactive Programming in the Netflix APIFunctional Reactive Programming in the Netflix API
Functional Reactive Programming in the Netflix APIC4Media
 
Front End Development for Backend Developers - GIDS 2019
Front End Development for Backend Developers - GIDS 2019Front End Development for Backend Developers - GIDS 2019
Front End Development for Backend Developers - GIDS 2019Matt Raible
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkBo-Yi Wu
 
Gradle plugin, take control of the build
Gradle plugin, take control of the buildGradle plugin, take control of the build
Gradle plugin, take control of the buildEyal Lezmy
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next levelEyal Lezmy
 
Asynchronous Programming at Netflix
Asynchronous Programming at NetflixAsynchronous Programming at Netflix
Asynchronous Programming at NetflixC4Media
 
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...Matt Raible
 
Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018Matt Raible
 
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019Matt Raible
 

What's hot (20)

Extending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss ForgeExtending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss Forge
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
 
Hybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKitHybrid Apps (Native + Web) via QtWebKit
Hybrid Apps (Native + Web) via QtWebKit
 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
 
Clean Pragmatic Architecture - Avoiding a Monolith
Clean Pragmatic Architecture - Avoiding a MonolithClean Pragmatic Architecture - Avoiding a Monolith
Clean Pragmatic Architecture - Avoiding a Monolith
 
Java 9 New Features
Java 9 New FeaturesJava 9 New Features
Java 9 New Features
 
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
SF JUG - GWT Can Help You Create Amazing Apps - 2009-10-13
 
Choosing a Java Web Framework
Choosing a Java Web FrameworkChoosing a Java Web Framework
Choosing a Java Web Framework
 
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
 
Guice tutorial
Guice tutorialGuice tutorial
Guice tutorial
 
Functional Reactive Programming in the Netflix API
Functional Reactive Programming in the Netflix APIFunctional Reactive Programming in the Netflix API
Functional Reactive Programming in the Netflix API
 
Front End Development for Backend Developers - GIDS 2019
Front End Development for Backend Developers - GIDS 2019Front End Development for Backend Developers - GIDS 2019
Front End Development for Backend Developers - GIDS 2019
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP Framework
 
Gradle plugin, take control of the build
Gradle plugin, take control of the buildGradle plugin, take control of the build
Gradle plugin, take control of the build
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next level
 
Asynchronous Programming at Netflix
Asynchronous Programming at NetflixAsynchronous Programming at Netflix
Asynchronous Programming at Netflix
 
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
 
Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018Bootiful Development with Spring Boot and React - UberConf 2018
Bootiful Development with Spring Boot and React - UberConf 2018
 
Desiging for Modularity with Java 9
Desiging for Modularity with Java 9Desiging for Modularity with Java 9
Desiging for Modularity with Java 9
 
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
A Gentle Introduction to Angular Schematics - Devoxx Belgium 2019
 

Similar to JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI Scopes

Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and NoteworthyJava EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and NoteworthyPeter Pilgrim
 
Avoiding and dealing with conflicting updates in Oak
Avoiding and dealing with conflicting updates in OakAvoiding and dealing with conflicting updates in Oak
Avoiding and dealing with conflicting updates in Oakmichid
 
It's complicated, but it doesn't have to be: a Dagger journey
It's complicated, but it doesn't have to be: a Dagger journeyIt's complicated, but it doesn't have to be: a Dagger journey
It's complicated, but it doesn't have to be: a Dagger journeyThiago “Fred” Porciúncula
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Patricia Aas
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Jonas Follesø
 
To Microservices and Beyond
To Microservices and BeyondTo Microservices and Beyond
To Microservices and BeyondMatt Stine
 
Get Back in Control of Your SQL - #33rdDegree
Get Back in Control of Your SQL - #33rdDegreeGet Back in Control of Your SQL - #33rdDegree
Get Back in Control of Your SQL - #33rdDegreeDataGeekery
 
Context and Dependency Injection
Context and Dependency InjectionContext and Dependency Injection
Context and Dependency InjectionWerner Keil
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Patricia Aas
 
The new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfileThe new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfileEmily Jiang
 
OpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConOpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConos890
 
Cleaning your architecture with android architecture components
Cleaning your architecture with android architecture componentsCleaning your architecture with android architecture components
Cleaning your architecture with android architecture componentsDebora Gomez Bertoli
 
Getting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafGetting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafMasatoshi Tada
 
M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013
M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013
M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013Dominik Obermaier
 
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Alina Vilk
 
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaroundGet Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaroundDataGeekery
 
Best Way to Write SQL in Java
Best Way to Write SQL in JavaBest Way to Write SQL in Java
Best Way to Write SQL in JavaGerger
 
Open Admin
Open AdminOpen Admin
Open Adminbpolster
 
Building cloud native microservices
Building cloud native microservicesBuilding cloud native microservices
Building cloud native microservicesEmily Jiang
 

Similar to JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI Scopes (20)

Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and NoteworthyJava EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
 
Avoiding and dealing with conflicting updates in Oak
Avoiding and dealing with conflicting updates in OakAvoiding and dealing with conflicting updates in Oak
Avoiding and dealing with conflicting updates in Oak
 
It's complicated, but it doesn't have to be: a Dagger journey
It's complicated, but it doesn't have to be: a Dagger journeyIt's complicated, but it doesn't have to be: a Dagger journey
It's complicated, but it doesn't have to be: a Dagger journey
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
 
To Microservices and Beyond
To Microservices and BeyondTo Microservices and Beyond
To Microservices and Beyond
 
Get Back in Control of Your SQL - #33rdDegree
Get Back in Control of Your SQL - #33rdDegreeGet Back in Control of Your SQL - #33rdDegree
Get Back in Control of Your SQL - #33rdDegree
 
Context and Dependency Injection
Context and Dependency InjectionContext and Dependency Injection
Context and Dependency Injection
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020
 
The new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfileThe new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfile
 
OpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConOpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheCon
 
Cleaning your architecture with android architecture components
Cleaning your architecture with android architecture componentsCleaning your architecture with android architecture components
Cleaning your architecture with android architecture components
 
Getting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with ThymeleafGetting start Java EE Action-Based MVC with Thymeleaf
Getting start Java EE Action-Based MVC with Thymeleaf
 
M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013
M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013
M2M for Java Developers: MQTT with Eclipse Paho - Eclipsecon Europe 2013
 
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
Встреча Google Post IO ( Владимир Иванов, Катерина Заворотченко и Сергей Комлач)
 
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaroundGet Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
Get Back in Control of your SQL with jOOQ - GeekOut by ZeroTurnaround
 
Best Way to Write SQL in Java
Best Way to Write SQL in JavaBest Way to Write SQL in Java
Best Way to Write SQL in Java
 
Open Admin
Open AdminOpen Admin
Open Admin
 
Building cloud native microservices
Building cloud native microservicesBuilding cloud native microservices
Building cloud native microservices
 
Devoxx 2012 (v2)
Devoxx 2012 (v2)Devoxx 2012 (v2)
Devoxx 2012 (v2)
 

More from Peter Pilgrim

Devoxx 2019 - Why we pair?
Devoxx 2019 - Why we pair?Devoxx 2019 - Why we pair?
Devoxx 2019 - Why we pair?Peter Pilgrim
 
Cloud native java are we there yet go tech world 2019
Cloud native java   are we there yet  go tech world 2019Cloud native java   are we there yet  go tech world 2019
Cloud native java are we there yet go tech world 2019Peter Pilgrim
 
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!Peter Pilgrim
 
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017Peter Pilgrim
 
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVMQCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVMPeter Pilgrim
 
BOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala appsBOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala appsPeter Pilgrim
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesPeter Pilgrim
 
JavaCro 2014 Digital Development with Java EE and Java Platform
JavaCro 2014 Digital Development with Java EE and Java PlatformJavaCro 2014 Digital Development with Java EE and Java Platform
JavaCro 2014 Digital Development with Java EE and Java PlatformPeter Pilgrim
 
ACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the EnterpiseACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the EnterpisePeter Pilgrim
 
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...Peter Pilgrim
 
JavaOne 2011 Progressive JavaFX 2.0 Custom Components
JavaOne 2011 Progressive JavaFX 2.0 Custom ComponentsJavaOne 2011 Progressive JavaFX 2.0 Custom Components
JavaOne 2011 Progressive JavaFX 2.0 Custom ComponentsPeter Pilgrim
 
ACCU 2011 Introduction to Scala: An Object Functional Programming Language
ACCU 2011 Introduction to Scala: An Object Functional Programming LanguageACCU 2011 Introduction to Scala: An Object Functional Programming Language
ACCU 2011 Introduction to Scala: An Object Functional Programming LanguagePeter Pilgrim
 

More from Peter Pilgrim (12)

Devoxx 2019 - Why we pair?
Devoxx 2019 - Why we pair?Devoxx 2019 - Why we pair?
Devoxx 2019 - Why we pair?
 
Cloud native java are we there yet go tech world 2019
Cloud native java   are we there yet  go tech world 2019Cloud native java   are we there yet  go tech world 2019
Cloud native java are we there yet go tech world 2019
 
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
 
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
 
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVMQCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
 
BOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala appsBOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala apps
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development Experiences
 
JavaCro 2014 Digital Development with Java EE and Java Platform
JavaCro 2014 Digital Development with Java EE and Java PlatformJavaCro 2014 Digital Development with Java EE and Java Platform
JavaCro 2014 Digital Development with Java EE and Java Platform
 
ACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the EnterpiseACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the Enterpise
 
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded...
 
JavaOne 2011 Progressive JavaFX 2.0 Custom Components
JavaOne 2011 Progressive JavaFX 2.0 Custom ComponentsJavaOne 2011 Progressive JavaFX 2.0 Custom Components
JavaOne 2011 Progressive JavaFX 2.0 Custom Components
 
ACCU 2011 Introduction to Scala: An Object Functional Programming Language
ACCU 2011 Introduction to Scala: An Object Functional Programming LanguageACCU 2011 Introduction to Scala: An Object Functional Programming Language
ACCU 2011 Introduction to Scala: An Object Functional Programming Language
 

Recently uploaded

APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 

Recently uploaded (20)

APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 

JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI Scopes

  • 1. Digital Java EE 7 with JSF Conversations, Flows, and CDI Scopes Peter Pilgrim JavaOne - CON5211 29th October 2015
  • 2. Digital Java EE 7 JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 2
  • 3. About me ▪ Java Champion ▪ Java programming since 1998 ▪ Independent contractor, LTD UK ▪ Java EE developer, designer and book author JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 3
  • 4. Agenda ▪ Java EE 7 modern architecture ▪ CDI Scopes ▪ Conversation scoped beans ▪ Faces-Flows and flow scoped beans ▪ Bootstrap your enterprise JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 4
  • 5. "Nobody is madder than me about the fact that the website isn't working” President Obama Rose Garden Speech, 21th October 2013 JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 5
  • 6. Demonstration JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 6 Digital Java EE application
  • 7. Digital Java EE 7 Platform ▪ Java EE 7 is standard architecture for building enterprise Java solutions ▪ Transactions, persistence, management ▪ Dynamic content: Servlets, JSP, JSF and MVC ▪ Remote endpoints EJB, JAX-RS, JMS WebSocket and JCA JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 7
  • 8. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 8
  • 9. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 9
  • 10. EJB Container Poolable managed remote end points with transactions and concurrency , which are application wide JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 10
  • 11. EJB Beans @Stateless class ProductQueryService { ... } @Stateful class ShoppingCartDao { ... } @MessageDriven class OrderProcessor implements MessageListener { ... } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 11
  • 12. CDI Container Dependency Injection with lifecycle and contextual information managing POJO instances in an enterprise web application JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 12
  • 13. CDI Beans @Named @RequestScoped class LivePriceController { ... } @Named @SessionScoped class ShoppingCart implements Serializable { ... } @ApplicationScoped class Utility implements Serializable { ... } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 13
  • 14. Servlet Container A specific container to manage Java Servlets, Filters and Context Listeners for a web application HTTP JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 14
  • 15. Web Infrastructure Beans @WebServlet(“/prices/live”) class LivePriceServlet extends HttpServlet { ... } @WebFilter(“/prices”) class PriceEnricher implements Filter { ... } @WebListener class UserSecurityRemover implements HttpSessionListener, HttpSessionAttributeListener { ... } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 15
  • 16. Request Scope Session Scope Application Scope Arrow ofTime JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 16
  • 17. Context & Dependency Injection 1.1 ▪ Different lifespans for stateful objects ▪ Typesafe dependency injection ▪ Can decorate injected objects ▪ Can interpret methods ▪ Event notification model ▪ Portable extensions mechanism through SPI JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 17
  • 18. Injection from CDI container interface PaymentIssuer { void allocate( int id ); } @ApplicationScoped public class CreditCardTicketTrackerImpl { @Inject PaymentIssuer issuer; /* ... */ } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 18
  • 19. CDI Qualifiers import java.inject.Qualifier; import java.lang.annotation.*; import static java.lang.annotation.ElementType.FIELD; @Qualifier @Retention(RUNTIME) @Target({FIELD} public @interface Premier { } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 19
  • 20. Use CDI Qualifiers #1 @Premier class StellarPaymentImpl implements PaymentIssuer { void allocate( int id ) { ... } } @Standard class BasicPaymentImpl implements PaymentIssuer { void allocate( int id ) { ... } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 20
  • 21. Use CDI Qualifiers #2 @ApplicationScoped public class SmartCreditCardTicketTracker() { @Premium @Inject PaymentIssuer issuer1; @Standard @Inject PaymentIssuer issuer2; public void processTickets() { if (nightTime) { ... } else { ... } } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 21
  • 22. Injection from EJB container @Stateless public class OrderDAO { List<Order> findByCustomer( int custId ) {...} } @SessionScoped public class CustomerOrderProcessor { @EJB OrderDao orderDao; /* ... */ } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 22
  • 23. Injection from Servlet container class LivePriceServlet extends HttpServlet { ... } @Named @RequestScoped class EntryController { @Inject LivePriceServlet servlet; // This does not work! } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 23
  • 24. CDI: Inject a long lifespan bean to a short lifespan bean @ApplicationScoped class Utility { ... } @Named @RequestScoped class DeliveryController { @Inject Utility utility; /* ... */ } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 24
  • 25. CDI: Inject a long lifespan bean to a short lifespan bean @ApplicationScoped class Utility implements Serializable { ... } @Named @SessionScoped class ShoppingCartController implements Serializable { @Inject Utility utility; /* ... */ } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 25
  • 26. CDI: Inject a short lifespan bean to a long lifespan bean @RequestScoped class SecureDomain { ... } @Named @SessionScoped class ShoppingCartController ... { @Inject SecureDomain secDomain; public void doAction() { ... } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 26
  • 27. CDI: Inject a short lifespan bean to a long lifespan bean @RequestScoped class SecureDomain { ... } @Named @SessionScoped class ShoppingCartController ... { @Inject SecureDomain secDomain; public void doAction() { secDomain.invoke(...); /* YMMV - it might work because of proxies */ } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 27
  • 28. CDI Events – Define a domain value object public class LivePriceEvent { private String product; private double price; public LivePriceEvent(String product, double price) { ... } public String getProduct() { ... } public double getPrice() { ... } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 28
  • 29. CDI Event Source @ApplicationScoped public class PriceUpdater { @Inject Event<LivePriceEvent> events; public void announce() { events.fire(new LivePriceEvent( "Digital Java EE", 45.0 )); } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 29
  • 30. CDI Event Target @ApplicationScoped public class PriceListener { public void listenAndReport( @Observes LivePriceEvent event ){ System.out.printf("event.product = %sn", event.getProduct()); System.out.printf("event.price = %sn", event.getPrice()); } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 30
  • 31. Demonstration JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 31 View Scoped Form
  • 32. JSF View Scoped Controller #1 ▪ @ViewScoped belongs to JSF specification ▪ Retains the scope lifespan for current page view ▪ If the controller navigates away to a different page view the bean is de-scoped ▪ Therefore view-scope is great for form validation and richAJAX request and response sequences! ▪ #Fail for HTTP POST-REDIRECT-GET idiom JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 32
  • 33. JSF View Scoped Controller #2 @Named @ViewScoped class ContactDetailController { @EJB ContactDetailService dao; ContactDetail contactDetail = new ContactDetail(); public String createContact() { dao.add(contactDetail); contactDetail = new ContactDetail(); return "index.xhtml"; } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 33
  • 34. Flash Scope #1 ▪ JSF supports a flash map collection for controllers ▪ Only accessible through FacesContext 1. JSF places the flash data temporarily into the HttpSession before it creates the Faces Response. 2. A special flash cookie is set before sending a redirect HTTP response. 3. A HTTP client resends the flash cookie in a Faces Request. JSF removes the flash cookie. 4. JSF copies the flash session data to request scope and them removes it from the session scope. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 34
  • 35. Flash Scope #2 @Named @ViewScoped class FrenchSuitController { private String firstName, lastName; public String doAction() { Flash flash = FacesContext.getCurrentInstance(). getExternalContext().getFlash(); flash.put("firstName",firstName); flash.put("lastName",lastName); return "/jsf-validation/french-suit- complete?redirect=true"; } ... JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 35
  • 36. Flash Scope #3 <ui:define name="mainContent"> <h1> House of Cards with JSF Validation</h1> <div class="jumbotron"> Terrific! You completed the French suite action. Your first name is <b>#{flash['firstName']}</b> and your last name is <b>#{flash['lastName']}</b> and you chose <b>#{flash['suit']}</b> as the suit. </div> ... </ui:define> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 36
  • 37. JSF 2.2 supports HTML5 content! JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 37
  • 38. HTML5 friendly markup in JSF 2.2 ▪ In JSF 2.2, by default XHTML are rendered with HTML5 <DOCTYPE html> ▪ Pass-through attributes ▪ Pass-through elements JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 38
  • 39. Pass-through attributes <html xmlns="http://www.w3.org/1999/xhtml" ... xmlns:p="http://xmlns.jcp.org/jsf/passthrough"> <div class="col-sm-9"> <h:inputText p:type="date" class="form-control" id="birthday" value="#{customerController.birthday}" p:placeholder="1977-10-25” /> </div> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 39
  • 40. Pass-through elements <html xmlns="http://www.w3.org/1999/xhtml” ... xmlns:jsf="http://xmlns.jcp.org/jsf"> <head jsf:id="head"> ... </head> <body jsf:id="body"> <form jsf:id="vacationForm"> ... <input type="text" jsf:id="companyId" placeholder="Your company identity number” jsf:value="#{vacationController.companyNo}” /> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 40
  • 41. Conversations JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 41
  • 42. Demonstration JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 42 Instant Smart Secure
  • 43. Conversation scope ▪ A lifespan sits between a Http Request scope and Http Session scope ▪ Maintains state for the unique interaction ▪ Works for individual tab in web browsers ▪ Better than @ViewScoped bean controllers ▪ Application defined lifespan JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 43
  • 44. Conversation scoped bean #1 public interface Conversation { void begin(); void begin(String id); void end(); String getId(); long getTimeout(); void setTimeout(long milliseconds); boolean isTransient(); } // import javax.enterprise.context.*; JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 44
  • 45. Conversation scoped bean #2 @Named @ConversationScoped public class LendingController implements Serializable { @EJB ApplicantService applicantService; @Inject Conversation conversation; @Inject Utility utility; public String doConfirm() { ... } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 45
  • 46. Conversation scoped bean #3 @Named @ConversationScoped class LendingController ... { public void checkAndStart() { if ( conversation.isTransient()) conversation.begin(); recalculatePMT(); } public void checkAndEnd() { if (!conversation.isTransient()) conversation.end(); } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 46
  • 47. Conversation scoped bean #4 @Named @ConversationScoped class LendingController ... { public String doLandingPage() { checkAndStart(); return "your-details?faces-redirect=true"; } ... } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 47
  • 48. Conversation scoped bean #5 @Named @ConversationScoped class LendingController ... { public String doCancel() { checkAndEnd(); return "index.xhtml?faces-redirect=true"; } ... } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 48
  • 49. Conversation scope conclusions Pros ▪ Conversation scope is great for “wizards” ▪ Linear sequence of pages ▪ Conversation is unique per tab ▪ Application defines the entry & exit points Cons ▪ Explicitly termination of conversation ▪ Customer jumps away and back again JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 49
  • 50. JSF 2.2 Faces Flows JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 50
  • 51. Flow scope #1 ▪ Brand new scope in JSF 2.2 and Java EE 7 ▪ Modular in execution ▪ Concept of nodes ▪ Associated with a URI path JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 51
  • 52. Flow scope #2 ▪ Flows can nested; a flow can invoke another ▪ Parameters and data can pass to and back through Flow scope map collection ▪ package javax.faces.flow.* JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 52
  • 53. Flow scope #3 ▪ A Flow is a folder name in your web context application ▪ A Flow must have a Flow Definition XML file that matches the folder name ▪ <Flow-Name>/<Flow-Name>-flow.xml ▪ This file can be blank – implicit flow navigation JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 53
  • 54. Flow node types ▪ View – represents any JSF page view ▪ Method Call – method invocation through EL (expression language) ▪ FlowCall – invocation of another flow with inbound and outbound parameters ▪ Flow Return – return to the calling flow ▪ Switch – navigation selection through EL JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 54
  • 55. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 55 sector-flow carbon-footprint-flow Start End
  • 56. Demonstration JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 56 Flow scope application
  • 58. Flow layout project #2 src/main/webapp/footprint/ src/main/webapp/footprint/footprint-flow.xml src/main/webapp/footprint/footprint.xhtml src/main/webapp/footprint/footprint-page-1a.xml src/main/webapp/endflow.xhtml JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 58
  • 59. Flow scoped controller #1 @Named @FlowScoped("sector") public class SectorFlow implements Serializable { @Inject UtilityHelper utilityHelper; @Inject CarbonFootprintService service; public SectorFlow() { ... } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 59
  • 60. Flow scoped controller #2 @Named @FlowScoped("sector") public class SectorFlow implements Serializable { @Inject UtilityHelper utilityHelper; @Inject CarbonFootprintService service; public SectorFlow() { ... } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 60
  • 61. Flow scoped controller #4 public class SectorFlow ...{ @PostConstruct public void initialize() { footprint.setApplicationId( utilityHelper.getNextApplicationId()); } ... } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 61
  • 62. Flow scoped controller #5 public class SectorFlow ...{ public String gotoEndFlow() { return "/endflow.xhtml"; } public String saveFootprintRecord() { service.add(footprint); return "sector-page-1c.xhtml"; } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 62
  • 63. Flow definition XML file #1 <faces-config version="2.2" ...> <flow-definition id="sector"> <flow-return id="goHome"> <from-outcome>/index</from-outcome> </flow-return> ... </flow-definition> </faces-config> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 63
  • 64. Flow definition XML file #2 <faces-config version="2.2" ...> <flow-definition id="sector"> <flow-return id="endFlow"> <from-outcome>#{sectorFlow.gotoEndFlow()} </from-outcome> </flow-return> <flow-call id="callFootprintFlow”>...</flow-call> </flow-definition> ... </faces-config> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 64
  • 65. Flow definition XML file #3 <flow-call id="callFootprintFlow"> <flow-reference><flow-id>footprint</flow-id> </flow-reference> ... <outbound-parameter> <name>param3FromSectorFlow</name> <value>#{sectorFlow.footprint}</value> </outbound-parameter> </flow-call> </flow-definition> </faces-config> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 65
  • 66. Nested flow scope #1 @Named @FlowScoped("footprint") public class FootprintFlow implements Serializable { private CarbonFootprint footprint; @PostConstruct public void initialize() {} Map<Object,Object> flowMap = FacesContext.getCurrentInstance() .getApplication().getFlowHandler() .getCurrentFlowScope(); footprint = (CarbonFootprint) flowMap.get("param3Value"); } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 66
  • 67. Nested flow scope #2 @Named @FlowScoped("footprint") public class FootprintFlow ... { public String exitFromFootprintFlow() { return ”/sector"; } . . . } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 67
  • 68. Nested flow scope #3 @Named @FlowScoped("footprint") public class FootprintFlow ... { . . . public String gotoPage2() { return "footprint-page-1a"; } } JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 68
  • 69. Nested Flow definition XML file #1 <faces-config version="2.2" ...> <flow-definition id="footprint-flow"> <flow-return id="goHome"> <from-outcome>/index</from-outcome> </flow-return> ... </faces-config> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 69
  • 70. Nested Flow definition XML file #2 <faces-config version="2.2" ...> <flow-definition id="footprint"> ... <flow-return id=”exitToCallerFlow"> <from-outcome>#{footprintFlow.exitFromFootprintFlow} </from-outcome> </flow-return> <flow-return id="exitToSectorFlow"> <from-outcome>/sector-flow</from-outcome> </flow-return> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 70
  • 71. Nested Flow definition XML file #3 <flow-definition id="footprint"> ... <inbound-parameter> <name>param1FromSectorFlow</name> <value>#{flowScope.param1Value}</value> </inbound-parameter> ... <inbound-parameter> <name>param3FromSectorFlow</name> <value>#{flowScope.param3Value}</value> </inbound-parameter> JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 71
  • 72. Flow scope bean conclusions Pros ▪ Conversation scope is great for “wizards” ▪ Flow node demarcated by URI folder convention ▪ Nestable flow customer journeys Cons ▪ Handling REDIRECT is difficult (JSF 2.3 perhaps?) ▪ Flow scope parameter passing can be peculiar ▪ Only one START NODE and not configurable JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 72
  • 73. Choosing a scope for a managed bean controller ▪ Sharing data, utility and information for all users, prefer @ApplicationScoped ▪ Sharing information and behavior for an individual customer, prefer @SessionScoped ▪ Customer journey restricted to a specific set of page views, choose @FlowScoped ▪ Defined customer journey and custom application entry and exit points, choose @ConversationScoped ▪ Basic rich validation entry and exit point, prefer @ViewScoped JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 73
  • 74. Adding Finesse ▪ Consider CSS framework such as Bootstrap (http://getbootstrap.com) or Foundation (http://foundation.zurb.com/ ) ▪ Consider SASS or LESS for CSS templates ▪ Learn JavaScript programming ▪ Maybe learn aboutTranspilers ▪ Consider RequireJS (http://requirejs.org/) for organising JavaScript modules JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 74
  • 75. Design considerations ▪ Evolution of object oriented JavaScript leads to rich frameworks inside the client’s web browser ▪ JSF lends itself to page view navigation ▪ Hybrid design is possible with JSF and adopting JavaScript controller ▪ JSF 2.2 Faces Flows is a major feature worthy of investigation JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 75
  • 76. Non-Functional Requirement HealthCare.gov site must handle 10,000 customers at once. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 76
  • 77. It failed with just a few hundred users. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 77
  • 78. HealthCare.gov (USA) Website cost $300 million price tag JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 78
  • 79. Don’t worry USA! British NHS IT system was abandoned after 10 years and cost the tax payer £10bn so far JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 79
  • 80. ▪ Innovate with optionality ▪ Constraints ▪ Build fast, fail fast ▪ Communication ▪ Technology == evolution JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 80
  • 81. JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 81 Executive Summary Hints and tips and where to go next
  • 82. Conclusions ▪ Leverage Java EE 7 platform ▪ Choose scope by lifespan of the bean ▪ Prefer Faces Flows for digital customer journeys ▪ Otherwise Conversation-Scoped beans ▪ Prefer HTML5 friendly markup of Facelets views ▪ Prefer CDI JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 82
  • 83. Conclusions #2 ▪ Protect your from UX changes ▪ Keep action controller methods short ▪ Delegate complex logic to business logic ▪ Use DOMAIN MODEL CONTEXT objects ▪ Avoid methods with long parameter lists! ▪ Inject DOMAIN MODEL LOGIC JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 83
  • 84. Contacts ▪ Follow me onTwitter @peter_pilgrim ▪ Read my blog http://xenonique.co.uk/blog/ ▪ Books from Packt Publishing –Digital Java EE 7 –Java EE 7 Developer Handbook JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 84
  • 85. Photo credits (cc) 2016 ▪ by Joshua Earle https://unsplash.com/joshuaearle ▪ By Lili Popper https://unsplash.com/lili_popper ▪ By Rowan Heuvel https://unsplash.com/insolitus ▪ By David Marcu https://stocksnap.io/author/302 JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 85
  • 86. Photo credits (cc) 2016 ▪ By Gemma Bou (hand fractal) https://www.flickr.com/photos/gemmabou/ ▪ By Nicole Hanusek (luggage) https://www.flickr.com/photos/nhanusek/ ▪ By Navaneeth KN (group photo painted stork) https://www.flickr.com/photos/navaneethkn/ ▪ By Ruben Schade (container ship in the Straits of Singapore) https://www.flickr.com/photos/rubenerd/ JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 86
  • 87. Photo credits (cc) 2016 ▪ Joel Cooper (big face 1) https://www.flickr.com/photos/origamijoel/ ▪ Nullfy from nullfy.com! (Ring of Power!) https://www.flickr.com/photos/130197050@N04/ ▪ philippe leroyer (Student Demonstration (46) - 27Nov07, Paris (France)) https://www.flickr.com/photos/philippeleroyer/ ▪ philippe leroyer (Pupil's Demonstration (10) - 10Apr08, Paris (France)) https://www.flickr.com/photos/philippeleroyer/ JavaOne 2015 - CON5211 - P.E.A.T UK LTD (C) follow me on Twitter @peter_pilgrim 87

Editor's Notes

  1. You probably need to use Java Web Filter mechanism to add the security domain to your request scope