OZ Framework Manual OZ Framework... 2 POST... 3 DataModule POST... 3 FXDataModule POST Custom... 5 Servlet API (for OZ Java Server)... 12 DataModuleFactory... 12 DataModule... 13 FXDataModule... 19... 26 Servlet API (for OZ.Net Server)... 27 FXDataModule... 27 Servlet API... 33 1 : Application -... 33 2 : Application - DataAction... 48 3 : Report -... 59 4 : XML SDM... 64 5 : FXDataModule... 76
OZ Framework User's Guide OZR, OZA OZ Framework OZR, OZA., (Fetch Unit). ODI 3 (fetchunit=dm_per_dataset), (fetchunit=dm_per_datamodule) ODI. URL ODI, POST URL. URL,, DataAction DataAction POST URL. DataAction "ok" "success". POST "POST ". OZ Framework ODI DB (UDS) FXDataModule. 2 FORCS Co., LTD
A Leader of Enterprise e-business Solution,, POST POST. Post ODI DataModule POST FXDataModule FXDataModule POST. DataModule POST POST _OZ_ODIFetchType OZ_ODIITEM OZ_ODICATEGORY OZ_DATASET OZ_DEBUG_ MyParam DM_BATCH_FETCH DM_CONCURRENT_FETCH FetchUnit DM_PER_DATASET DM_CONCURRENT_FETCH. ODI ODI FetchUnit DM_PER_DATASET. Debug (true / false) : XML SDM Debug. ODI ODI DataAction POST MyParam ODI ODI FORCS Co., LTD 3
OZ Framework User's Guide _OZ_DAC_CNT <INDEX>.DATASET <INDEX>.TYPE <INDEX>.EXT <INDEX>.SRC_CNT <INDEX>.SF_<INDEX2> <INDEX>.SV_<INDEX2> <INDEX>.TRG_CNT <INDEX>.DF_<INDEX2> <INDEX>.DV_<INDEX2> DataAction <INDEX> DataAction DataAction CUD Insert, Delete, RowUpdate DataAction Extra DataAction Source <INDEX2> DataAction <INDEX2> SourceName DataAction <INDEX2> SourceValue DataAction Target <INDEX2> DataAction <INDEX2> TargetName DataAction <INDEX2> TargetValue : 3 ODI, DataAction 3 Commit POST parama=somevalue paramb=somevalue paramc=somevalue _OZ_DAC_CNT=3 0.DATASET=dataset1 0.TYPE=Insert 0.EXT= 0.SRC_CNT=2 0.SF_0=FieldName1 0.SV_0=a 0.SF_1=FieldName2 0.SV_1=b 1.DATASET=dataset1 1.TYPE=Delete 1.EXT= 1.TRG_CNT=1 1.DF_0=FieldName1 1.DV_0=a 2.DATASET=dataset1 2.TYPE=RowUpdate 2.EXT= 2.SRC_CNT=2 2.SF_0=FieldName1 4 FORCS Co., LTD
A Leader of Enterprise e-business Solution 2.SV_0=newvalue 2.SF_1=FieldName2 2.SV_1=oldvalue 2.TRG_CNT=2 2.DF_0=FieldName1 2.DV_0=newvalue 2.DF_1=FieldName2 2.DV_1=oldvalue FXDataModule POST Custom DataAction POST _OZ_DAC_CNT_ <DAC_INDEX>.DATASET <DAC_INDEX>.TYPE <DAC_INDEX>.EXT <DAC_INDEX>.SRC_CNT <DAC_INDEX>.SF_<SRC_INDEX> <DAC_INDEX>.SFT_<SRC_INDEX> <DAC_INDEX>.SV_<SRC_INDEX> <DAC_INDEX>.TRG_CNT <DAC_INDEX>.DF_<TRG_INDEX> <DAC_INDEX>.DFT_<TRG_INDEX> <DAC_INDEX>.DV_<TRG_INDEX> DataAction DataAction (Insert, RowUpdate, Delete) DataAction ext DataAction Source DataAction Source DataAction Source DataAction Source ( null ) DataAction Target DataAction Target DataAction Target DataAction Target ( null ) - Type Object Const FORCS Co., LTD 5
OZ Framework User's Guide FX_DT_BIT Boolean -7 "BIT" FX_DT_TINYINT Integer -6 "TINYINT" FX_DT_SMALLINT Integer 5 "SMALLINT" FX_DT_INTEGER Integer 4 "INTEGER" FX_DT_BIGINT Long -5 "BIGINT" FX_DT_FLOAT Double 6 "FLOAT" FX_DT_REAL Float 7 "REAL" FX_DT_DOUBLE Double 8 "DOUBLE" FX_DT_NUMERIC String 2 "NUMERIC" FX_DT_DECIMAL String 3 "DECIMAL" FX_DT_CHAR String 1 "CHAR" FX_DT_VARCHAR String 12 "VARCHAR" FX_DT_LONGVARCHAR String -1 "LONGVARCHAR" FX_DT_DATE Date 91 "DATE" FX_DT_TIME Time 92 "TIME" FX_DT_TIMESTAMP Timestamp 93 "TIMESTAMP" FX_DT_BINARY byte[] -2 "BINARY" FX_DT_VARBINARY byte[] -3 "VARBINARY" FX_DT_LONGVARBINARY byte[] -4 "LONGBINARY" FX_DT_BLOB byte[] 2004 "BLOB" FX_DT_CLOB byte[] 2005 "CLUB" : BINARY, VARBINARY, LONGVARBINARY, BLOB, CLOB BASE64. (enum FX_DataTypes) - Type Object BIT TINYINT SMALLINT INTEGER BIGINT FLOAT Boolean Integer Integer Integer Long Double 6 FORCS Co., LTD
A Leader of Enterprise e-business Solution REAL DOUBLE NUMERIC DECIMAL CHAR VARCHAR LONGVARCHAR DATE TIME TIMESTAMP BINARY VARBINARY LONGVARBINARY BLOB CLOB Float Double String String String String String Date Time Timestamp byte[] byte[] byte[] byte[] byte[] : BINARY, VARBINARY, LONGVARBINARY, BLOB, CLOB BASE64. Custom DataModule ( ) Child Parameter, DataSetMeta, DataSet DataModule ( ) Attribute runat "server" Child Parameter, DataSetMeta, DataSet Parameter Attribute name fieldtype FORCS Co., LTD 7
OZ Framework User's Guide Text DataSetMeta Attribute Child name mastersetname DataFieldMeta DataFieldMeta Attribute fieldname fieldtype DataSet Attribute name Child Record Record Child Column, DataSet Column Attribute Name Text Send Attribute Child iscompress issdm Error (gzip) (true : SDM, false : XML) 8 FORCS Co., LTD
A Leader of Enterprise e-business Solution Error Text Servlet 2.3. DataAction. DataModule runat="server". Custom JSP WAS web.xml Custom. location ozsdmtag.tld. web.xml.... <!-- JSPC servlet mappings start -->... <taglib> <taglib-uri>http://www.forcs.com/oz/fxsdmapi/taglib</taglib-uri> <taglib-location>/web-inf/ozsdmtag.tld</taglib-location> </taglib>... <servlet-mapping> FORCS Co., LTD 9
OZ Framework User's Guide <servlet-name>sample.test </servlet-name> <url-pattern>/test </url-pattern> </servlet-mapping>... <!-- JSPC servlet mappings end --> jsp HTML. URL web.xml URL. <%@ taglib uri="http://www.forcs.com/oz/fxsdmapi/taglib" prefix="oz" %> ASP.NET OZSDMAPI aspx HTML. <%@ Register TagPrefix="oz" Namespace="oz.fxapi.custom.tag" Assembly="OZSDMAPI" %>. <oz:datamodule runat="server"> <oz:datasetmeta name="ids" > <oz:datafieldmeta fieldname="carid" fieldtype="varchar" /> </oz:datasetmeta> <oz:datasetmeta name="informations" mastersetname="ids" > <oz:datafieldmeta fieldname="maker" fieldtype="varchar" /> <oz:datafieldmeta fieldname="carname" fieldtype="clob" /> <oz:datafieldmeta fieldname="ecarname" fieldtype="varchar" /> </oz:datasetmeta> <oz:parameter name="param1" fieldtype="integer">35</oz:parameter> <oz:dataset name="ids"> <oz:record> <oz:column name="carid" >08</oz:Column> <oz:dataset name="informations" > <oz:record> <oz:column name="maker" >HYUNDAI</oz:Column> <oz:column name="carname" >EF</oz:Column> <oz:column name="ecarname" >EFSONATA</oz:Column> </oz:record> </oz:dataset> </oz:record> <oz:record> <oz:column name="carid" >05</oz:Column> <oz:dataset name="informations" > 10 FORCS Co., LTD
A Leader of Enterprise e-business Solution <oz:record> <oz:column name="maker" >HYUNDAI</oz:Column> <oz:column name="carname" ></oz:column> <oz:column name="ecarname" >DYNASTY</oz:Column> </oz:record> </oz:dataset> </oz:record> <oz:record> <oz:column name="carid" >07</oz:Column> <oz:dataset name="informations" > <oz:record> <oz:column name="maker" >HYUNDAI</oz:Column> <oz:column name="carname" ></oz:column> <oz:column name="ecarname" >GRANDEUR</oz:Column> </oz:record> </oz:dataset> </oz:record> <oz:record> <oz:column name="carid" >04</oz:Column> <oz:dataset name="informations" > <oz:record> <oz:column name="maker" >HYUNDAI</oz:Column> <oz:column name="carname" ></oz:column> <oz:column name="ecarname" >EQUUS</oz:Column> </oz:record> </oz:dataset> </oz:record> <oz:record> <oz:column name="carid" >09</oz:Column> <oz:dataset name="informations" > <oz:record> <oz:column name="maker" >HYUNDAI</oz:Column> <oz:column name="carname" ></oz:column> <oz:column name="ecarname" >VERNA</oz:Column> </oz:record> </oz:dataset> </oz:record> </oz:dataset> <oz:send iscompressed="false" issdm="true"> <oz:error>not implemented</oz:error> </oz:send> </oz:datamodule> FORCS Co., LTD 11
OZ Framework User's Guide DataModuleFactory DataModuleFactory - getdatamodule public static DataModule getdatamodule(string FetchType) throws OZSDMException. "DM_CONCURRENT_FETCH" getdatamodule CONCURRENT. Argument FetchType DM_CONCURRENT_FETCH / DM_BATCH_FETCH / DM_PER_DATASET :,. OZ Framework. DM_CONCURRENT_FETCH :. DM_BATCH_FETCH :. DM_PER_DATASET :.,. 12 FORCS Co., LTD
A Leader of Enterprise e-business Solution DataModule DataModule - init public void init(outputstream out) throws IOException Stream. Argument out Response OutputStream - startbinding public void startbinding() throws IOException, SQLException.. - endbinding public void endbinding() throws IOException, SQLException.. - startset public void startset(string DatasetName) throws IOException.. Argument DatasetName - endset public void endset(string DatasetName) throws IOException. Argument DatasetName - addparameter public void addparameter(string ParamName, int FieldType, Object Value) FORCS Co., LTD 13
OZ Framework User's Guide. :., getdatamodule() DM_CONCURRENT_FETCH DM_BATCH_FETCH. Argument ParamName FieldType Value - addsetinfo public void addsetinfo(string DatasetName, String MasterDatasetName, String[] FieldNames, int[] FieldTypes) throws IllegalArgumentException., DM_CONCURRENT_FETCH DM_BATCH_FETCH. DatasetName Argument MasterDatasetName FieldNames FieldTypes, "" - addsetinfo public void addsetinfo(string DatasetName, String[] FieldNames, int[] FieldTypes) throws IllegalArgumentException., DM_PER_DATASET. Argument DatasetName FieldNames FieldTypes - addrow public void addrow(string DatasetName, HashMap hmap) throws IOException, SQLException 14 FORCS Co., LTD
A Leader of Enterprise e-business Solution ResultSet Row. DatasetName Argument hmap HashMap Row )... rs = stmt.executequery(query); while(rs.next()) HashMap hmap = new HashMap(); hmap.put(_fn[0], rs.getstring(_fn[0])); hmap.put(_fn[1], rs.getstring(_fn[1])); hmap.put(_fn[2], rs.getstring(_fn[2])); hmap.put(_fn[3], rs.getstring(_fn[3])); hmap.put(_fn[4], rs.getstring(_fn[4])); hmap.put(_fn[5], rs.getstring(_fn[5])); module.addrow("set_1", hmap);... - addrow public void addrow(string DatasetName, List list) throws IOException, SQLException ResultSet Row. Argument DatasetName list ArrayList Row - addrow public void addrow(string DatasetName, String[] arr) throws IOException, SQLException ResultSet Row. Argument DatasetName arr String[] Row - makesdm_set FORCS Co., LTD 15
OZ Framework User's Guide public void makesdm_set(string DatasetName, ResultSet rs, OutputStream out) throws OZSDMException, IOException DM_PER_DATASET SDM., Batch. DatasetName Argument rs out ResultSet Response OutputStream - ParseXML public string ParseXML(XMLID) XML SDM. Argument XMLID XML ID Return Success - sendbinderrormessage public void sendbinderrormessage(string msg) throws IOException. :. Argument msg - senderrormessage public void senderrormessage(string msg, OutputStream out) throws IOException. :. Argument msg out Response OutputStream - setdebug 16 FORCS Co., LTD
A Leader of Enterprise e-business Solution public void setdebug(boolean isdebug, HttpServletResponse response) throws IOException Debug. : XML SDM Debug. : init,. "setdebug method can't call after init method calling and call only one time". Argument isdebug response Debug - true : Debug - false : Debug () Servlet API - ODI getdatamodule(); init(); addparameter(); addsetinfo(); startbinding(); startset(); * addrow(); endset(); endbinding(); :. - - FORCS Co., LTD 17
OZ Framework User's Guide ODI getdatamodule(); init(); addparameter(); addsetinfo(); startbinding(); startset(); * addrow(); * startset(); * * addrow(); * endset(); endset(); endbinding(); :,. - getdatamodule(); init(); addsetinfo(); startbinding(); startset(); * addrow(); endset(); 18 FORCS Co., LTD
A Leader of Enterprise e-business Solution endbinding(); :. FXDataModule FX_DataModule - FX_DataModule Argument public FX_DataModule() FXDataModule. addparameter public void addparameter(fx_parameter param). Argument Param addparameters public void addparameters(fx_parameter[] param). Argument Params adddatasetmeta public void adddatasetmeta(fx_datasetmeta meta). Argument Meta write public void write(outputstream out, booleam issdm, boolen iscompress) FORCS Co., LTD 19
OZ Framework User's Guide DataModule SDM XML. : XML Response ContentType. (Ex : "text/xml") out OutStream Argument issdm iscompress SDM (false XML ) : true GZip Unzip. Return senderrormessage public void senderrormessage(outputstream out, booleam issdm, boolen iscompress, String error) DataModule SDM XML,. Argument out issdm iscompress error OutStream SDM (false XML ) : true GZip Unzip. Return getdataaction public FX_DataAction getdataaction(httpservletrequest request) Request FX_DataAction. Argument request error Request Return DataAction FX_DataSetMeta FX_ DataSetMeta 20 FORCS Co., LTD
A Leader of Enterprise e-business Solution public FX_DataSetMeta(String name) FXDataModule. Argument name FX_DataSetMeta public FX_DataSetMeta(String name, String msetname) FXDataModule. Argument name msetname setmastersetname public void setmastersetname(string msetname). Argument msetname adddatafieldmeta public void adddatafieldmeta(fx_datafieldmeta field). Argument field adddatafieldmeta public void adddatafieldmeta(fx_datafieldmeta[] fields). Argument fields FX_DataFieldMeta FX_DataFieldMeta public FX_DataFieldMeta(String name, int type). Argument name type FX_ DataFieldMeta FORCS Co., LTD 21
OZ Framework User's Guide public FX_DataFieldMeta(String name) VARCHAR. Argument name settype public void settype(int type). Argument type FX_DataSet FX_DataSet public FX_DataSet(String name) FXDataModule. Argument name addrecord public void addrecord(fx_record record),. Argument record FX_Record FX_Record public FX_Record(),. addcolumn public void addcolumn(string name, Object value). Argument name value adddetaildataset 22 FORCS Co., LTD
A Leader of Enterprise e-business Solution public void adddetaildataset(fx_dataset detail). Argument detail FX_DataAction FX_DataAction public FX_DataAction(String name, String actiontype) DataAcion. Argument name actiontype DataAction FX_DataAction public FX_DataAction(String name, String actiontype, String ext) DataAcion. Argument name actiontype ext DataAction ext getdatasetname Return public String getdatasetname(). getactiontype Return public String getactiontype() DataAction. DataAction (Insert, RowUpdate, Delete) getext Return public String getext() ext. ext FORCS Co., LTD 23
OZ Framework User's Guide setext public String setext(string ext) ext. Argument ext ext getsourcefields Return public FX_Parameter[] getsourcefields() Source. Source setsourcefields public void setsourcefields(fx_parameter[] fields) Source. Argument fields Source gettargetfields Return public FX_Parameter[] gettargetfields() Target. Target settargetfields public void settargetfields(fx_parameter[] fields) Target. Argument fields Target FX_Parameter FX_Parameter public FX_Parameter(String name, int type, String value) FXDataModule. Argument name type value 24 FORCS Co., LTD
A Leader of Enterprise e-business Solution FX_Parameter public FX_Parameter(String name, String value) FXDataModule VARCHAR. Argument name value getname Return public String getname(). gettype Return public int gettype(). settype public void settype(int type). type getvalue Return public String gettype(). isnull Return public boolean isnull() null. null FORCS Co., LTD 25
OZ Framework User's Guide GetWebBrowserWindow Argument object _GetWebBrowserWindow() OCX. : viewer.isframe=false viewer.isframe=true null. 26 FORCS Co., LTD
A Leader of Enterprise e-business Solution : Servlet API Framework 1.1.4322. FXDataModule FX_DataModule FX_DataModule Argument public FX_DataModule() FXDataModule. addparameter public void addparameter(fx_parameter param). Argument Param addparameters public void addparameters(fx_parameter[] param). Argument Params adddatasetmeta Public void adddatasetmeta(fx_datasetmeta meta). Argument Meta write public void write(outputstream output, booleam issdm, boolen iscompress) FORCS Co., LTD 27
OZ Framework User's Guide Argument Return DataModule SDM XML. : XML Response ContentType. (Ex : "text/xml") output OutStream issdm SDM (false XML ) iscompress : true GZip Unzip. senderrormessage public void senderrormessage(outputstream output, booleam issdm, boolen iscompress, string error) DataModule SDM XML,. Argument output issdm iscompress error OutStream SDM (false XML ) : true GZip Unzip. Return getdataaction public FX_DataAction getdataaction(httpservletrequest request) Request FX_DataAction. Argument request error Request Return DataAction FX_DataSetMeta FX_ DataSetMeta public FX_DataSetMeta(String name) 28 FORCS Co., LTD
A Leader of Enterprise e-business Solution FXDataModule. Argument name FX_DataSetMeta public FX_DataSetMeta(String name, String msetname) FXDataModule. Argument name msetname MasterSetName public string MasterSetNameget; set;. adddatafieldmeta public void adddatafieldmeta(fx_datafieldmeta[] field). Argument field FX_DataFieldMeta FX_DataFieldMeta public FX_DataFieldMeta(string name, int type) Argument name type FX_ DataFieldMeta public FX_DataFieldMeta(String name) VARCHAR. Argument name Type public FX_DataTypes Typeget; set;. FORCS Co., LTD 29
OZ Framework User's Guide FX_DataSet FX_DataSet public FX_DataSet(string name) FXDataModule Argument name addrecord public void AddRecord(FX_Record record),. Argument record FX_Record FX_Record public FX_REcord(),. addcolumn public void addcolumn(string name, Object value). Argument name value adddetaildataset public void adddetaildataset(fx_dataset detail). Argument detail FX_DataAction FX_DataAction public FX_DataAction(string name, string actiontype) DataAcion. Argument name 30 FORCS Co., LTD
A Leader of Enterprise e-business Solution actiontype DataAction FX_DataAction public FX_DataAction(string name, string actiontype, string ext) DataAcion. Argument name actiontype ext DataAction ext DataSetName public string DataSetNameget;. ActionType public string ActionTypeget; DataAction. (Insert, RowUpdate, Delete) ExtraArgument public string ExtraArgumentget; set; ext. SourceFields public FX_Parameter[] SourceFieldsget; set; Source. TargetFields public FX_Parameter[] TargetFieldsget; set; Target. FX_Parameter FX_Parameter public FX_Parameter(string name, int type, string value) FORCS Co., LTD 31
OZ Framework User's Guide FXDataModule. Argument name type value FX_Parameter public FX_Parameter(string name, string value) FXDataModule VARCHAR. Argument name value Name public string Nameget;. Type public FX_DataTypes Typeget; set;. value public string valueget;. IsNull public string gettypeget; set; null. 32 FORCS Co., LTD
A Leader of Enterprise e-business Solution 1 : Application - Servlet API Table. Servlet API ozsdmapi.jar WAS UDS ODI. Step 1 ozsdmapi.jar WAS Servlet API ozsdmapi.jar WAS. Tomcat 5.0 webapps\root\web-inf\lib ozsdmapi.jar. Step 2. java DataModuleSampleServlet.class. package sample; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import java.util.*; import oz.framework.api.datamodule; import oz.uds.rs.listmapresultset; import oz.sdm.datamodulefactory; import oz.uds.rs.listmapresultset; /** * <p>title: OZ SDM API</p> * <p>description: </p> * <p>copyright: Copyright (c) 2005</p> * <p>company: </p> * @author Forcs * @version 1.0 */ public class DataModuleSampleServlet extends HttpServlet FORCS Co., LTD 33
OZ Framework User's Guide private static final String _KEY_ODI_FETCH_TYPE = "_OZ_ODIFetchType_"; private static final String _KEY_ODIITEM = "_OZ_ODIITEM_"; private static final String _KEY_ODICATEGORY = "_OZ_ODICATEGORY_"; private static final String _KEY_OZ_DATASET_ = "_OZ_DATASET_"; private Connection m_conn = null; public void init(servletconfig config) throws ServletException super.init(config); System.out.println("init..."); public void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException process(request, response); public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException process(request, response); private void process(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException // init connection. try String _URL = "jdbc:odbc:ozdemokr30"; Properties prop = new Properties(); prop.put("user", ""); prop.put("password", ""); Driver driver = (Driver) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); m_conn = driver.connect(_url, prop); System.out.println("connection ok..."); catch(exception e) System.out.println("connection error..."); DataModule.sendErrorMessage("connection error...",response.getoutputstream()); if (m_conn!= null) try m_conn.close(); catch (Exception e1) throw new ServletException(e.getMessage()); try System.out.println("start--------------------"); Enumeration enum = request.getparameternames(); while (enum.hasmoreelements()) String temp = (String) enum.nextelement(); System.out.println("name=" + temp + " value=" + getencode(request.getparameter(temp))); 34 FORCS Co., LTD
A Leader of Enterprise e-business Solution // --------------------------------------------------------------------- // fetch parameters // "DM_BATCH_FETCH DM_CONCURRENT_FETCH" String odifetchtype = getencode(request.getparameter(_key_odi_fetch_type)); String item = getencode(request.getparameter(_key_odiitem)); String category = getencode(request.getparameter(_key_odicategory)); String dataset = getencode(request.getparameter(_key_oz_dataset_)); // --------------------------------------------------------------------- if (odifetchtype == null) odifetchtype = "DM_CONCURRENT_FETCH"; if ( (dataset == null) (dataset.length() == 0)) // ODI FetchUnit DM_PER_DATAMODULE. if (item.equals("jasmin_sample3.odi")) // Master-Detail Sample. Master_Detail_Style(request, response, odifetchtype); else if (item.equals("jasmin_sample2.odi") (item.equals("jasmin_sample4.odi"))) // SET Sample. default_style(request, response, odifetchtype); else System.out.println("unsupported odi error..."); DataModule.sendErrorMessage("unsupported odi error...", response.getoutputstream()); throw new ServletException("Unknown Item :" + item); else // ODI FetchUnit DM_PER_DATASET. // odifetchtype DM_PER_DATASET DM_CONCURRENT_FETCH. //. (batch.) if (odifetchtype.equalsignorecase("dm_concurrent_fetch")) // set #1 setdefaultstyle(request, response, "DM_PER_DATASET"); // set #2 // setresultsetquerystyle(request, response, "DM_CONCURRENT_FETCH"); else System.out.println("unsupported error..."); DataModule.sendErrorMessage("unsupported error...", response.getoutputstream()); throw new ServletException("unsupported"); catch(exception ex) ex.printstacktrace(); // senderrormessage // throw. client DataModule.sendErrorMessage(ex.getMessage(), response.getoutputstream()); throw new ServletException(ex.getMessage()); finally if (m_conn!= null) try m_conn.close(); catch (Exception e) FORCS Co., LTD 35
OZ Framework User's Guide System.out.println("end--------------------"); private void Master_Detail_Style(HttpServletRequest request, HttpServletResponse response, String fetchtype) throws ServletException, IOException Statement stmt1 = null; Statement stmt4 = null; ResultSet rs1 = null; ResultSet rs4 = null; DataModule module = null; // jasmin/jasmin_sample1.odi // SET_1 String[] _FN1 = "FirstName" ; int[] _FT1 = java.sql.types.varchar ; // SET_4 String[] _FN4 = "ContactId", "FirstName", "LastName", "Phone", "Fax", "Email", "OrgUnitId", "UserName" ; int[] _FT4 = 4, 12, 12, 12, 12, 12, 5, 12 ; try module = DataModuleFactory.getDataModule(fetchType); module.init(response.getoutputstream()); // set SET Info. module.addsetinfo("set_1", "", _FN1, _FT1); module.addsetinfo("set_4", "SET_1", _FN4, _FT4); catch(exception ex) throw new ServletException(ex.getMessage()); try module.startbinding(); String query1 = "select distinct FirstName from contact"; module.startset("set_1"); stmt1 = m_conn.createstatement(); rs1 = stmt1.executequery(query1); while(rs1.next()) String f1 = rs1.getstring(_fn1[0]); HashMap map1 = new HashMap(); map1.put(_fn1[0], f1); module.addrow("set_1", map1); contactid"; String query4 = "select * from contact where FirstName='" + f1 + "' order by module.startset("set_4"); stmt4 = m_conn.createstatement(); rs4 = stmt4.executequery(query4); while(rs4.next()) HashMap map4 = new HashMap(); map4.put(_fn4[0], new Integer(rs4.getInt(_FN4[0]))); map4.put(_fn4[1], rs4.getstring(_fn4[1])); map4.put(_fn4[2], rs4.getstring(_fn4[2])); map4.put(_fn4[3], rs4.getstring(_fn4[3])); map4.put(_fn4[4], rs4.getstring(_fn4[4])); 36 FORCS Co., LTD
A Leader of Enterprise e-business Solution map4.put(_fn4[5], rs4.getstring(_fn4[5])); map4.put(_fn4[6], new Integer(rs4.getInt(_FN4[6]))); map4.put(_fn4[7], rs4.getstring(_fn4[7])); module.addrow("set_4", map4); rs4.close(); rs4 = null; stmt4.close(); stmt4 = null; module.endset("set_4"); rs1.close(); rs1 = null; stmt1.close(); stmt1 = null; module.endset("set_1"); module.endbinding(); catch(exception e) e.printstacktrace(); // sendbinderrormessage. if(module!= null) module.sendbinderrormessage(e.tostring()); finally if(rs1!= null) try rs1.close(); catch(exception e) if(stmt1!= null) try stmt1.close(); catch(exception e) if(rs4!= null) try rs4.close(); catch(exception e) if(stmt4!= null) try stmt4.close(); catch(exception e) private void default_style(httpservletrequest request, HttpServletResponse response, String fetchtype) throws ServletException, IOException System.out.println("select time=="+system.currenttimemillis()); Statement stmt = null; ResultSet rs = null; DataModule module = null; // jasmin/jasmin_sample2.odi // SET_1 String[] _FN = "CarID", "Maker", "EMaker", "CarName", "ECarName", "CarImageFile"; int[] _FT = java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar ; try module = DataModuleFactory.getDataModule(fetchType); FORCS Co., LTD 37
OZ Framework User's Guide module.init(response.getoutputstream()); // module.init(output); // set Parameter Info. module.addparameter("param1", java.sql.types.varchar, getencode(request.getparameter("param1"))); module.addparameter("param2", java.sql.types.varchar, getencode(request.getparameter("param2"))); // set SET Info. module.addsetinfo("set_1", "", _FN, _FT); catch(exception ex) throw new ServletException(ex.getMessage()); try module.startbinding(); String query = "select * from car"; module.startset("set_1"); stmt = m_conn.createstatement(); rs = stmt.executequery(query); while(rs.next()) HashMap map = new HashMap(); String a = rs.getstring(_fn[0]); String b = rs.getstring(_fn[1]); String c = rs.getstring(_fn[2]); String d = rs.getstring(_fn[3]); String e = rs.getstring(_fn[4]); String f = rs.getstring(_fn[5]); map.put(_fn[0], a); map.put(_fn[1], b); map.put(_fn[2], c); map.put(_fn[3], d); map.put(_fn[4], e); map.put(_fn[5], f); module.addrow("set_1", map); System.out.print("select FN0="+_FN[0]+" name="+a); System.out.print(" FN1="+_FN[1]+" name="+b); System.out.print(" FN2="+_FN[2]+" name="+c); System.out.print(" FN3="+_FN[3]+" name="+d); System.out.print(" FN4="+_FN[4]+" name="+e); System.out.print(" FN5="+_FN[5]+" name="+f); System.out.println(""); module.endset("set_1"); module.endbinding(); rs.close(); rs = null; stmt.close(); stmt = null; catch(exception e) e.printstacktrace(); // sendbinderrormessage. module.sendbinderrormessage(e.tostring()); finally OutputStream out = response.getoutputstream(); 38 FORCS Co., LTD
A Leader of Enterprise e-business Solution if(rs!= null) try rs.close(); catch(exception e) if(stmt!= null) try stmt.close(); catch(exception e) private void setdefaultstyle(httpservletrequest request, HttpServletResponse response, String fetchtype) throws ServletException, IOException System.out.println("setDefaultStyle fetchtype =="+fetchtype); Statement stmt = null; ResultSet rs = null; DataModule module = null; // jasmin/jasmin_sample4.odi // SET_1 String[] _FN = "CarID", "Maker", "EMaker", "CarName", "ECarName", "CarImageFile"; int[] _FT = java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar ; try module = DataModuleFactory.getDataModule(fetchType); module.init(response.getoutputstream()); // set SET Info. module.addsetinfo("set_1", _FN, _FT); catch(exception ex) throw new ServletException(ex.getMessage()); try module.startbinding(); String query = "select * from car"; module.startset("set_1"); stmt = m_conn.createstatement(); rs = stmt.executequery(query); while(rs.next()) HashMap map = new HashMap(); String a = rs.getstring(_fn[0]); String b = rs.getstring(_fn[1]); String c = rs.getstring(_fn[2]); String d = rs.getstring(_fn[3]); String e = rs.getstring(_fn[4]); String f = rs.getstring(_fn[5]); map.put(_fn[0], a); map.put(_fn[1], b); map.put(_fn[2], c); map.put(_fn[3], d); map.put(_fn[4], e); map.put(_fn[5], f); FORCS Co., LTD 39
OZ Framework User's Guide module.addrow("set_1", map); System.out.print("select FN0="+_FN[0]+" name="+a); System.out.print(" FN1="+_FN[1]+" name="+b); System.out.print(" FN2="+_FN[2]+" name="+c); System.out.print(" FN3="+_FN[3]+" name="+d); System.out.print(" FN4="+_FN[4]+" name="+e); System.out.print(" FN5="+_FN[5]+" name="+f); System.out.println(""); module.endset("set_1"); module.endbinding(); rs.close(); rs = null; stmt.close(); stmt = null; catch(exception e) e.printstacktrace(); // sendbinderrormessage. module.sendbinderrormessage(e.tostring()); finally OutputStream out = response.getoutputstream(); if(rs!= null) try rs.close(); catch(exception e) if(stmt!= null) try stmt.close(); catch(exception e) private void setresultsetquerystyle(httpservletrequest request, HttpServletResponse response, String fetchtype) throws ServletException, IOException System.out.println("setResultSetQueryStyle..."); Statement stmt = null; ResultSet rs = null; DataModule module = null; try // jasmin/jasmin_sample4.odi // SET_1 String[] _FN = "CarID", "Maker", "EMaker", "CarName", "ECarName", "CarImageFile" ; int[] _FT = java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar,java.sql.types.varchar; module = DataModuleFactory.getDataModule(fetchType); String query = "select * from car"; stmt = m_conn.createstatement(); rs = stmt.executequery(query); module.makesdm_set("set_1",rs,response.getoutputstream()); rs.close(); rs = null; stmt.close(); stmt = null; 40 FORCS Co., LTD
A Leader of Enterprise e-business Solution catch(exception e) e.printstacktrace(); // set sendbinderrormessage. // makesdm_set. throw new ServletException(e.getMessage()); finally if(rs!= null) try rs.close(); catch(exception e) if(stmt!= null) try stmt.close(); catch(exception e) public void destroy() super.destroy(); private String getencode(string value) try return new String(value.getBytes("8859_1"), "KSC5601"); catch(exception ex) return value; Step 3 DataModuleSampleServlet.class WAS. DataModuleSampleServlet.class. Tomcat 5.0 webapps\root\web-inf\classes sample. DataModuleSampleServlet.class WAS. Tomcat 5.0 webapps\root\web-inf web.xml.... <!-- JSPC servlet mappings start -->... <servlet> <servlet-name>sample.datamodulesampleservlet</servlet-name> <servlet-class>sample.datamodulesampleservlet</servlet-class> </servlet> FORCS Co., LTD 41
OZ Framework User's Guide... <servlet-mapping> <servlet-name>sample.datamodulesampleservlet</servlet-name> <url-pattern>/sample.datamodulesampleservlet</url-pattern> </servlet-mapping>... <!-- JSPC servlet mappings end --> Step 4 ODI Servlet API (UDS),. POST "_OZ_ODIITEM_".. (UDS).. 42 FORCS Co., LTD
A Leader of Enterprise e-business Solution. [ ]. [].. FORCS Co., LTD 43
OZ Framework User's Guide. ( ). URL []. 44 FORCS Co., LTD
A Leader of Enterprise e-business Solution "_OZ_ODIITEM_=ODI" [].. ODI "JASMIN_SAMPLE2.odi". Step 5 OZF : Servlet API URL DataModule RegisterUserDataModule JavaScript. JavaScript, Document.GlobalFunction OZF OZF. OZF. OZF "MyFrameworkURLUDS.ozf". MyFrameworkURLUDS.prototype.GetFrameworkURL = MyFrameworkURLUDS_GetFrameworkURL; MyFrameworkURLUDS.prototype.GetCUDFrameworkURL = FORCS Co., LTD 45
OZ Framework User's Guide MyFrameworkURLUDS_GetCUDFrameworkURL; MyFrameworkURLUDS.prototype.GetFrameworkPostParam = MyFrameworkURLUDS_GetFrameworkPostParam; MyFrameworkURLUDS.prototype.GetCUDFrameworkPostParam = MyFrameworkURLUDS_GetCUDFrameworkPostParam; function MyFrameworkURLUDS(_url, _cud_url, _url_param, _cud_url_param) this.url = _url; this.cud_url = _cud_url; this.url_param = _url_param; if(this.url_param == null) this.url_param = ""; this.cud_url_param = _cud_url_param; if(this.cud_url_param == null) this.cud_url_param = ""; function MyFrameworkURLUDS_GetFrameworkURL(dataset_name) return this.url; function MyFrameworkURLUDS_GetCUDFrameworkURL(dataset_name) return this.cud_url; function MyFrameworkURLUDS_GetFrameworkPostParam(dataset_name) return "default&"+this.url_param; function MyFrameworkURLUDS_GetCUDFrameworkPostParam(dataset_name) return "default&"+this.cud_url_param; GetFrameworkURL GetCUDFrameworkURL. GetFrameworkURL URL. GetCUDFrameworkURL DataAction URL. URL 46 FORCS Co., LTD
A Leader of Enterprise e-business Solution, URL. "JASMIN_SAMPLE2.odi" "MyFrameworkURLUDS.ozf". Board Table Table ODIKey "JASMIN_SAMPLE2", DataSet "SET_1",. Table OnInitialize. var uds = new MyFrameworkURLUDS("http://127.0.0.1:8088/sample.DataModuleSampleServlet","http://127.0.0.1:8088/sample.DataModuleSampleServlet"); var datamanager = _GetDataManager(); var datamodule = datamanager.getdatamodule("jasmin_sample2"); datamodule.registeruserdatamodule(uds); Step 6 WAS. FORCS Co., LTD 47
OZ Framework User's Guide 2 : Application - DataAction Servlet API Table,,. Step 1 ozsdmapi.jar WAS Servlet API ozsdmapi.jar WAS. Tomcat 5.0 webapps\root\web-inf\lib ozsdmapi.jar. Step 2 DataAction DataAction. java DataActionSampleServlet.class. package sample; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import java.util.*; /** * <p>title: OZ SDM API</p> 48 FORCS Co., LTD
A Leader of Enterprise e-business Solution * <p>description: </p> * <p>copyright: Copyright (c) 2005</p> * <p>company: </p> * @author Forcs * @version 1.0 */ public class DataActionSampleServlet extends HttpServlet private static final String _KEY_ODI_FETCH_TYPE = "_OZ_ODIFetchType_"; private static final String _KEY_ODIITEM = "_OZ_ODIITEM_"; private static final String _KEY_ODICATEGORY = "_OZ_ODICATEGORY_"; private static final String _KEY_OZ_DATASET_ = "_OZ_DATASET_"; private static final String _KEY_OZ_DAC_CNT = "_OZ_DAC_CNT"; private static String TABLENAME = "car"; private String dac_insert_query = ""; private String dac_update_query = ""; private String dac_delete_query = ""; private PreparedStatement p_insert_stmt = null; private PreparedStatement p_update_stmt = null; private PreparedStatement p_delete_stmt = null; private Connection m_conn = null; public void init(servletconfig config) throws ServletException super.init(config); public void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException process(request, response); public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException process(request, response); private void process(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException try String _URL = "jdbc:odbc:ozdemokr30"; Properties prop = new Properties(); prop.put("user", ""); prop.put("password", ""); Driver driver = (Driver) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); m_conn = driver.connect(_url, prop); catch(exception ex) response.getoutputstream().write(ex.getmessage().getbytes()); throw new ServletException(ex.getMessage()); FORCS Co., LTD 49
OZ Framework User's Guide try dac_insert_query = ""; dac_update_query = ""; dac_delete_query = ""; Enumeration enum = request.getparameternames(); while (enum.hasmoreelements()) String temp = (String) enum.nextelement(); System.out.println("name=" + temp + " value=" + getencode(request.getparameter(temp))); // --------------------------------------------------------------------- // fetch parameters // "DM_BATCH_FETCH DM_CONCURRENT_FETCH" String odifetchtype = getencode(request.getparameter( _KEY_ODI_FETCH_TYPE)); String item = getencode(request.getparameter(_key_odiitem)); String category = getencode(request.getparameter(_key_odicategory)); String dataset = getencode(request.getparameter(_key_oz_dataset_)); // --------------------------------------------------------------------- System.out.println("--------------------"); if (odifetchtype == null) odifetchtype = "DM_CONCURRENT_FETCH"; m_conn.setautocommit(false); //Action. int dac_cnt = Integer.parseInt(request.getParameter(_KEY_OZ_DAC_CNT)); for (int i = 0; i < dac_cnt; i++) String type = request.getparameter(i + ".TYPE"); if (type.equalsignorecase("insert")) insert(request, response, i); else if (type.equalsignorecase("rowupdate")) update(request, response, i); else if (type.equalsignorecase("delete")) delete(request, response, i); System.out.println(type+" time=="+system.currenttimemillis()); m_conn.commit(); response.getoutputstream().write(new String("OK").getBytes()); catch(exception ex) ex.printstacktrace(); try m_conn.rollback(); catch(exception e) response.getoutputstream().write(ex.getmessage().getbytes()); throw new ServletException(ex.getMessage()); finally if(p_insert_stmt!= null) try p_insert_stmt.close(); catch(exception e) if(p_update_stmt!= null) try p_update_stmt.close(); catch(exception e) if(p_delete_stmt!= null) try p_delete_stmt.close(); catch(exception e) if (m_conn!= null) try m_conn.close(); catch(exception e) 50 FORCS Co., LTD
A Leader of Enterprise e-business Solution private void insert(httpservletrequest request, HttpServletResponse response, int cnt) throws Exception int insert_source_fieldcnt = Integer.parseInt(request.getParameter(cnt + ".SRC_CNT")); if (dac_insert_query.equalsignorecase("")) // prepared. dac_insert_query = "INSERT INTO "+TABLENAME+" ("; for (int i = 0; i < insert_source_fieldcnt; i++) String s_fieldname = getencode(request.getparameter(cnt + ".SF_" + i)); if (i == insert_source_fieldcnt - 1) dac_insert_query += s_fieldname; else dac_insert_query += s_fieldname + ","; dac_insert_query += ") VALUES ( "; for (int i = 0; i < insert_source_fieldcnt; i++) if (i == insert_source_fieldcnt - 1) dac_insert_query += "?"; else dac_insert_query += "?,"; dac_insert_query += ")"; System.out.println("dac_insert_query="+dac_insert_query); p_insert_stmt = m_conn.preparestatement(dac_insert_query); for (int i = 0; i < insert_source_fieldcnt; i++) String value = getencode(request.getparameter(cnt + ".SV_" + i)); p_insert_stmt.setstring(i + 1, value); p_insert_stmt.execute(); private void update(httpservletrequest request, HttpServletResponse response, int cnt) throws Exception int update_source_fieldcnt = Integer.parseInt(request.getParameter(cnt + ".SRC_CNT")); int update_target_fieldcnt = 0; try update_target_fieldcnt = Integer.parseInt(request.getParameter(cnt + ".TRG_CNT")); catch(exception ex) if (dac_update_query.equalsignorecase("")) // prepared. dac_update_query = "UPDATE "+TABLENAME+" set "; for (int i = 0; i < update_source_fieldcnt; i++) String s_fieldname = getencode(request.getparameter(cnt + ".SF_" + i)); if (i == update_source_fieldcnt - 1) FORCS Co., LTD 51
OZ Framework User's Guide dac_update_query += s_fieldname +" =? "; else dac_update_query += s_fieldname +" =?,"; dac_update_query += " WHERE "; for (int i = 0; i < update_target_fieldcnt; i++) String t_fieldname = getencode(request.getparameter(cnt + ".DF_" + i)); if (i == update_target_fieldcnt - 1) dac_update_query += t_fieldname +" =? "; else dac_update_query += t_fieldname +" =? AND "; System.out.println("dac_update_query="+dac_update_query); p_update_stmt = m_conn.preparestatement(dac_update_query); int i = 0; for (i = 0; i < update_source_fieldcnt; i++) String value = getencode(request.getparameter(cnt + ".SV_" + i)); p_update_stmt.setstring(i + 1, value); for (int j = 0; j < update_source_fieldcnt; j++) String value = getencode(request.getparameter(cnt + ".DV_" + j)); p_update_stmt.setstring(i + 1, value); i++; p_update_stmt.execute(); private void delete(httpservletrequest request, HttpServletResponse response, int cnt) throws Exception int delete_target_fieldcnt = Integer.parseInt(request.getParameter(cnt + ".TRG_CNT")); if (dac_delete_query.equalsignorecase("")) // prepared. dac_delete_query = "DELETE FROM "+TABLENAME+" WHERE "; for (int i = 0; i < delete_target_fieldcnt; i++) String t_fieldname = getencode(request.getparameter(cnt + ".DF_" + i)); if (i == delete_target_fieldcnt - 1) dac_delete_query += t_fieldname +" =? "; else dac_delete_query += t_fieldname +" =? AND "; System.out.println("dac_delete_query="+dac_delete_query); p_delete_stmt = m_conn.preparestatement(dac_delete_query); 52 FORCS Co., LTD
A Leader of Enterprise e-business Solution int i = 0; for (i = 0; i < delete_target_fieldcnt; i++) String value = getencode(request.getparameter(cnt + ".DV_" + i)); p_delete_stmt.setstring(i + 1, value); p_delete_stmt.execute(); public void destroy() super.destroy(); private String getencode(string value) try return new String(value.getBytes("8859_1"), "KSC5601"); catch(exception ex) return value; Step 3 " 1" DataModuleSampleServlet.class DataActionSampleServlet.class WAS. DataModuleSampleServlet.class, DataActionSampleServlet.class WAS. Tomcat 5.0 webapps\root\web-inf\classes sample. DataModuleSampleServlet.class, DataActionSampleServlet.class WAS. Tomcat 5.0 webapps\root\web-inf web.xml.... <!-- JSPC servlet mappings start -->... <servlet> <servlet-name>sample.datamodulesampleservlet</servlet-name> <servlet-class>sample.datamodulesampleservlet</servlet-class> </servlet> <servlet> <servlet-name>sample.dataactionsampleservlet</servlet-name> FORCS Co., LTD 53
OZ Framework User's Guide <servlet-class>sample.dataactionsampleservlet</servlet-class> </servlet>... <servlet-mapping> <servlet-name>sample.datamodulesampleservlet</servlet-name> <url-pattern>/sample.datamodulesampleservlet</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>sample.dataactionsampleservlet</servlet-name> <url-pattern>/sample.dataactionsampleservlet</url-pattern> </servlet-mapping>... <!-- JSPC servlet mappings end --> Step 4 ODI Servlet API (UDS),. (UDS).. 54 FORCS Co., LTD
A Leader of Enterprise e-business Solution. [ ]. []. FORCS Co., LTD 55
OZ Framework User's Guide. SET_1 [ ], [ ], [ ],,.. INSERT INTO car(#@arg_sf1#, #@ARG_SF2#, #@ARG_SF3#, #@ARG_SF4#, #@ARG_SF5#, #@ARG_SF6#) VALUES('#@ARG_SV1#','#@ARG_SV2#', '#@ARG_SV3#','#@ARG_SV4#', '#@ARG_SV5#', '#@ARG_SV6#'). DELETE FROM car WHERE [#@ARG_DF1#] = '#@ARG_DV1#"; 56 FORCS Co., LTD
A Leader of Enterprise e-business Solution. UPDATE car SET [#@ARG_SF1#] = '#@ARG_SV1#', [#@ARG_SF2#] = '#@ARG_SV2#', [#@ARG_SF3#] = '#@ARG_SV3#', [#@ARG_SF4#] = '#@ARG_SV4#', [#@ARG_SF5#] = '#@ARG_SV5#', [#@ARG_SF6#] = '#@ARG_SV6#' WHERE [#@ARG_DF1#] = '#@ARG_DV1#' ODI "JASMIN_SAMPLE4.odi". Step 5 "JASMIN_SAMPLE4.odi" " 1" "MyFrameworkURLUDS.ozf". Board Table Table ODIKey "JASMIN_SAMPLE4", DataSet "SET_1",. Table,, Table "AllowInsert", "AllowDelete", "AllowUpdate" "True". Table OnInitialize. var uds = new MyFrameworkURLUDS("http://127.0.0.1:8088/sample.DataModuleSampleServlet","http://127.0.0.1:8088/sample.DataActionSampleServlet"); var datamanager = _GetDataManager(); var datamodule = datamanager.getdatamodule("jasmin_sample4"); datamodule.registeruserdatamodule(uds); FORCS Co., LTD 57
OZ Framework User's Guide Board Button Button OnClick. var result = Table1.CommitQueuedActions(); if(result == "") Table1.GetDataModule().RefreshAllDataSet(); else _MessageBox(result); //var myodiobject = _GetDataManager().GetDataModule("odiName").GetUserDataModule(); //Select // myodiobject.url_param = "key1=value1&key2=value2"; //DataAction // myodiobject.cud_url_param = "key1=value1&key2=value2"; //_GetDataManager().GetDataModule("odiName").RefreshAllDataSet(); Step 7.. Delete.. 58 FORCS Co., LTD
A Leader of Enterprise e-business Solution,, DataAction. [CommitQueueActions]. 3 : Report - Servlet API. Servlet API framworkurl (HTTP URL). odi.odi.framworkurl, odi.framworkurl, connection.framworkurl. : Servlet API,. Step 1 ozsdmapi.jar WAS Servlet API ozsdmapi.jar WAS. Tomcat 5.0 webapps\root\web-inf\lib ozsdmapi.jar. Step 2 " 1" DataModuleSampleServlet.class WAS. DataModuleSampleServlet.class WAS. Tomcat 5.0 webapps\root\web-inf\classes\sample. FORCS Co., LTD 59
OZ Framework User's Guide DataModuleSampleServlet.class WAS. Tomcat 5.0 webapps\root\web-inf web.xml.... <!-- JSPC servlet mappings start -->... <servlet> <servlet-name>sample.datamodulesampleservlet</servlet-name> <servlet-class>sample.datamodulesampleservlet</servlet-class> </servlet>... <servlet-mapping> <servlet-name>sample.datamodulesampleservlet</servlet-name> <url-pattern>/sample.datamodulesampleservlet</url-pattern> </servlet-mapping>... <!-- JSPC servlet mappings end --> Step 3 " 1" JASMIN_SAMPLE2.odi.,. "ODI " "JASMIN_SAMPLE2", "" "SET_1". &.. 60 FORCS Co., LTD
A Leader of Enterprise e-business Solution [] " " []. [],,. FORCS Co., LTD 61
OZ Framework User's Guide "Sample_ServletAPI.ozr". Step 4. Sample_ServletAPI.htm. <HTML> <BODY> <OBJECT width = "0" height = "0" ID="ZTransferX" CLASSID="CLSID:C7C7225A-9476-47AC- B0B0-FF3B79D55E67" codebase="127.0.0.1:8088/ozrviewer/ztransferx.cab#version=2,0,1,2"> <PARAM NAME="download.Server" VALUE="http://127.0.0.1/ozrviewer"> <PARAM NAME="download.Port" VALUE="8088"> <PARAM NAME="download.Instruction" VALUE="ozrviewer.idf"> <PARAM NAME="install.Base" VALUE="<PROGRAMS>/Forcs"> <PARAM NAME="install.Namespace" VALUE="Sample_ServletAPI"> </OBJECT> <OBJECT id = "ozrviewer" CLASSID="CLSID:0DEF32F8-170F-46f8-B1FF-4BF7443F5F25" width="100%" height="100%"> <param name="connection.servlet" value="http://127.0.0.1:8088/ozservlet40/server"> <param name="connection.reportname" value="sample_servletapi.ozr"> <param name="odi.odinames" value="jasmin_sample2"> <param name="odi.jasmin_sample2.frameworkurl" value="http://127.0.0.1:8088/sample.datamodulesampleservlet"> <param name="odi.jasmin_sample2.fetchtype" value="batch"> <param name="viewer.isframe" value="false"> <param name="viewer.namespace" value="sample_servletapiozviewer"> </OBJECT> </BODY> </HTML> : Servlet API odi.odi.framworkurl odi.framworkurl connection.framworkurl URL.. 62 FORCS Co., LTD
A Leader of Enterprise e-business Solution. FORCS Co., LTD 63
OZ Framework User's Guide 4 : XML SDM Servlet API XML SDM. Servlet API XML SDM ozsdmapi.jar, crimson.jar XML SDM WAS UDS ODI. Step 1 ozsdmapi.jar crimson.jar WAS Servlet API ozsdmapi.jar, crimson.jar WAS. Tomcat 5.0 webapps\root\web-inf\lib ozsdmapi.jar, crimson.jar. Step 2 XML SDM XML SDM. java DebugDMSampleServlet.class. package sample; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import java.util.*; import oz.framework.api.datamodule; import oz.sdm.datamodulefactory; public class DebugDMSampleServlet extends HttpServlet private static final String _KEY_ODI_FETCH_TYPE = "_OZ_ODIFetchType_"; private static final String _KEY_ODIITEM = "_OZ_ODIITEM_"; private static final String _KEY_OZ_DATASET_ = "_OZ_DATASET_"; private static final String _KEY_OZ_DEBUG_ = "_OZ_DEBUG_"; private static final String ODI_NAME_1 = "JASMIN_SAMPLE2.odi"; private static final String ODI_NAME_2 = "JASMIN_SAMPLE3.odi"; private static final String ODI_NAME_3 = "JASMIN_SAMPLE4.odi"; private Connection m_conn = null; public void init(servletconfig config) throws ServletException super.init(config); System.out.println("init..."); public void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException process(request, response); 64 FORCS Co., LTD
A Leader of Enterprise e-business Solution public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException process(request, response); public void destroy() super.destroy(); System.out.println("destroy..."); private void process(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException try String _URL = "jdbc:odbc:ozdemokr30"; Properties prop = new Properties(); prop.put("user", ""); prop.put("password", ""); Driver driver = (Driver)Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); m_conn = driver.connect(_url, prop); System.out.println("connection ok..."); catch(exception e) System.out.println("connection error..."); System.out.println(e.getMessage()); DataModule.sendErrorMessage("connection error...", response.getoutputstream()); close(m_conn, null, null); throw new ServletException(e.getMessage()); try System.out.println("start--------------------"); Enumeration enum = request.getparameternames(); System.out.println("parameter list--------------------"); while (enum.hasmoreelements()) String temp = (String) enum.nextelement(); System.out.println("name=" + temp + " value=" + getencode(request.getparameter(temp))); System.out.println("----------------------------------------"); String odifetchtype = getencode(request.getparameter(_key_odi_fetch_type)); String item = getencode(request.getparameter(_key_odiitem)); String dataset = getencode(request.getparameter(_key_oz_dataset_)); if (odifetchtype == null) odifetchtype = "DM_CONCURRENT_FETCH"; if ((dataset == null) (dataset.length() == 0)) if (item.equals(odi_name_2)) Master_Detail_Style(request, response, odifetchtype); else if (item.equals(odi_name_1) item.equals(odi_name_3)) default_style(request, response, odifetchtype); else System.out.println("unsupported odi error..."); DataModule.sendErrorMessage("unsupported odi error...", response.getoutputstream()); throw new ServletException("Unknown Item :" + item); else if (odifetchtype.equalsignorecase("dm_concurrent_fetch") odifetchtype.equalsignorecase("dm_per_dataset")) FORCS Co., LTD 65
OZ Framework User's Guide setdefaultstyle(request, response, odifetchtype); //setresultsetquerystyle(request, response, odifetchtype); else System.out.println("unsupported error..."); DataModule.sendErrorMessage("unsupported error...", response.getoutputstream()); throw new ServletException("unsupported"); catch(exception ex) System.out.println(ex.getMessage()); DataModule.sendErrorMessage(ex.getMessage(), response.getoutputstream()); throw new ServletException(ex.getMessage()); finally close(m_conn, null, null); System.out.println("end--------------------"); private void Master_Detail_Style(HttpServletRequest request, HttpServletResponse response, String fetchtype) throws ServletException, IOException Statement stmt1 = null; Statement stmt4 = null; ResultSet rs1 = null; ResultSet rs4 = null; DataModule module = null; String[] _FN1 = "FirstName"; int[] _FT1 = java.sql.types.varchar; String[] _FN4 = "ContactId", "FirstName", "LastName", "Phone", "Fax", "Email", "OrgUnitId", "UserName" ; int[] _FT4 = 4, 12, 12, 12, 12, 12, 5, 12 ; try module = DataModuleFactory.getDataModule(fetchType); // debug true. // init setdebug. module.setdebug(parseboolean(request), response); module.init(response.getoutputstream()); module.addsetinfo("set_1", "", _FN1, _FT1); module.addsetinfo("set_4", "SET_1", _FN4, _FT4); catch(exception ex) throw new ServletException(ex.getMessage()); try module.startbinding(); String query1 = "select distinct FirstName from contact"; module.startset("set_1"); stmt1 = m_conn.createstatement(); rs1 = stmt1.executequery(query1); while(rs1.next()) String f1 = rs1.getstring(_fn1[0]); HashMap map1 = new HashMap(); map1.put(_fn1[0], f1); module.addrow("set_1", map1); contactid"; String query4 = "select * from contact where FirstName='" + f1 + "'order by module.startset("set_4"); stmt4 = m_conn.createstatement(); rs4 = stmt4.executequery(query4); 66 FORCS Co., LTD
A Leader of Enterprise e-business Solution while(rs4.next()) HashMap map4 = new HashMap(); map4.put(_fn4[0], new Integer(rs4.getInt(_FN4[0]))); map4.put(_fn4[1], rs4.getstring(_fn4[1])); map4.put(_fn4[2], rs4.getstring(_fn4[2])); map4.put(_fn4[3], rs4.getstring(_fn4[3])); map4.put(_fn4[4], rs4.getstring(_fn4[4])); map4.put(_fn4[5], rs4.getstring(_fn4[5])); map4.put(_fn4[6], new Integer(rs4.getInt(_FN4[6]))); map4.put(_fn4[7], rs4.getstring(_fn4[7])); module.addrow("set_4", map4); rs4.close(); stmt4.close(); module.endset("set_4"); module.endset("set_1"); module.endbinding(); catch(exception e) System.out.println(e.getMessage()); if(module!= null) module.sendbinderrormessage(e.tostring()); finally close(null, stmt1, rs1); close(null, stmt4, rs4); private void default_style(httpservletrequest request, HttpServletResponse response, String fetchtype) throws ServletException, IOException System.out.println("select time=="+system.currenttimemillis()); Statement stmt = null; ResultSet rs = null; DataModule module = null; String[] _FN = "CarID", "Maker", "EMaker", "CarName", "ECarName", "CarImageFile"; int[] _FT = java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar; try module = DataModuleFactory.getDataModule(fetchType); // debug true. // init setdebug. module.setdebug(parseboolean(request), response); module.init(response.getoutputstream()); module.addparameter("param1", java.sql.types.varchar, getencode(request.getparameter("param1"))); module.addparameter("param2", java.sql.types.varchar, getencode(request.getparameter("param2"))); module.addsetinfo("set_1", "", _FN, _FT); catch(exception ex) throw new ServletException(ex.getMessage()); try module.startbinding(); String query = "select * from car"; module.startset("set_1"); stmt = m_conn.createstatement(); rs = stmt.executequery(query); FORCS Co., LTD 67
OZ Framework User's Guide while(rs.next()) HashMap map = new HashMap(); String a = rs.getstring(_fn[0]); String b = rs.getstring(_fn[1]); String c = rs.getstring(_fn[2]); String d = rs.getstring(_fn[3]); String e = rs.getstring(_fn[4]); String f = rs.getstring(_fn[5]); map.put(_fn[0], a); map.put(_fn[1], b); map.put(_fn[2], c); map.put(_fn[3], d); map.put(_fn[4], e); map.put(_fn[5], f); module.addrow("set_1", map); System.out.print("select FN0="+_FN[0]+" name="+a); System.out.print(" FN1="+_FN[1]+" name="+b); System.out.print(" FN2="+_FN[2]+" name="+c); System.out.print(" FN3="+_FN[3]+" name="+d); System.out.print(" FN4="+_FN[4]+" name="+e); System.out.print(" FN5="+_FN[5]+" name="+f); System.out.println(""); module.endset("set_1"); module.endbinding(); catch(exception e) System.out.println(e.getMessage()); module.sendbinderrormessage(e.tostring()); finally close(null, stmt, rs); private void setdefaultstyle(httpservletrequest request, HttpServletResponse response, String fetchtype) throws ServletException, IOException System.out.println("1setDefaultStyle fetchtype =="+fetchtype); Statement stmt = null; ResultSet rs = null; DataModule module = null; String[] _FN = "CarID", "Maker", "EMaker", "CarName", "ECarName", "CarImageFile"; int[] _FT = java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar, java.sql.types.varchar; try module = DataModuleFactory.getDataModule(fetchType); // debug true. // init setdebug. module.setdebug(parseboolean(request), response); module.init(response.getoutputstream()); module.addsetinfo("set_1", _FN, _FT); catch(exception ex) throw new ServletException(ex.getMessage()); try module.startbinding(); String query = "select * from car"; module.startset("set_1"); stmt = m_conn.createstatement(); 68 FORCS Co., LTD
A Leader of Enterprise e-business Solution rs = stmt.executequery(query); while(rs.next()) HashMap map = new HashMap(); String a = rs.getstring(_fn[0]); String b = rs.getstring(_fn[1]); String c = rs.getstring(_fn[2]); String d = rs.getstring(_fn[3]); String e = rs.getstring(_fn[4]); String f = rs.getstring(_fn[5]); map.put(_fn[0], a); map.put(_fn[1], b); map.put(_fn[2], c); map.put(_fn[3], d); map.put(_fn[4], e); map.put(_fn[5], f); module.addrow("set_1", map); System.out.print("select FN0="+_FN[0]+" name="+a); System.out.print(" FN1="+_FN[1]+" name="+b); System.out.print(" FN2="+_FN[2]+" name="+c); System.out.print(" FN3="+_FN[3]+" name="+d); System.out.print(" FN4="+_FN[4]+" name="+e); System.out.print(" FN5="+_FN[5]+" name="+f); System.out.println(""); module.endset("set_1"); module.endbinding(); catch(exception e) System.out.println(e.getMessage()); module.sendbinderrormessage(e.tostring()); finally close(null, stmt, rs); private void setresultsetquerystyle(httpservletrequest request, HttpServletResponse response, String fetchtype) throws ServletException, IOException System.out.println("setResultSetQueryStyle..."); Statement stmt = null; ResultSet rs = null; DataModule module = null; try module = DataModuleFactory.getDataModule(fetchType); // debug true. // init setdebug. module.setdebug(parseboolean(request), response); String query = "select * from car"; stmt = m_conn.createstatement(); rs = stmt.executequery(query); module.makesdm_set("set_1", rs, response.getoutputstream()); catch(exception e) System.out.println(e.getMessage()); throw new ServletException(e.getMessage()); finally close(null, stmt, rs); private String getencode(string value) try FORCS Co., LTD 69
OZ Framework User's Guide return new String(value.getBytes("8859_1"), "KSC5601"); catch(exception ex) return value; private void close(connection con, Statement stmt, ResultSet rs) try if(rs!= null) rs.close(); if(stmt!= null) stmt.close(); if(con!= null) con.close(); catch(sqlexception se) private boolean parseboolean(httpservletrequest request) String tmp = (String)request.getParameter(_KEY_OZ_DEBUG_); if("true".equalsignorecase(tmp)) return true; else return false; Step 3 DebugDMSampleServlet.class WAS. DebugDMSampleServlet.class WAS. Tomcat 5.0 webapps\root\web-inf\classes\sample. DebugDMSampleServlet.class WAS. Tomcat 5.0 webapps\root\web-inf web.xml.... <!-- JSPC servlet mappings start -->... <servlet> <servlet-name>sample.debugdmsampleservlet </servlet-name> <servlet-class>sample.debugdmsampleservlet</servlet-class> </servlet>... <servlet-mapping> 70 FORCS Co., LTD
A Leader of Enterprise e-business Solution <servlet-name>sample.debugdmsampleservlet </servlet-name> <url-pattern>/sample.debugdmsampleservlet </url-pattern> </servlet-mapping>... <!-- JSPC servlet mappings end --> Step 4 ODI Servlet API (UDS),. POST "_OZ_ODIITEM_".. (UDS).. FORCS Co., LTD 71
OZ Framework User's Guide. [ ]. [].. 72 FORCS Co., LTD
A Leader of Enterprise e-business Solution. ( ). URL []. FORCS Co., LTD 73
OZ Framework User's Guide "_OZ_ODIITEM_=ODI" [].. ODI "JASMIN_SAMPLE2.odi". Step 5 XML SDM. 74 FORCS Co., LTD
A Leader of Enterprise e-business Solution XML SDM URL. http://127.0.0.1:8080/sample.debugdmsampleservlet?_oz_odifetchtype_=dm_batch_fetch &_OZ_DEBUG_=true&_OZ_ODIITEM_=JASMIN_SAMPLE2.odi XML SDM. FORCS Co., LTD 75
OZ Framework User's Guide 5 : FXDataModule Servlet API FX Data Accesses "_OZData_" Table,,. XML Servlet API ozsdmapi.jar, crimson.jar WAS. Step 1 ozsdmapi.jar crimson.jar WAS Servlet API ozsdmapi.jar, crimson.jar WAS. Tomcat 5.0 webapps\root\web-inf\lib ozsdmapi.jar, crimson.jar. Step 2 FXDataModule FXDataModule. java Test.class. package sample; import java.io.ioexception; import java.sql.connection; import java.sql.driver; import java.sql.preparedstatement; import java.sql.resultset; import java.sql.statement; import java.util.properties; import javax.servlet.servletexception; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import oz.fxapi.core.convertexception; import oz.fxapi.core.dataactionparser; import oz.fxapi.dm.fx_dataaction; import oz.fxapi.dm.fx_datafieldmeta; import oz.fxapi.dm.fx_datamodule; import oz.fxapi.dm.fx_dataset; import oz.fxapi.dm.fx_datasetmeta; import oz.fxapi.dm.fx_datatypes; import oz.fxapi.dm.fx_parameter; import oz.fxapi.dm.fx_record; import oz.fxapi.dm.fx_unmatchingmetaexception; import oz.util.ozsql; import oz.util.ozstring; /** <p>title: Framework test module</p> * <p>description: Tests framework functionality </p> * <p>copyright: Copyright (c) 2006 by FORCS All rights reserved </p> * <p>company: FORCS Co.,LTD.</p> 76 FORCS Co., LTD
A Leader of Enterprise e-business Solution * @author kgn */ public class Test extends HttpServlet private static final long serialversionuid = 8673861145524516336L; public void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException process(request, response); public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException process(request, response); private void process(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException String type = request.getparameter("type"); boolean iscompressed = "true".equalsignorecase(request.getparameter("compressed")); if (OZString.isNullOrEmpty(type)) throw new ServletException("Operation type not specified."); try if ("sdm".equalsignorecase(type)) processsdm(request, response, true, iscompressed); else if ("xml".equalsignorecase(type)) processsdm(request, response, false, iscompressed); else if ("dac".equalsignorecase(type)) processdac(request, response); else throw new ServletException("Unknown operation code; " + type); catch (Exception e) e.printstacktrace(); throw new ServletException(e.getMessage()); /** Generate data module which has master-detail relation * @param request * @param response * @param issdm * @throws Exception */ private void processsdm(httpservletrequest request, HttpServletResponse response, boolean issdm, boolean iscompressed) throws Exception FX_DataModule dm = new FX_DataModule(); // Access does not support multiple ResultSet Connection con = null; Connection con2 = null; try String url = "jdbc:odbc:ozcar"; Properties prop = new Properties(); FORCS Co., LTD 77
OZ Framework User's Guide Driver driver = (Driver) Class.forName( "sun.jdbc.odbc.jdbcodbcdriver").newinstance(); con = driver.connect(url, prop); con2 = driver.connect(url, prop); catch (Exception e) dm.senderrormessage(response.getoutputstream(), issdm, iscompressed, e.getmessage()); OZSQL.close(con); OZSQL.close(con2); throw new ServletException(e.getMessage()); response.setcontenttype(issdm iscompressed? "application/octet-stream" : "text/xml"); FX_DataSetMeta fxmeta = new FX_DataSetMeta("IDs"); fxmeta.adddatafieldmeta(new FX_DataFieldMeta("CarID", FX_DataTypes.FX_DT_VARCHAR)); dm.adddatasetmeta(fxmeta); fxmeta = new FX_DataSetMeta("Informations"); fxmeta.adddatafieldmeta(new FX_DataFieldMeta("Maker", FX_DataTypes.FX_DT_VARCHAR)); fxmeta.adddatafieldmeta(new FX_DataFieldMeta("CarName", FX_DataTypes.FX_DT_VARCHAR)); fxmeta.adddatafieldmeta(new FX_DataFieldMeta("ECarName", FX_DataTypes.FX_DT_VARCHAR)); fxmeta.setmastersetname("ids"); dm.adddatasetmeta(fxmeta); Statement stmt = con.createstatement(); Statement stmt2 = con2.createstatement(); String id; ResultSet master = stmt.executequery("select CarID from car"); try FX_DataSet masterset = new FX_DataSet("IDs"); while (master.next()) FX_Record record = new FX_Record(); id = master.getstring(1); record.addcolumn("carid", id); car where CarID = '" if (!OZString.isNullOrEmpty(id)) ResultSet detail = stmt2.executequery("select Maker, CarName, ECarName from try + id + "'"); FX_DataSet detailset = new FX_DataSet("Informations"); while (detail.next()) FX_Record detailrecord = new FX_Record(); detailrecord.addcolumn("maker", detail.getstring(1)); detailrecord.addcolumn("carname", detail.getstring(2)); detailrecord.addcolumn("ecarname", detail.getstring(3)); detailset.addrecord(detailrecord); 78 FORCS Co., LTD
A Leader of Enterprise e-business Solution record.adddetailset(detailset); finally detail.close(); masterset.addrecord(record); dm.adddataset(masterset); catch (Exception e) dm.senderrormessage(response.getoutputstream(), issdm, iscompressed, e.getmessage()); throw e; finally master.close(); stmt.close(); stmt2.close(); OZSQL.close(con); OZSQL.close(con2); try String error = request.getparameter("error"); if(!ozstring.isnullorempty(error)) throw new FX_UnmatchingMetaException(error); dm.write(response.getoutputstream(), issdm, iscompressed); catch(fx_unmatchingmetaexception ue) dm.senderrormessage(response.getoutputstream(), issdm, iscompressed, ue.getmessage()); catch(convertexception ce) dm.senderrormessage(response.getoutputstream(), issdm, iscompressed, ce.getmessage()); catch(ioexception e) // ignore private void processdac(httpservletrequest request, HttpServletResponse response) throws Exception Connection con = null; try String url = "jdbc:odbc:ozcar"; Properties prop = new Properties(); prop.put("user", ""); prop.put("password", ""); Driver driver = (Driver) Class.forName( FORCS Co., LTD 79
OZ Framework User's Guide "sun.jdbc.odbc.jdbcodbcdriver").newinstance(); con = driver.connect(url, prop); catch (Exception e) OZSQL.close(con); throw new ServletException(e.getMessage()); FX_DataModule dm = new FX_DataModule(); FX_DataAction[] dacs = dm.getdataaction(request); for (int i = 0; i < dacs.length; i++) FX_DataAction dac = dacs[i]; String type = dac.getactiontype(); if ("insert".equalsignorecase(type)) // do insert insert(dac, con); else if ("delete".equalsignorecase(type)) // do delete delete(dac, con); else if ("rowupdate".equalsignorecase(type)) // to update update(dac, con); else throw new Exception("Illegal data action type; " + type); private String m_insert, m_update, m_delete; private static final String TABLENAME = "car"; private PreparedStatement m_insertstmt, m_deletestmt, m_updatestmt; private void insert(fx_dataaction dac, Connection con) throws Exception FX_Parameter[] srcfields = dac.getsourcefields(); if (OZString.isNullOrEmpty(m_insert)) // prepared. m_insert = "INSERT INTO " + TABLENAME + " ("; for (int i = 0; i < srcfields.length; i++) if (i == srcfields.length - 1) m_insert += srcfields[i].getname(); else m_insert += srcfields[i].getname() + ","; m_insert += ") VALUES ( "; for (int i = 0; i < srcfields.length; i++) if (i == srcfields.length - 1) m_insert += "?"; 80 FORCS Co., LTD
A Leader of Enterprise e-business Solution else m_insert += "?,"; m_insert += ")"; m_insertstmt = con.preparestatement(m_insert); for (int i = 0; i < srcfields.length; i++) m_insertstmt.setstring(i + 1, encode(srcfields[i].getvalue())); m_insertstmt.execute(); private void update(fx_dataaction dac, Connection con) throws Exception FX_Parameter[] srcfields = dac.getsourcefields(); FX_Parameter[] destfields = dac.gettargetfields(); if (OZString.isNullOrEmpty(m_update)) // prepared. m_update = "UPDATE " + TABLENAME + " set "; for (int i = 0; i < srcfields.length; i++) if (i == srcfields.length - 1) m_update += srcfields[i].getname() + " =? "; else m_update += srcfields[i].getname() + " =?, "; m_update += " WHERE "; for (int i = 0; i < destfields.length; i++) if (i == destfields.length - 1) m_update += destfields[i].getname() + " =? "; else m_update += destfields[i].getname() + " =? AND "; m_updatestmt = con.preparestatement(m_update); int i = 0; for (i = 0; i < srcfields.length; i++) m_updatestmt.setstring(i + 1, encode(srcfields[i].getvalue())); for (int k = 0; k < destfields.length; k++) m_updatestmt.setstring(i + 1, encode(destfields[k].getvalue())); FORCS Co., LTD 81
OZ Framework User's Guide i++; m_updatestmt.execute(); private void delete(fx_dataaction dac, Connection con) throws Exception FX_Parameter[] targetfields = dac.gettargetfields(); if (OZString.isNullOrEmpty(m_delete)) m_delete = "DELETE FROM " + TABLENAME + " WHERE "; for (int i = 0; i < targetfields.length; i++) if (i == targetfields.length - 1) m_delete += targetfields[i].getname() + " =? "; else m_delete += targetfields[i].getname() + " =? AND "; m_deletestmt = con.preparestatement(m_delete); int i = 0; for (i = 0; i < targetfields.length; i++) m_deletestmt.setstring(i + 1, encode(targetfields[i].getvalue())); m_deletestmt.execute(); private String encode(string value) try return new String(value.getBytes("8859_1"), "KSC5601"); catch(exception ex) return value; Step 3 Test.class WAS. Test.class. Tomcat 5.0 webapps\root\web-inf\classes sample. Test.class WAS. Tomcat 5.0 82 FORCS Co., LTD
A Leader of Enterprise e-business Solution webapps\root\web-inf web.xml.... <!-- JSPC servlet mappings start -->... <servlet> <servlet-name>sample.test</servlet-name> <servlet-class>sample.test</servlet-class> </servlet>... <servlet-mapping> <servlet-name>sample.test </servlet-name> <url-pattern>/test </url-pattern> </servlet-mapping>... <!-- JSPC servlet mappings end --> Step 4 FX Data Accesses "_OZData_" [ FX DataSet] []. [ ]. [ Detail FX DataSet] [] FORCS Co., LTD 83
OZ Framework User's Guide. [ ]. -. Step 5 OZA Board Panel, Label, TextBox, Button, Table,. Label Lable "Text" "CarID", "Maker", "CarName", "ECarName". 84 FORCS Co., LTD
A Leader of Enterprise e-business Solution Button 4 Button "Text" "XML ", "Insert", "Update", "Delete". TextBox (Location), (Size) TextBox. TextBox1 "ODIKey" "_OZData_", "DataSet" "IDs", "Field" "CarID" "TextBox2", "TextBox3", "TextBox4" "ODIKey" "_OZData_", "DataSet" "Informations" "Field" "Maker", "CarName", "ECarName". Table 2 Table1 "ODIKey" "_OZData_", "DataSet" "IDs", "FireRowCursorChange" "True" Table2 "ODIKey" "_OZData_", "DataSet" "Informations". Table1 "CarID", Table2 "Maker", "CarName", "ECarName". Step 5 XML DataAction. [XML ] "OnClick" XML. _GetFXDataModule().RemoveAllDataSet(); var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // XML, xmlhttp.open("post", "http://127.0.0.1:8080/test?type=xml", false); xmlhttp.send(""); var dm = _GetFXDataModule(); dm.applydata(xmlhttp.responsestream); if(dm.fxerrormessage!= "") _MessageBox(dm.FXErrorMessage); [Insert] "OnClick" "CarID: K04". _GetFXDataModule().RemoveAllDataSet(); FORCS Co., LTD 85
OZ Framework User's Guide var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // XML, xmlhttp.open("post", http://127.0.0.1:8080/test?type=dac&_oz_dac_cnt_=1&0.type=insert&0.src_cnt=4&0.s F_0=CarID&0.SFT_0=VARCHAR&0.SV_0=K04&0.SF_1=Maker&0.SFT_1=VARCHAR&0.SV_1= &0.SF_2=CarName&0.SFT_2=VARCHAR&0.SV_2=&0.SF_3=ECarName&0.SFT_3 =VARCHAR&0.SV_3=SEPHIA, false); xmlhttp.send(""); var dm = _GetFXDataModule(); dm.applydata(xmlhttp.responsestream); if(dm.fxerrormessage!= "") _MessageBox(dm.FXErrorMessage); [Update] 'OnClick' "CarID: K04". _GetFXDataModule().RemoveAllDataSet(); var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // XML, xmlhttp.open("post", "http://127.0.0.1:8080/test?type=dac&_oz_dac_cnt_=1&0.type=rowupdate&0.src_cnt=1 &0.SF_0=ECarName&0.SFT_0=VARCHAR&0.SV_0=SEPHIA2&0.TRG_CNT=1&0.DF_0=CarID&0.D FT_0=VARCHAR&0.DV_0=K04", false); xmlhttp.send(""); var dm = _GetFXDataModule(); dm.applydata(xmlhttp.responsestream); if(dm.fxerrormessage!= "") _MessageBox(dm.FXErrorMessage); [Delete] "OnClick" "CarID: K04". _GetFXDataModule().RemoveAllDataSet(); var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); // XML, xmlhttp.open("post", http://127.0.0.1:8080/test?type=dac&_oz_dac_cnt_=1&0.type=delete&0.trg_cnt=1&0.d F_0=CarID&0.DFT_0=VARCHAR&0.DV_0=K04, false); xmlhttp.send(""); var dm = _GetFXDataModule(); 86 FORCS Co., LTD
A Leader of Enterprise e-business Solution dm.applydata(xmlhttp.responsestream); if(dm.fxerrormessage!= "") _MessageBox(dm.FXErrorMessage); Step 6 WAS. [File] [Preview] ( ). FORCS Co., LTD 87