Markos FragkakisJHUG meeting 20 Nov 2010
My experience with JBoss Seam and JSF:•  Used plain JSF 1.2 for prototype (~1 month)•  Used Seam 2.2 in actual implementat...
    Separated business logic     in:	     ◦    JSF managed beans	     ◦    Business components (EJBs)	    EJB lookup	Con...
  One kind of “stuff ”  Seam Components     ◦  POJOs     ◦  EJB     ◦  Entities    Seam unifies Java EE:     ◦    Depen...
faces-config.xml	    JSF                                        <managed-bean>	     ◦  Through faces-config.xml          ...
    Injection of Seam     components       @Name("myBean")	                        @Scope(ScopeType.EVENT)	     ◦  EJB   ...
    State:     ◦  Server (i.e. session)     ◦  Client (i.e. hidden fields)     ◦  Combination    JSF     ◦  Request para...
     JSF UI Component      tree and state     ◦  Tomahawk <t:saveState>     ◦  Richfaces <a4j:keepAlive>    If client-si...
    Session     ◦  Problems:         Increased memory usage         Scalability problems         Need to consider     ...
    Seam scopes:     ◦  Event (Request)     ◦  Session     ◦  Application     ◦  Page     ◦  Stateless     ◦  Business Pr...
  Conversation end / timeout  Aggressive management
    Application Security:     ◦  Page-level security     ◦  Component-level security    JSF does not specify security  ...
     Both Page-level and Component-level security     Some examples:      ◦  Page-level authentication / authorization<p...
<h:commandLink value="Click here” action="#{myBean.method}">	  <f:setPropertyActionListener target="#{myBean.methodParamet...
<h:commandLink value="Click here” action="#{myBean.method(value)}” />	@Name("myBean")	public class MyBean {	     public St...
  Help:  ◦  Good books  ◦  Extensive, up-to-date documentation  ◦  Old forum, somewhat inactive  ◦  StackOverflow.com  I...
?
JBoss Seam vs JSF
Upcoming SlideShare
Loading in …5
×

JBoss Seam vs JSF

8,741 views

Published on

A comparison between JBoss Seam 2.2 and JSF 1.2 vanilla. I gave this presentation at the JHUG event of the 20 November 2010.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
8,741
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
93
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

JBoss Seam vs JSF

  1. 1. Markos FragkakisJHUG meeting 20 Nov 2010
  2. 2. My experience with JBoss Seam and JSF:•  Used plain JSF 1.2 for prototype (~1 month)•  Used Seam 2.2 in actual implementation (~9months)What is this presentation about?•  Common tasks where Seam makes life easier
  3. 3.   Separated business logic in: ◦  JSF managed beans ◦  Business components (EJBs)   EJB lookup Context context = new InitialContext(); context.lookup("java:comp/env/...");
  4. 4.   One kind of “stuff ”  Seam Components ◦  POJOs ◦  EJB ◦  Entities  Seam unifies Java EE: ◦  Dependency Injection ◦  Transactions ◦  Security  No separation between front- end components and business components.  Define your own architecture
  5. 5. faces-config.xml   JSF <managed-bean> ◦  Through faces-config.xml <managed-bean-name>myBean1</managed-bean-name> <managed-bean-class>mypackage.MyBean1</managed- bean-class>   Java EE: @EJB <managed-bean-scope>application</managed-bean- scope> </managed-bean> ◦  Servlets, Filters, Listeners <managed-bean> ◦  Tag handlers, tag library <managed-bean-name>myBean2</managed-bean-name> event listeners <managed-bean-class>mypackage.MyBean2</managed- bean-class> <managed-bean-scope>request</managed-bean-scope> … but not in JSF Managed <managed-property> beans (backing beans) <property-name>myBean1</property-name> <value>#{myBean1}</value> </managed-property> </managed-bean>
  6. 6.   Injection of Seam components @Name("myBean") @Scope(ScopeType.EVENT) ◦  EJB public class MyBean { ◦  Entities @In(create=true) ◦  POJOs private AccountFacadeRemote accountFacade;   Outjection @In(scope=ScopeType.CONVERSATION) @Out(scope=ScopeType.CONVERSATION) private AccountEntity accountEntity; @In @Out private SomePojo somePojo; …
  7. 7.   State: ◦  Server (i.e. session) ◦  Client (i.e. hidden fields) ◦  Combination  JSF ◦  Request parameters (i.e. hidden fields) ◦  Cookies ◦  URLs: http://jhug.gr/user/markos  Maybe a problem: object != object
  8. 8.   JSF UI Component tree and state ◦  Tomahawk <t:saveState> ◦  Richfaces <a4j:keepAlive>  If client-side state: object != object
  9. 9.   Session ◦  Problems:   Increased memory usage   Scalability problems   Need to consider multiple tabs
  10. 10.   Seam scopes: ◦  Event (Request) ◦  Session ◦  Application ◦  Page ◦  Stateless ◦  Business Process ◦  Conversation  What is a conversation? ◦  Lives for multiple requests ◦  Stateful, but not session
  11. 11.   Conversation end / timeout  Aggressive management
  12. 12.   Application Security: ◦  Page-level security ◦  Component-level security  JSF does not specify security  Can a filter be used? ◦  Does View Handler use the Servlet Request Dispatcher?   JSP:Yes<filter-mapping> <filter-name>My Security Filter</filter-name> <url-pattern>/view2.jsp</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping>   Facelets: No
  13. 13.   Both Page-level and Component-level security  Some examples: ◦  Page-level authentication / authorization<pages login-view-id="/login.xhtml"> <page view-id=”admin*" login-required="true”> <restrict>#{s:hasRole(admin)}</restrict> </page> </pages> <security:identity authenticate-method="#{authManager.authenticate}"/> ◦  Page customization <s:link view="/jhug/deleteMember.xhtml" value="Delete" rendered="#{s:hasRole(admin) || s:hasRole(’usermanager)}"/> ◦  Component-level authorization @Name("myBean") @Scope(ScopeType.SESSION) @Restrict("#{s:hasRole(admin)}") public class MyBean implements Serializable { …
  14. 14. <h:commandLink value="Click here” action="#{myBean.method}"> <f:setPropertyActionListener target="#{myBean.methodParameter}”value="#{value}" /> </h:commandLink> public class MyBean { private String param; public String method() { if("something".equals(param)) { return "ok"; } return "notOk"; } public String getParam() { return param; } public void setParam(String param) { this.param = param; } }
  15. 15. <h:commandLink value="Click here” action="#{myBean.method(value)}” /> @Name("myBean") public class MyBean { public String method(String param) { if("something".equals(param)) { return "ok"; } return "notOk"; } }
  16. 16.   Help: ◦  Good books ◦  Extensive, up-to-date documentation ◦  Old forum, somewhat inactive ◦  StackOverflow.com  Issues: ◦  Works best on JBoss AS ◦  Seam 2 issues are resolved slowly (Focus on Seam 3)
  17. 17. ?

×