Presentation is loading. Please wait.

Presentation is loading. Please wait.

8/15/2003System Specialists Corporation How to implement BC4J with the Struts Framework Eugene Sicat Technical Architect/Project Manager System Specialists.

Similar presentations


Presentation on theme: "8/15/2003System Specialists Corporation How to implement BC4J with the Struts Framework Eugene Sicat Technical Architect/Project Manager System Specialists."— Presentation transcript:

1 8/15/2003System Specialists Corporation How to implement BC4J with the Struts Framework Eugene Sicat Technical Architect/Project Manager System Specialists Corporation Session Id: 36702

2 8/15/2003System Specialists Corporation Next Steps … Recommended sessions –40212 - “Take Control” of Your J2EE Applications with Apache Struts and Oracle JDeveloper 10g – Focus on the MVC Controller –37002 - Developing J2EE Applications with Oracle9i JDeveloper and Struts Recommended demos and/or hands-on labs –http://otn.oracle.com/products/jdev/htdocs/handson/Frameworks/bc4jh andson.htmlhttp://otn.oracle.com/products/jdev/htdocs/handson/Frameworks/bc4jh andson.html –http://otn.oracle.com/sample_code/products/jdev/bc4jknowledgeBase/r eadme.html#ID148http://otn.oracle.com/sample_code/products/jdev/bc4jknowledgeBase/r eadme.html#ID148 See Your Business in Our Software –Visit the DEMOgrounds Relevant web sites to visit for more information –http://otn.oracle.com/products/jdev/htdocs/j2ee_bc4j.htmlhttp://otn.oracle.com/products/jdev/htdocs/j2ee_bc4j.html –http://otn.oracle.com/products/jdev/howtos/jsp/StrutsHowTo.htmlhttp://otn.oracle.com/products/jdev/howtos/jsp/StrutsHowTo.html

3 8/15/2003System Specialists Corporation Reminder Please complete the OracleWorld online session survey Thank you.

4 8/15/2003System Specialists Corporation Outline Sample App MVC, BC4J, Struts BC4J/Struts Integration Master/Detail code

5 8/15/2003System Specialists Corporation Approach Better approach to learning Show the running application Browse the code –Start from the view –Drill to the controller –Drill to the model

6 8/15/2003System Specialists Corporation Sample App

7 8/15/2003System Specialists Corporation Sample App

8 8/15/2003System Specialists Corporation Sample App

9 8/15/2003System Specialists Corporation Sample App

10 8/15/2003System Specialists Corporation JSP (View) :

11 8/15/2003System Specialists Corporation XML Config (Controller) <action path="/browsekb" type=“com.ssc.kb.controller.BrowseDataAction"> <set-property property="application" value="KnowledgeBaseAppModule"/> <set-property property="viewobject" value="KnowledgeBaseDataView"/> <forward name="success" path="/WEB-INF/jsp/browsekb.jsp"/>

12 8/15/2003System Specialists Corporation View Object (Model) <ViewObject Name=“KnowledgeBaseDataView" : <![CDATA[ SELECT KB_ID, KB_DESC, ENT_DATE, ENT_BY FROM KNOWLEDGE_BASE ]]> :

13 8/15/2003System Specialists Corporation MVC View (JSP) Controller (User input / page flow handling logic) Model (Business Service, Objects, Data)

14 8/15/2003System Specialists Corporation Struts Framework Consistent development approach

15 8/15/2003System Specialists Corporation Struts Framework Consistent development approach View Controller Model

16 8/15/2003System Specialists Corporation Struts Framework Separate configuration from code

17 8/15/2003System Specialists Corporation Struts Framework Separate configuration from code –Java –XML

18 8/15/2003System Specialists Corporation Struts Framework Separate configuration from code –XML (struts-config.xml) <action path="/browsekb" type=“com.ssc.kb.controller.BrowseDataAction"> <set-property property="viewobject" value="KnowledgeBaseDataView"/> <forward name="success" path="/WEB-INF/jsp/browsekb.jsp"/>

19 8/15/2003System Specialists Corporation Struts Framework Components –JSP using Struts Tag –Controller setup in struts-config.xml –ActionForm –Action

20 8/15/2003System Specialists Corporation Struts Framework Easy to test

21 8/15/2003System Specialists Corporation Struts Framework Easy to test –StrutsTestCase –MockObjects –Cactus

22 8/15/2003System Specialists Corporation Struts Framework Much simpler than Sun’s Java Pet Store Demo

23 8/15/2003System Specialists Corporation BC4J Framework Entity Objects and Associations

24 8/15/2003System Specialists Corporation BC4J Framework Entity Objects and Associations –business rules –persistence details –express the relationships

25 8/15/2003System Specialists Corporation BC4J Framework Entity Objects and Associations –business rules –persistence details –express the relationships Excellent Reference –http://otn.oracle.com/products/jdev/htdocs/han dson/Frameworks/bc4jhandson.htmlhttp://otn.oracle.com/products/jdev/htdocs/han dson/Frameworks/bc4jhandson.html

26 8/15/2003System Specialists Corporation BC4J Framework

27 8/15/2003System Specialists Corporation BC4J Framework View objects and links

28 8/15/2003System Specialists Corporation BC4J Framework View objects and links –Updateable data transfer objects –Based on SQL queries

29 8/15/2003System Specialists Corporation BC4J Framework

30 8/15/2003System Specialists Corporation BC4J Framework

31 8/15/2003System Specialists Corporation BC4J Framework Application Module –Transactional business services –“Business Delegate” J2EE Design Pattern

32 8/15/2003System Specialists Corporation BC4J Framework

33 8/15/2003System Specialists Corporation BC4J/Struts Integration BC4J complements the model layer of Struts

34 8/15/2003System Specialists Corporation BC4J/Struts Integration automate interaction of Form Beans and BC4J's objects

35 8/15/2003System Specialists Corporation BC4J/Struts Integration automate interaction of Form Beans and BC4J's objects <action path="/browsekb" type=“com.ssc.kb.controller.BrowseDataAction"> <set-property property="application" value="KnowledgeBaseAppModule"/> <set-property property="viewobject" value="KnowledgeBaseDataView"/> <forward name="success" path="/WEB-INF/jsp/browsekb.jsp"/>

36 8/15/2003System Specialists Corporation BC4J/Struts Integration High-performance Business Delegate

37 8/15/2003System Specialists Corporation BC4J/Struts Integration High-performance Business Delegate –finds and pools business service components

38 8/15/2003System Specialists Corporation BC4J/Struts Integration High-performance Business Delegate –finds and pools business service components am.findViewObject(“string-key-name”)

39 8/15/2003System Specialists Corporation BC4J/Struts Integration High-performance Business Delegate –finds and pools business service components am.findViewObject(“string-key-name”) : am.createRecord(aRecord)

40 8/15/2003System Specialists Corporation BC4J/Struts Integration High-performance Business Delegate –finds and pools business service components am.findViewObject(“string-key-name”) : am.createRecord(aRecord) : am.commitChanges()

41 8/15/2003System Specialists Corporation BC4J/Struts Integration Customized Struts Request Processor

42 8/15/2003System Specialists Corporation BC4J/Struts Integration Customized Struts Request Processor <controller debug="0" locale="true" processorClass= “com.ssc.kb.controller.KnowledgeBaseRequestPr ocessor" contentType="text/html" />

43 8/15/2003System Specialists Corporation BC4J/Struts Integration Customized Struts Request Processor -processRoles -processActionForward -processActionForm

44 8/15/2003System Specialists Corporation How to Options #1 Create from scratch #2 Migrate old MVC

45 8/15/2003System Specialists Corporation Option #1: Create from scratch Create entity objects and associations Create view objects Create view links Create application module Create complete struts-app using wizard Reference: http://otn.oracle.com/products/jdev/htdocs/h andson/Frameworks/bc4jhandson.html

46 8/15/2003System Specialists Corporation Option #1: Create from scratch

47 8/15/2003System Specialists Corporation Option #1: Create from scratch

48 8/15/2003System Specialists Corporation Option #2: Migrate old MVC 1.inherit from struts.Action

49 8/15/2003System Specialists Corporation Option #2: Migrate old MVC 1.inherit from struts.Action public class KnowledgeBaseAction extends Action { public ActionForward execute ( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)

50 8/15/2003System Specialists Corporation Option #2: Migrate old MVC 2. migrate action mappings to struts-config.xml <action path="/browsekb“ type="org.apache.struts.action.ForwardAction“> <forward name="success“ path="/browsekb.jsp"/>

51 8/15/2003System Specialists Corporation Option #2: Migrate old MVC 3. configure to use struts.ActionServlet web.xml: org.apache.struts.action.ActionServlet

52 8/15/2003System Specialists Corporation Option #2: Migrate old MVC 4. migrate messages and labels to resources ApplicationResources.properties: DataTransaction.commit=Commit DataQuery.search=Search DataTable.edit=Edit :

53 8/15/2003System Specialists Corporation Installation/Configuration 1.1. web.xml – action servlet org.apache.struts.action.ActionServlet

54 8/15/2003System Specialists Corporation Installation/Configuration 1.2. web.xml – Taglib /webapp/DataTags.tld /WEB-INF/lib/datatags.jar /WEB-INF/struts-bean.tld

55 8/15/2003System Specialists Corporation Installation/Configuration 2.1. JAR files - BC4J jars - under /BC4J/lib

56 8/15/2003System Specialists Corporation Installation/Configuration 2.2. JAR files - Struts jar - under /WEB-INF/lib

57 8/15/2003System Specialists Corporation Installation/Configuration 3.1. struts-config.xml install under /WEB-INF/lib 3.2. TagLib definition files - *tld install under /WEB-INF/lib

58 8/15/2003System Specialists Corporation Challenge with Master/Detail What’s the common challenge? What does a user normally want in their application? How does it affect your architecture?

59 8/15/2003System Specialists Corporation Browse

60 8/15/2003System Specialists Corporation Edit Master/Display Detail

61 8/15/2003System Specialists Corporation Edit Detail

62 8/15/2003System Specialists Corporation JBO Tag Java Business Object tag

63 8/15/2003System Specialists Corporation JBO Tag Java Business Object tag <%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>

64 8/15/2003System Specialists Corporation JBO Tag Java Business Object tag : :

65 8/15/2003System Specialists Corporation Struts tag

66 8/15/2003System Specialists Corporation Struts tag

67 8/15/2003System Specialists Corporation JBO vs Struts tags JBO for RAD

68 8/15/2003System Specialists Corporation JBO vs Struts tags JBO for RAD JBO integration with BC4J objects

69 8/15/2003System Specialists Corporation JBO vs Struts tags JBO for RAD JBO integration with BC4J objects JBO consistency

70 8/15/2003System Specialists Corporation JBO vs Struts tags Struts flexibility

71 8/15/2003System Specialists Corporation JBO vs Struts tags Struts flexibility Struts richness

72 8/15/2003System Specialists Corporation JBO vs Struts tags Struts flexibility Struts richness Struts many contributors

73 8/15/2003System Specialists Corporation Where to use Struts tags Sophisticated browse with sort, display formats

74 8/15/2003System Specialists Corporation Where to use Struts tags Sophisticated browse with sort, display formats Master/Detail CRUD

75 8/15/2003System Specialists Corporation Master/Detail

76 8/15/2003System Specialists Corporation Master/Detail

77 8/15/2003System Specialists Corporation Master/Detail BC4J –KnowledgeBase* –KnowledgeBaseDetail* –KnowledgeBaseDetailViewLink* –KnowledgeBaseAppModule

78 8/15/2003System Specialists Corporation Master/Detail public class KnowledgeBaseForm extends ActionForm { String kbBaseId; String kbDesc; String repDate; String repBy; ArrayList kbFormDetails; : public ArrayList getDetails(…) {…} public void setDetails(…) {…} publjc void setKnowledgeBaseFromViewObject (KnowledgeBaseVIew kbView){…} public void setKnowledgeBaseFromViewObject (KnowledgeBaseDetailVIew kbDetailView() {…} }

79 8/15/2003System Specialists Corporation Master/Detail public class KnowledgeBaseDetail { String kbId; String entDate; String details; String ref; public void KnowledgeBaseDetail() {…} : public String getEntDate() {…}; : public void setEntDate(…) {…}; }

80 8/15/2003System Specialists Corporation Master/Detail public class KnowledgeBaseAction extends Action { public ActionForward execute(ActionForm newForm,.) { String id = request.getParameter(“id”); KnowledgeBaseForm form = (KnowledgeBaseForm) newForm; KnowledgeBaseAccess access = new KnowledgeBaseAccess(); if (action.equals(“Edit”) { access.getKnowledgeBase(id, form); return (mapping.findForward("success")); } else if ( action.equals(“Save”) { if (access.saveKnowledgeBase(form) ) return (mapping.findForward("saved")); elsereturn (mapping.findForward(“failure")); }}}

81 8/15/2003System Specialists Corporation Master/Detail public class KnowledgeBaseAccess { public void getKnowledgeBase(String id, … form) { KnowledgeBaseView kbView = (KnowledgeBaseView) appModule.findKnowledgeBaseView(id); /* no need to find the dtl because the view link forced the child to follow the parent so just get it */ KnowledgeBaseDetailViewImpl kbDetailView = appModule.getKnowledgeBaseDetailView(); form.setKnowledgeBaseFromViewObject(kbView); form.setKnowledgeBaseDetailFromViewObject (kbDetailView); }

82 8/15/2003System Specialists Corporation Master/Detail public class KnowledgeBaseAccess { public void saveKnowledgeBase(…kbForm) { Long id = kbForm.getKnowledgeBaseId(); Key key = new Key(new Object[] { id }); Row kbRow[] = appModule.findKnowledgeBaseView(key); setKnowledgeBase(kbForm, kbRow[0]); KnowledgeBaseDetailViewImpl kbFormDetailView = appModule.getKnowledgeBaseDetailView(); setKnowledgeBaseDetails(kbForm, kbFormDetailView); }

83 8/15/2003System Specialists Corporation Master/Detail private void setKnowledgeBase(… kbForm, Row row) { row.setAttribute(“KbId", kbForm.getMKbId()); row.setAttribute("RepDt", kbForm.getRepDt()); row.setAttribute("RepBy", kbForm.getRepBy()); row.setAttribute("KbDesc“, kbForm.getKbDesc()); }

84 8/15/2003System Specialists Corporation Master/Detail private void setKnowledgeBaseDetails (… kbForm, … kbFormDetailView)) { List kbFormDetails = kbForm.getDetails(); Iterator i = kbFormDetails.iterator(); while (i.hasNext()) { KnowledgeBaseDetail kbFormDetail = (KnowledgeBaseDetail) i.next(); setOneKnowledgeBaseDetail (kbFormDetail,kbFormDetailView); }

85 8/15/2003System Specialists Corporation Master/Detail private void setOneKnowledgeBaseDetail (…kbFormDetail,... kbFormDetailView) { Row row = getKbDetailViewRow (kbFormDetailView, kbFormDetail); row.setAttribute(“Detail", kbFormDetail.getDetail()); row.setAttribute(“EntDt", kbFormDetail.getEntDt()); row.setAttribute(“Ref", kbFormDetail.getRef()); }

86 8/15/2003System Specialists Corporation Master/Detail Struts-config.xml <action path="/editKnowledgeBase" type=“com.ssc.kb.model.KnowledgeBaseAction" attribute="knowledgeBaseForm"…> <forward name="success" path="/editKnowledgeBase.jsp"/> <forward name=“saved" path="/browseKnowledgeBase.jsp"/> <forward name=“failure" path="/editKnowledgeBase.jsp"/>

87 8/15/2003System Specialists Corporation Master/Detail - JSP Knowledge Base Id: Description: Date Reported:

88 8/15/2003System Specialists Corporation Master/Detail – JSP cont’n Date Details Reference

89 8/15/2003System Specialists Corporation Master/Detail

90 8/15/2003System Specialists Corporation Summary BC4J and Struts – great combination

91 8/15/2003System Specialists Corporation Summary BC4J and Struts – great combination RAD

92 8/15/2003System Specialists Corporation Summary BC4J and Struts – great combination RAD Consistent

93 8/15/2003System Specialists Corporation Summary BC4J and Struts – great combination RAD Consistent Industry standard

94 8/15/2003System Specialists Corporation Summary BC4J and Struts – great combination RAD Consistent Industry standard Becoming widely used

95 8/15/2003System Specialists Corporation Summary BC4J and Struts – great combination RAD Consistent Industry standard Becoming widely used Easy to learn

96 8/15/2003System Specialists Corporation Q & A Questions and Answers


Download ppt "8/15/2003System Specialists Corporation How to implement BC4J with the Struts Framework Eugene Sicat Technical Architect/Project Manager System Specialists."

Similar presentations


Ads by Google