Hi, this is the code of the example based on 2 new tables in bookstore: --------------- CODE ------------------------------------ ivanCustomerJSTL_Bean.jsp
<html> <%@ taglib uri="/WEB-INF/dbforms.tld" prefix="db" %> <%@ taglib uri="/jstl-c" prefix="c" %> <jsp:useBean id="backcolor" scope="page" class="Xoft.IvanBackgroudColor"/> <!-- To use the bean in JSTL i have to define a variable with jstl c:set var filled with the value of the bean. In this way later I could access to the properties of that bean --> <c:set var="backcolor" value="${backcolor}" /> <head> <script src ="/bookstore/jscal/calendar.js" type="text/javascript"></script> <db:base /> <target="_top"> </head> <body> <db:dbform autoUpdate="false" maxRows="*" tableName="CUSTOMER" > <db:header> <h1 align="center">Edit Customers</h1> <p align="center">Using simple dbform on simple table. maxRows=1; allowNew=true; autoUpdate=false</p> <table class="fixed" align="center"> <db:errors/> </db:header> <db:body allowNew="true"> <c:out value="${currentRow_CUSTOMER}" /> <br/>Setting the idNumber via scripting; <% backcolor.setIdNumber((int) Integer.parseInt((String)currentRow_CUSTOMER.get("CUSTOMER_ID"))); out.println("<br/> Test current ID: " + (String)currentRow_CUSTOMER.get("CUSTOMER_ID")); %> <c:out value="${backcolor.idNumber}" /> <br/> <!-- sets the idNumber property of the bean via JSTL SYNTAX --> Setting the idNumber via jstl syntax: <c:set target="${backcolor}" property="idNumber" value="${currentRow_CUSTOMER.CUSTOMER_ID}" /> <c:out value="${backcolor.idNumber}" /> <br/>getBgColor via scripting: <%=backcolor.getBgColor() %> <c:out value="${backcolor.bgColor}" /> <!-- sets the value of the bean via BEAN syntax --> <jsp:setProperty name="backcolor" property="idNumber" value="3" /> <br/>Id Number setted by setProperty fixed value 3- BEAN SYNTAX - <c:out value="${backcolor.idNumber}" /> <!-- sets the value of the bean via JSTL syntax --> <br/>Id Number setted by jstl set fixed value 4-JSTL SYNTAX, with previous initializaziton - <c:set target="${backcolor}" property="idNumber" value="4" /> <c:out value="${backcolor.idNumber}" /> <!-- Body --> <tr class="even" bgcolor=<c:out value="${backcolor.bgColor}"/> > <td style="width:300px">ID</td> <td style="width:100px"> JSTL_ID: <c:out value="${currentRow_CUSTOMER.CUSTOMER_ID}" /> DBFORMS_ID: <db:label fieldName="CUSTOMER_ID" /> </td> </tr> <tr class="even" bgcolor=<c:out value="${backcolor.bgColor}"/> > <td>CUSTOMER NAME</td> <td><db:textField size="25" fieldName="NAME"/> </td> </tr> <tr class="even" bgcolor=<c:out value="${backcolor}"/> class="button"> <td colspan="2" style="text-align:center"> <db:updateButton style="width:100" caption="Save"/> <db:deleteButton style="width:100" caption="Delete"/> <db:insertButton style="width:100" caption="Insert" showAlways="false" /> </td> </tr> <tr> <td colspan="2"><hr/></td> </tr> </db:body> <db:footer> <tr class="button"> <td colspan="2" style="text-align:center"><db:navFirstButton style="width:100" caption="<< First"/> <db:navPrevButton style="width:100" caption="< Previous"/> <db:navNextButton style="width:100" caption="> Next"/> <db:navLastButton style="width:100" caption=">> Last"/> <db:navNewButton style="width:100" caption="New" showAlwaysInFooter="false"/> <db:navCopyButton style="width:100" caption="Copy" showAlwaysInFooter="false"/> </td> </tr> </table> </db:footer> </db:dbform> <%@ include file="httpSnooper.jsp" %> <!-- Body end --> </body> </html> ----------------------------------------------------------------------- IvanBackgroundColor.java - the bean - /* * Created on Jul 4, 2004 * * Test per bean */ package Xoft; /** * @author [EMAIL PROTECTED] * * Simple class to create background color. */ public class IvanBackgroudColor { private String BG_LIGHT; private String BG_DARK; private String bgColor; private int idNumber; /** * @param ID_Number */ public IvanBackgroudColor() { BG_LIGHT="#EEEEEE"; BG_DARK="#666666"; } /** * @param idNumber The idNumber to set. */ public void setIdNumber(int idNumber) { this.idNumber = idNumber; } /** * @return Returns the idNumber. */ public int getIdNumber() { return idNumber; } /** * @return Returns the bgColor. */ public String getBgColor() { if (this.idNumber % 2 ==1) this.bgColor=BG_DARK; else this.bgColor=BG_LIGHT; return bgColor; } } ------------------------------------------------------------------------ A piece of code added to bookstore.script to create the new tables: CREATE TABLE LIBRARY(LIBRARY_ID INTEGER NOT NULL IDENTITY PRIMARY KEY, COMPANYNAME VARCHAR(50) NOT NULL) CREATE TABLE CUSTOMER(CUSTOMER_ID INTEGER NOT NULL IDENTITY PRIMARY KEY, NAME VARCHAR(50) NOT NULL) CREATE TABLE CUSTOMER_LIBRARY(CUSTOMER_ID INTEGER NOT NULL, LIBRARY_ID INTEGER NOT NULL) INSERT INTO LIBRARY VALUES(1,'First Library inc') INSERT INTO LIBRARY VALUES(2,'Second Library inc') INSERT INTO CUSTOMER VALUES(1,'First customer John Kazzus') INSERT INTO CUSTOMER VALUES(2,'Second customer Joanna LaSilona') INSERT INTO CUSTOMER VALUES(3,'Third customer Alabao Masino') INSERT INTO CUSTOMER VALUES(4,'Fourth customer Meo Mara') INSERT INTO CUSTOMER_LIBRARY VALUES(1,1) INSERT INTO CUSTOMER_LIBRARY VALUES(1,2) INSERT INTO CUSTOMER_LIBRARY VALUES(2,3) INSERT INTO CUSTOMER_LIBRARY VALUES(2,4) INSERT INTO CUSTOMER_LIBRARY VALUES(2,2) --------------------------------------------------------------------- Piece of XML added to dbforms-config.xml of the bookstore exmample <table name="LIBRARY"> <field name="LIBRARY_ID" fieldType="int" isKey="true" autoInc="true"/> <field name="COMPANYNAME" fieldType="varchar" sortable="true"/> </table> <table name="CUSTOMER"> <field name="CUSTOMER_ID" fieldType="int" isKey="true" autoInc="true"/> <field name="NAME" fieldType="varchar" sortable="true"/> </table> <table name="CUSTOMER_LIBRARY"> <field name="LIBRARY_ID" fieldType="int" isKey="true" /> <field name="CUSTOMER_ID" fieldType="int" isKey="true" /> </table> ============== END ============================================== RESULT.HTML Here you can see that CUSTOMER_ID returned by JSTL is setted to 2 inspite of 1 (like the dbforms label tag). --------------------- result.html <html><head><!-- To use the bean in JSTL i have to define a variable with jstl c:set var filled with the value of the bean. In this way later I could access to the properties of that bean --> <script src="result_files/calendar" type="text/javascript"></script> <!-- base href="http://localhost:8080/ivanstore/tests/ivanCustomerJSTL_Bean.jsp" --> <target ="_top"></target></head> <body> <form name="dbform" action="/ivanstore/servlet/control" method="post"><input name="invtable" value="1" type="hidden"><input name="invname_1" value="" type="hidden"><input name="autoupdate_1" value="false" type="hidden"><input name="fu_1" value="/tests/ivanCustomerJSTL_Bean.jsp" type="hidden"><input name="lang" value="en" type="hidden"><imput type="hidden" name="country" value="US"><input name="source" value="/ivanstore/tests/ivanCustomerJSTL_Bean.jsp" type="hidden"><input name="customEvent" type="hidden"><input name="firstpos_1" value="0%3A1%3A1-1%3A26%3AFirst+customer+John+Kazzus" type="hidden"><input name="lastpos_1" value="0%3A1%3A4-1%3A24%3AFourth+customer+Meo+Mara" type="hidden"> </imput><h1 align="center">Edit Customers</h1> <p align="center">Using simple dbform on simple table. maxRows=1; allowNew=true; autoUpdate=false</p> {NAME=Second customer Joanna LaSilona, CUSTOMER_ID=2} <br>Setting the idNumber via scripting; <br> Test current ID: 1 1 <br> <!-- sets the idNumber property of the bean via JSTL SYNTAX --> Setting the idNumber via jstl syntax: 2 <br>getBgColor via scripting: #EEEEEE #EEEEEE <!-- sets the value of the bean via BEAN syntax --> <br>Id Number setted by setProperty fixed value 3- BEAN SYNTAX - 3 <!-- sets the value of the bean via JSTL syntax --> <br>Id Number setted by jstl set fixed value 4-JSTL SYNTAX, with previous initializaziton - 4 <!-- Body --> {NAME=Third customer Alabao Masino, CUSTOMER_ID=3} <br>Setting the idNumber via scripting; <br> Test current ID: 2 2 <br> <!-- sets the idNumber property of the bean via JSTL SYNTAX --> Setting the idNumber via jstl syntax: 3 <br>getBgColor via scripting: #666666 #666666 <!-- sets the value of the bean via BEAN syntax --> <br>Id Number setted by setProperty fixed value 3- BEAN SYNTAX - 3 <!-- sets the value of the bean via JSTL syntax --> <br>Id Number setted by jstl set fixed value 4-JSTL SYNTAX, with previous initializaziton - 4 <!-- Body --> {NAME=Fourth customer Meo Mara, CUSTOMER_ID=4} <br>Setting the idNumber via scripting; <br> Test current ID: 3 3 <br> <!-- sets the idNumber property of the bean via JSTL SYNTAX --> Setting the idNumber via jstl syntax: 4 <br>getBgColor via scripting: #EEEEEE #EEEEEE <!-- sets the value of the bean via BEAN syntax --> <br>Id Number setted by setProperty fixed value 3- BEAN SYNTAX - 3 <!-- sets the value of the bean via JSTL syntax --> <br>Id Number setted by jstl set fixed value 4-JSTL SYNTAX, with previous initializaziton - 4 <!-- Body --> {NAME=Fourth customer Meo Mara, CUSTOMER_ID=4} <br>Setting the idNumber via scripting; <br> Test current ID: 4 4 <br> <!-- sets the idNumber property of the bean via JSTL SYNTAX --> Setting the idNumber via jstl syntax: 4 <br>getBgColor via scripting: #EEEEEE #EEEEEE <!-- sets the value of the bean via BEAN syntax --> <br>Id Number setted by setProperty fixed value 3- BEAN SYNTAX - 3 <!-- sets the value of the bean via JSTL syntax --> <br>Id Number setted by jstl set fixed value 4-JSTL SYNTAX, with previous initializaziton - 4 <!-- Body --> <table class="fixed" align="center"> <tbody><tr class="even" bgcolor="#eeeeee"> <td style="width: 300px;">ID</td> <td style="width: 100px;"> JSTL_ID: 2 DBFORMS_ID: 1 </td> </tr> <tr class="even" bgcolor="#eeeeee"> <td>CUSTOMER NAME</td> <td><input name="[EMAIL PROTECTED]" value="First customer John Kazzus" size="25" type="text"><input name="[EMAIL PROTECTED]" value="First customer John Kazzus" type="hidden"> </td> </tr> <tr class="even" bgcolor="#00000b"> <td colspan="2" style="text-align: center;"> <input value="Save" style="width: 100px;" name="[EMAIL PROTECTED]" type="submit"> <input value="Delete" style="width: 100px;" name="[EMAIL PROTECTED]" type="submit"> </td> </tr> <tr> <td colspan="2"><hr></td> </tr> <tr class="even" bgcolor="#eeeeee"> <td style="width: 300px;">ID</td> <td style="width: 100px;"> JSTL_ID: 3 DBFORMS_ID: 2 </td> </tr> <tr class="even" bgcolor="#eeeeee"> <td>CUSTOMER NAME</td> <td><input name="[EMAIL PROTECTED]" value="Second customer Joanna LaSilona" size="25" type="text"><input name="[EMAIL PROTECTED]" value="Second customer Joanna LaSilona" type="hidden"> </td> </tr> <tr class="even" bgcolor="#00000b"> <td colspan="2" style="text-align: center;"> <input value="Save" style="width: 100px;" name="[EMAIL PROTECTED]" type="submit"> <input value="Delete" style="width: 100px;" name="[EMAIL PROTECTED]" type="submit"> </td> </tr> <tr> <td colspan="2"><hr></td> </tr> <tr class="even" bgcolor="#eeeeee"> <td style="width: 300px;">ID</td> <td style="width: 100px;"> JSTL_ID: 4 DBFORMS_ID: 3 </td> </tr> <tr class="even" bgcolor="#eeeeee"> <td>CUSTOMER NAME</td> <td><input name="[EMAIL PROTECTED]" value="Third customer Alabao Masino" size="25" type="text"><input name="[EMAIL PROTECTED]" value="Third customer Alabao Masino" type="hidden"> </td> </tr> <tr class="even" bgcolor="#00000b"> <td colspan="2" style="text-align: center;"> <input value="Save" style="width: 100px;" name="[EMAIL PROTECTED]" type="submit"> <input value="Delete" style="width: 100px;" name="[EMAIL PROTECTED]" type="submit"> </td> </tr> <tr> <td colspan="2"><hr></td> </tr> <tr class="even" bgcolor="#eeeeee"> <td style="width: 300px;">ID</td> <td style="width: 100px;"> JSTL_ID: 4 DBFORMS_ID: 4 </td> </tr> <tr class="even" bgcolor="#eeeeee"> <td>CUSTOMER NAME</td> <td><input name="[EMAIL PROTECTED]" value="Fourth customer Meo Mara" size="25" type="text"><input name="[EMAIL PROTECTED]" value="Fourth customer Meo Mara" type="hidden"> </td> </tr> <tr class="even" bgcolor="#00000b"> <td colspan="2" style="text-align: center;"> <input value="Save" style="width: 100px;" name="[EMAIL PROTECTED]" type="submit"> <input value="Delete" style="width: 100px;" name="[EMAIL PROTECTED]" type="submit"> </td> </tr> <tr> <td colspan="2"><hr></td> </tr> <tr class="button"> <td colspan="2" style="text-align: center;"><input value="<< First" style="width: 100px;" disabled="true" name="ac_first_1_307" type="submit"> <input value="< Previous" style="width: 100px;" disabled="true" name="ac_prev_1_308" type="submit"> <input value="> Next" style="width: 100px;" disabled="true" name="ac_next_1_309" type="submit"> <input value=">> Last" style="width: 100px;" disabled="true" name="ac_last_1_310" type="submit"> <input value="New" style="width: 100px;" name="ac_new_1_311" type="submit"> <input value="Copy" style="width: 100px;" name="ac_copy_1_312" type="submit"> </td> </tr> </tbody></table> <input name="[EMAIL PROTECTED]" value="0%3A1%3A1" type="hidden"><input name="[EMAIL PROTECTED]" value="0%3A1%3A2" type="hidden"><input name="[EMAIL PROTECTED]" value="0%3A1%3A3" type="hidden"><input name="[EMAIL PROTECTED]" value="0%3A1%3A4" type="hidden"> </form> <script language="JavaScript1.2"> var visible = false; /** * Toggle Visibility for the input layer * * @param layerName the value of the ID attribute of the DIV element */ function toggleVis(layerName) { if (visible) { toggleVisibility(layerName,'hidden','hidden','hidden'); } else { toggleVisibility(layerName,'show','visible','visible'); } visible = !visible; } /** * Toggle Layer Visibility * * @author İEddie Traversa (nirvana.media3.net) */ function toggleVisibility(id, NNtype, IEtype, WC3type) { if (document.getElementById) { eval("document.getElementById(id).style.visibility = \"" + WC3type + "\""); } else { if (document.layers) { document.layers[id].visibility = NNtype; } else { if (document.all) { eval("document.all." + id + ".style.visibility = \"" + IEtype + "\""); } } } } </script> <br><br> <a href="javascript:void(0);" onclick="toggleVis('layer1');">HTTP debug</a> <div id="layer1" style="visibility: hidden;"> <table border="0" width="100%"> <tbody><tr> <td> <pre>HTTP Snooper Servlet Request URL: http://localhost:8080/ivanstore/tests/ivanCustomerJSTL_Bean.jsp Request Info: Request Method: GET Request URI: /ivanstore/tests/ivanCustomerJSTL_Bean.jsp Request Protocol: HTTP/1.1 Servlet Path: /tests/ivanCustomerJSTL_Bean.jsp Path Info: null Path Translated: null Content Length: -1 Content Type: null QueryString: null Server Name: localhost Server Port: 8080 Remote User: null Remote Host: 127.0.0.1 Remote Address: 127.0.0.1 Authentication Scheme: null Request Headers: host: localhost:8080 user-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040702 Firefox/0.9.1 accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 accept-language: en-us,en;q=0.5 accept-encoding: gzip,deflate accept-charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 keep-alive: 300 connection: keep-alive referer: http://localhost:8080/ivanstore/tests/ cookie: JSESSIONID=D8A72D7EA0FD21736827A2DD76FA6659 cache-control: max-age=0 </pre> </td> </tr> </tbody></table> </div> <!-- Body end --> </body></html> ------------------------------------------------------------ p.s. Sorry for this "long" message. ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com _______________________________________________ DbForms Mailing List http://www.wap-force.net/dbforms