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

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

Embed Size (px)

Citation preview

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

8/15/2003 System Specialists Corporation

How to implement BC4J with the Struts Framework

Eugene SicatTechnical Architect/Project Manager

System Specialists Corporation

Session Id: 36702

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

8/15/2003 System 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.html– http://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.html– http://otn.oracle.com/products/jdev/howtos/jsp/StrutsHowTo.html

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

8/15/2003 System Specialists Corporation

Reminder

Please complete the OracleWorld online session survey

Thank you.

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

8/15/2003 System Specialists Corporation

Outline

• Sample App

• MVC, BC4J, Struts

• BC4J/Struts Integration

• Master/Detail code

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

8/15/2003 System 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

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

8/15/2003 System Specialists Corporation

Sample App

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

8/15/2003 System Specialists Corporation

Sample App

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

8/15/2003 System Specialists Corporation

Sample App

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

8/15/2003 System Specialists Corporation

Sample App

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

8/15/2003 System Specialists Corporation

JSP (View)

<table>

<jbo:RowsetIterate …>

<tr> :

<td><jbo:ShowValue dataitem=“kbDesc"/></td>

<td><jbo:ShowValue dataitem=“repDate"/></td>

<td><jbo:ShowValue dataitem=“repBy"/></td>

</tr>

</jbo:RowsetIterate>

</table>

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

8/15/2003 System 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"/>

</action>

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

8/15/2003 System Specialists Corporation

View Object (Model)<ViewObject

Name=“KnowledgeBaseDataView"

:

<SQLQuery><![CDATA[

SELECT KB_ID, KB_DESC, ENT_DATE, ENT_BY

FROM KNOWLEDGE_BASE

]]></SQLQuery>

:

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

8/15/2003 System Specialists Corporation

MVC

View(JSP)

Controller(User input / page flow handling logic)

Model(Business Service, Objects, Data)

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

8/15/2003 System Specialists Corporation

Struts Framework

• Consistent development approach

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

8/15/2003 System Specialists Corporation

Struts Framework

• Consistent development approach

View

Controller

Model

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

8/15/2003 System Specialists Corporation

Struts Framework

• Separate configuration from code

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

8/15/2003 System Specialists Corporation

Struts Framework

• Separate configuration from code– Java– XML

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

8/15/2003 System 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"/>

</action>

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

8/15/2003 System Specialists Corporation

Struts Framework

• Components– JSP using Struts Tag– Controller setup in struts-config.xml– ActionForm– Action

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

8/15/2003 System Specialists Corporation

Struts Framework

• Easy to test

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

8/15/2003 System Specialists Corporation

Struts Framework

• Easy to test– StrutsTestCase– MockObjects– Cactus

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

8/15/2003 System Specialists Corporation

Struts Framework

• Much simpler than Sun’s Java Pet Store Demo

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

8/15/2003 System Specialists Corporation

BC4J Framework

• Entity Objects and Associations

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

8/15/2003 System Specialists Corporation

BC4J Framework

• Entity Objects and Associations– business rules– persistence details – express the relationships

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

8/15/2003 System 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.html

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

8/15/2003 System Specialists Corporation

BC4J Framework

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

8/15/2003 System Specialists Corporation

BC4J Framework

• View objects and links

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

8/15/2003 System Specialists Corporation

BC4J Framework

• View objects and links– Updateable data transfer objects – Based on SQL queries

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

8/15/2003 System Specialists Corporation

BC4J Framework

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

8/15/2003 System Specialists Corporation

BC4J Framework

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

8/15/2003 System Specialists Corporation

BC4J Framework

• Application Module– Transactional business services – “Business Delegate” J2EE Design Pattern

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

8/15/2003 System Specialists Corporation

BC4J Framework

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

8/15/2003 System Specialists Corporation

BC4J/Struts Integration

• BC4J complements the model layer of Struts

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

8/15/2003 System Specialists Corporation

BC4J/Struts Integration• automate interaction of Form Beans and BC4J's

objects

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

8/15/2003 System 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"/>

</action>

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

8/15/2003 System Specialists Corporation

BC4J/Struts Integration

• High-performance Business Delegate

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

8/15/2003 System Specialists Corporation

BC4J/Struts Integration

• High-performance Business Delegate– finds and pools business service components

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

8/15/2003 System Specialists Corporation

BC4J/Struts Integration

• High-performance Business Delegate– finds and pools business service components

am.findViewObject(“string-key-name”)

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

8/15/2003 System Specialists Corporation

BC4J/Struts Integration

• High-performance Business Delegate– finds and pools business service components

am.findViewObject(“string-key-name”)

:

am.createRecord(aRecord)

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

8/15/2003 System 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()

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

8/15/2003 System Specialists Corporation

BC4J/Struts Integration

• Customized Struts Request Processor

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

8/15/2003 System Specialists Corporation

BC4J/Struts Integration

• Customized Struts Request Processor

<controller debug="0" locale="true"

processorClass=

“com.ssc.kb.controller.KnowledgeBaseRequestProcessor"

contentType="text/html"

/>

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

8/15/2003 System Specialists Corporation

BC4J/Struts Integration

• Customized Struts Request Processor- processRoles- processActionForward- processActionForm

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

8/15/2003 System Specialists Corporation

How to

• Options#1 Create from scratch

#2 Migrate old MVC

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

8/15/2003 System 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/handson/Frameworks/bc4jhandson.html

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

8/15/2003 System Specialists Corporation

Option #1: Create from scratch

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

8/15/2003 System Specialists Corporation

Option #1: Create from scratch

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

8/15/2003 System Specialists Corporation

Option #2: Migrate old MVC

1. inherit from struts.Action

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

8/15/2003 System 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)

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

8/15/2003 System 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"/>

</action>

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

8/15/2003 System Specialists Corporation

Option #2: Migrate old MVC

3. configure to use struts.ActionServlet

web.xml:

<servlet-class>

org.apache.struts.action.ActionServlet

</servlet-class>

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

8/15/2003 System 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

:

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

8/15/2003 System Specialists Corporation

Installation/Configuration

1.1. web.xml – action servlet

<servlet-class>

org.apache.struts.action.ActionServlet

</servlet-class>

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

8/15/2003 System Specialists Corporation

Installation/Configuration

1.2. web.xml – Taglib<taglib> <taglib-uri>/webapp/DataTags.tld</taglib-uri> <taglib-location>/WEB-INF/lib/datatags.jar</taglib-

location></taglib><taglib> <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri> <taglib-location>/WEB-INF/struts-bean.tld</taglib-

location></taglib>

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

8/15/2003 System Specialists Corporation

Installation/Configuration2.1. JAR files - BC4J jars - under <OC4J_HOME>/BC4J/lib

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

8/15/2003 System Specialists Corporation

Installation/Configuration2.2. JAR files - Struts jar - under <webroot>/WEB-INF/lib

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

8/15/2003 System Specialists Corporation

Installation/Configuration

3.1. struts-config.xml

install under <webroot>/WEB-INF/lib

3.2. TagLib definition files - *tld

install under <webroot>/WEB-INF/lib

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

8/15/2003 System 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?

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

8/15/2003 System Specialists Corporation

Browse

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

8/15/2003 System Specialists Corporation

Edit Master/Display Detail

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

8/15/2003 System Specialists Corporation

Edit Detail

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

8/15/2003 System Specialists Corporation

JBO Tag

• Java Business Object tag

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

8/15/2003 System Specialists Corporation

JBO Tag

• Java Business Object tag

<%@ taglib uri="/webapp/DataTags.tld"

prefix="jbo" %>

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

8/15/2003 System Specialists Corporation

JBO Tag

• Java Business Object tag

<%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>

:<jbo:RowsetIterate …>

: <jbo:ShowValue dataitem=“KbDesc"/></td>

<jbo:ShowValue dataitem=“EntDate"/></td></jbo:RowsetIterate>

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

8/15/2003 System Specialists Corporation

Struts tag

<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix=“nested" %>

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

8/15/2003 System Specialists Corporation

Struts tag

<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix=“nested" %>

<nested:iterate property="details">

<nested:text property="entDate"/>

<nested:text property="details"/>

<nested:text property="ref"/>

</nested:iterate>

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

8/15/2003 System Specialists Corporation

JBO vs Struts tags

• JBO for RAD

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

8/15/2003 System Specialists Corporation

JBO vs Struts tags

• JBO for RAD• JBO integration with BC4J objects

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

8/15/2003 System Specialists Corporation

JBO vs Struts tags

• JBO for RAD• JBO integration with BC4J objects• JBO consistency

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

8/15/2003 System Specialists Corporation

JBO vs Struts tags

• Struts flexibility

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

8/15/2003 System Specialists Corporation

JBO vs Struts tags

• Struts flexibility• Struts richness

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

8/15/2003 System Specialists Corporation

JBO vs Struts tags

• Struts flexibility• Struts richness• Struts many contributors

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

8/15/2003 System Specialists Corporation

Where to use Struts tags

• Sophisticated browse with sort, display formats

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

8/15/2003 System Specialists Corporation

Where to use Struts tags

• Sophisticated browse with sort, display formats• Master/Detail CRUD

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

8/15/2003 System Specialists Corporation

Master/Detail

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

8/15/2003 System Specialists Corporation

Master/Detail

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

8/15/2003 System Specialists Corporation

Master/Detail

• BC4J– KnowledgeBase*– KnowledgeBaseDetail*– KnowledgeBaseDetailViewLink*– KnowledgeBaseAppModule

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

8/15/2003 System Specialists Corporation

Master/Detailpublic 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() {…}}

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

8/15/2003 System Specialists Corporation

Master/Detail

public class KnowledgeBaseDetail {String kbId;String entDate;String details;String ref;public void KnowledgeBaseDetail() {…}

:public String getEntDate() {…};

:public void setEntDate(…) {…};

}

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

8/15/2003 System Specialists Corporation

Master/Detailpublic 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"));else return (mapping.findForward(“failure"));

}}}

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

8/15/2003 System Specialists Corporation

Master/Detailpublic 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);}

}

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

8/15/2003 System Specialists Corporation

Master/Detailpublic 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); }

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

8/15/2003 System 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());

}

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

8/15/2003 System 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); }}

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

8/15/2003 System 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());

}

}

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

8/15/2003 System Specialists Corporation

Master/DetailStruts-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"/>

</action>

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

8/15/2003 System Specialists Corporation

Master/Detail - JSP<tr>

<th>Knowledge Base Id:</th><td><bean:write property="kbId"/></td>

</tr><tr>

<th>Description:</th><td><html:text property="description"/></td>

</tr><tr> <th>Date Reported:</th>

<td><html:text property="repDate"/></td></tr>

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

8/15/2003 System Specialists Corporation

Master/Detail – JSP cont’n<table>

<th align="center">Date</th> <th align="center">Details</th> <th align="center">Reference</th> <nested:iterate property="details">

<tr> <td><nested:text property="entDate"/></td>

<td><nested:text property="details"/></td> <td><nested:text property="ref"/></td></tr>

</nested:iterate><table>

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

8/15/2003 System Specialists Corporation

Master/Detail

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

8/15/2003 System Specialists Corporation

Summary

• BC4J and Struts – great combination

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

8/15/2003 System Specialists Corporation

Summary

• BC4J and Struts – great combination• RAD

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

8/15/2003 System Specialists Corporation

Summary

• BC4J and Struts – great combination• RAD• Consistent

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

8/15/2003 System Specialists Corporation

Summary

• BC4J and Struts – great combination• RAD• Consistent• Industry standard

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

8/15/2003 System Specialists Corporation

Summary

• BC4J and Struts – great combination• RAD• Consistent• Industry standard• Becoming widely used

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

8/15/2003 System Specialists Corporation

Summary

• BC4J and Struts – great combination• RAD• Consistent• Industry standard• Becoming widely used• Easy to learn

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

8/15/2003 System Specialists Corporation

Q & A

• Questions and Answers