0% found this document useful (0 votes)
74 views15 pages

Jboss Seam: Agenda

This document provides an overview of JBoss SEAM, which combines JavaServer Faces and EJB3. It begins with background on JSF, EJB3, and other technologies like Ajax. It then introduces SEAM, describing its features for integrating these technologies. The document concludes with an example of using the SEAM generator to quickly set up a project and entities, and demonstrates injection, navigation rules, and other SEAM capabilities.

Uploaded by

osmanizbat
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views15 pages

Jboss Seam: Agenda

This document provides an overview of JBoss SEAM, which combines JavaServer Faces and EJB3. It begins with background on JSF, EJB3, and other technologies like Ajax. It then introduces SEAM, describing its features for integrating these technologies. The document concludes with an example of using the SEAM generator to quickly set up a project and entities, and demonstrates injection, navigation rules, and other SEAM capabilities.

Uploaded by

osmanizbat
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

JBoss SEAM

Sewing together JSF and EJB3

Andy Bosch
Independent consultant
2060

AGENDA
> Basic technologies
– What is JavaServer Faces?
– What is EJB3?
– What else? Ajax? PPR? Remoting? ...
> JBoss SEAM
– Introduction
– Features
> Case study
– Using Seam generator
– Entity Beans and Session Beans
– Injection, outjection, bijection
– Other cool features

1
3

AGENDA
> Basic technologies
– What is JavaServer Faces?
– What is EJB3?
– What else? Ajax? PPR? Remoting? ...
> JBoss SEAM
– Introduction
– Features
> Case study
– Using Seam generator
– Entity Beans and Session Beans
– Injection, outjection, bijection
– Other cool features

JavaServer Faces

> JavaServer Faces is a user interface framework to generate user


interfaces for web applications

> JavaServer Faces is a standard. The first version was released as


JSR 128 in March 2004.

> Together with Java EE 5, JSF is now part of the EE range.

> From my (subjective) point of view, JSF these days has established itself
as standard UI framework, many companies and projects are based on
it.

2
5

EJB3

> Central element within the Java Enterprise Edition

> Basis for business-critical software components, like the access to


aspects of transaction, persistence, and safety of a Java EE container is
possible.

> EJB3 offers a considerable simplification concerning the applicability


and pace of development compared to EJB2.x

> Marginal “detail”: annotations instead of configuration files

Ajax, PPR, remoting, ...

> Ajax is one (if not the most important) pillar of Web 2.0

> With Ajax, server functions can be called from the browser in an
asynchronous manner.

> Ajax enables to change only parts of a webpage (Partial Page


Rendering) instead of re-loading the entire page (Full Page Reload)

> Cool, modern, and extremely user-friendly user interfaces (even for the
browser) can be written with Ajax.

3
7

The result of all the ingredients put together...

> Each of the mentioned technologies alone works very well.

> It becomes difficult, when the technologies are to be combined with each
other.
 Sometimes it requires a lot of glue code.

> Another possibility to get and to use all the technologies mentioned
“from one source” : SEAM

AGENDA
> Basic technologies
– What is JavaServer Faces?
– What is EJB3?
– What else? Ajax? PPR? Remoting? ...
> JBoss SEAM
– Introduction
– Features
> Case study
– Using Seam generator
– Entity Beans and Session Beans
– Injection, outjection, bijection
– Other cool features

4
9

What is SEAM?

• Seam is an application framework, which specially puts EJB3 and JSF


closer together.

• But not only JSF and EJB3 are combined, other technologies as Ajax,
pdf generation, BPM and many more are integrated too.

• Seam has many features / concepts, which considerably simplify a


development of applications based on JSF (pre-actions, button-back
treatment, …)

• Seam provides additional components.

10

SEAM and JBoss

• SEAM was developed under the direction of JBoss (Gavin King).

• SEAM can be of course ideally connected with other products of the


JBoss range.

• SEAM does also work in other application servers though. It is even


possible to run SEAM in a web container by means of the micro-container.

• JBoss has submitted SEAM for standardization. The JSR 299 (WebBeans)
is currently being dealt with.

5
11

Essential properties
• SEAM is based on POJOs (with annotations).

• There are no separate managed beans (for JSF) and separate


persistence beans, but only components of Seam.

• So there is no division into layers anymore (at least not too distinct).

• SEAM provides a remoting function, which can be used to call up EJB


methods via Ajax.

• SEAM has an own Business Process Management Engine (jBPM) to map


workflows.

12

Cool stuff

• SEAM introduces Bijection (combination of injection and outjection)

• SEAM introduces new contexts: Conversation Scope and Business


Process Scope.

• SEAM solves the “Open-in-new-window” problem.

• SEAM is by default based on Facelets.

• SEAM offers a generator to set up new projects and artifacts very


quickly.

6
13

AGENDA
> Basic technologies
– What is JavaServer Faces?
– What is EJB3?
– What else? Ajax? PPR? Remoting? ...
> JBoss SEAM
– Introduction
– Features
> Case study
– Using Seam generator
– Entity Beans and Session Beans
– Injection, outjection, bijection
– Other cool features

14

Hands-on example

• Set-up of a shop application. The user is to select one


product from a list and start the ordering process.

Here especially:
• use of the Seam generator
• injection
• data list and open-in-new-window
• conversation scope

7
15

Use of Seam-Gen

By means of the Seam generator, complete Seam projects and


Seam artifacts can be generated very quickly.

Use:

seam setup
seam new-project
seam new-form
...

16

Generation of an Entity Bean

@Name("ProductCatalog") @Name
@Scope(ScopeType.SESSION)  SEAM component
@Entity
@Table(name="catalog") @Entity
public class ProductCatalogBean {  EJB Entity Bean

@Id @NotNull
private long id;

private String name;

@DataModel(value="choiceProducts") @DataModel
private List<ProductBean> products;  see next page
...

8
17

Binding to the surface


@DataModel from
Managed Bean
...
Pricelist #{ProductCatalog.name}

<h:dataTable var="current" value="#{choiceProducts}">


<h:column>
<s:link action="#{ShopController.selectProduct(current)}"
value="#{current.name}" />
</h:column>
</h:dataTable>
...

Action method with parameter

18

Controller logic: Session Beans

@Name("ShopController") @Name
@Scope(ScopeType.SESSION)  SEAM component
public class ShopController {

@In(create=true) @In
private ShoppingCart shoppingCart;  Injection

public String selectProduct(


ProductBean prod ) {

shoppingCart.setProduct(prod);
return „success“;
}
...

9
19

Navigation rules (1)

Seam offers an extended syntax for navigation rules, defined in the


pages.xml.
<page view-id="/startPage.xhtml">
<navigation from-action="#{controller.update}">
<rule if-outcome="success">
<redirect view-id="/resultPage.xhtml"/>
</rule>
</navigation>
</page>

20

Navigation rules (2)

In addition, expressions can be used in the rules:

<page ...>
<navigation from-action="#{startPage.update}"
evaluate="#{controller.errors.size}">
<rule if-outcome="0">
<redirect view-id="/resultPage.xhtml"/>
</rule>
</navigation>
</page>

10
21

Pre-actions und request parameters

In the use of the pages.xml, it is possible to define pre-actions or read


in request parameters.

<page view-id="/hello.jsp"
action="#{helloWorld.preparePage}"> ...

<page view-id="/hello.jsp">
<param name="vorname" value="#{person.firstName}"/>
..

22

What about “faces-config.xml”?

• A faces-config.xml continues to exist.

• A “Managed Bean” section is not required anymore.

• Managed Beans are declared exclusively via annotations in the Java


classes.

• Navigation rules can be given according to the “JSF style“, or a


changeover to the pages.xml is possible.

• Additional configurations (render kits, custom components, message


bundles etc.) are still carried out in the faces-config.

11
23

Open-in-new-window

Initial position: A user can keep open several windows with of different
program states at the same time.

Here, SEAM defines so-called conversations.

 All beans with scope Conversation can thus be stored several times
within one session (per conversation).

 To be able to execute an action method in a new window, there is the


s:link- (or s:button) component / tag.

24

Build, deploy and start


• If projects are set up via the SEAM generator, an Ant-script is
automatically generated.

• Restart of the context is not required for Xhtml pages. A restart is required
for changes in Java classes and configuration files.

• If a packaging / deployment is to be set up manually (e.g. for a Maven


integration), you will need patience and some time. ☺

• The above statements are exclusively applicable for an implementation in


JBoss, it will require a bit more patience and a bit more time for other
application servers. ☺

12
25

After all, do I like it?

- Well, it’s quite cool.

- Only who has already done projects with standard JSF and Hibernate
is able to really appreciate the advantages of SEAM.

- Direct entry into SEAM without any knowledge of JSF and EJB3 is on
the one hand quite simple, but on the other hand also risky (mixture of
technologies).

- There is light and shadow.

 Pros and cons?

26

Pros and cons

• Starting with the pros:

• Fully integrated Java EE 5 based web application framework

• By means of Seam-Gen, very quick generation of applications

• Simplification of an EJB3 and JSF development to the effect that no more


glue code is required

• Many cool features, which considerably simplify the development of


applications (pre-actions, request parameters, conversation scope, ...)

13
27

Pros and cons

Now the cons:

• No layers any more, but I like layers!!!

• Mixture of GUI and persistence layer

• Not yet standardized

• Application developers learn only “Seam” and do not know the basic
technologies.

28

Conclusion

• Seam certainly provides some useful and valuable extensions for a


web application development.

• Seam works. ☺

• The abolition of the strict division into layers is a matter of opinion.

• You either love it or you hate it.

14
Questions? Comments?

Andy Bosch www.jsf-forum.de


Independent Consultant [email protected]

15

You might also like