Re: custom Table
Hi Thufir, Zachary allready wrote a lot about possible problems with different scopes in jsp, passing the ResultSet this way shouldn't bring up any problem IMHO - as long as the instance is destroyed after the page has rendered (don't know exactly if the reference to a resultset in your instance blocks your database connection as long as the resultset can't get destroyed (but I assume this), so maybe you should consider executing an explicit close() on the resultset). But I didn't understand the first part of your mail: Thufir schrieb: I think that the problem with this class is that setColumnNames and setData aren't really setting attributes. I suppose I should make instance attributes like "header" and "data"? You want to render a table, so you're creating rows for header an data and adding them to the parent table. If you want to alter the table after creation, you could additionally keep the TRs in a list as attributes or something like this. But in difference to swing (or something like this), you're just generating HTML, sending it to the client and the server part is finished. The client renders the html you created and maybe, there well be a click on a link or a form will be submitted, so you're having a new request, you don't get a gui event like in swing. To simulate this behaviour over http, there are technologies like jsf (or some other frameworks like http://wingsframework.org/ what is some more like swing). Greetings, Martin - To unsubscribe, e-mail: ecs-user-unsubscr...@jakarta.apache.org For additional commands, e-mail: ecs-user-h...@jakarta.apache.org
Re: custom Table
There are a few things to know with JSP's and copies of objects in JSP's, when it comes to variables of session and page scopes. A text/ebook like "special edition using Java 2 enterprise edition clarifies this, but it all goes to the fact that a jsp deploys to its servlet engine by being compiled into a servlet class/instance, which is injected and then executed from there. This means that every client web browser run of the jsp is running from THE SAME class of your programmed jsp, though from different server threads and different browser instances though. You need to be careful that each page variable object doesn't conflict with other objects by use of page objects. You will want each to have a local copy of your resultset Object, in each jsp page context, to be a unique object context, and each have all of them concurrently in your jsp, rather than be using dirty references back to your original copy. It should (your resultset object), optmistically, be unbound from your resultSet Object produced by bean/corba/rmi/ejb/whatever object source. In your example, in a situation where each jsp page may alter it's unique resultset object later on, -you may use a managed class/bean/enterprise javaban to correspond to your entire table, to have setResultSet/getResultSet methods. These methods may have somethig like a linkedlist that holds resultset objects (or a complexresultset object of yours, to include an id for each node. This way, you have one managemenet class, and are blind to key objects, and have a manager (Accessible) class. >From hear, each page may the obtain it's own particular pageContext copy of your resultselt object. //** Or, you may use a LinkedList object in an application scope, which of its own, is outside of every page's context. The page that get's a LinkedList from there, the page deals appropriately with it's resultset, and may use the java.util.LinkedList method to update the collection appropriately. the page context. See how ya go, but doen't overlook the reading I suggested, even though your stuck, and it's old! :)
Re: custom Table
On Tue, 24 Feb 2009 14:14:39 +1030, Zachary Mitchell, BCIS wrote: > > I recommend submitting your resultset What did you mean by submitting resultset? I was asking about passing around a resultset. You mean that's "ok"? thanks, Thufir - To unsubscribe, e-mail: ecs-user-unsubscr...@jakarta.apache.org For additional commands, e-mail: ecs-user-h...@jakarta.apache.org
Re: custom Table
There are a few things to do with JSP's and copies of objects in JSP's, when it comes to variables of session and page scopes. A text/ebook like "special edition using Java 2 enterprise edition clarifies this, but it all goes to the fact that a jsp ends by being compiled into a servlet, which is injected and then executed from there. This means that every client run of the jsp is running from THE SAME class of your programmed jsp, though from different execution context instances. You need to be careful that each page variable object doesn't conflict with other objects by use of page objects. You will want each copy of your resultset Object, in each jsp page contextn, to be a unique object context, and have all of them, ins your jsp, be dirty references back to your original copy. It should, optmistically, be unbound from your resultSet Object produced by bean/corba/rmi/ejb/whatever object source. In your example, in a situation where each jsp page may alter it's unique resultset object later on, -you may use a to managelibrary class/bean/enterprise javaban to have setResultSet/getResultSet methods. These methods may have somethig like a linkedlist that holds resultsetl objects (or a complexresultset object of yous, with field int field = 1; with this reflected in get/set function signatures. from hear, each page may the obtain it's own particular pageContext copy of your resultselt object. Or, you may use a linked list approach, getitng/setting methods, on a LinkedList object in an application scope, which of its own, excludes the page context. See how ya go, but doen't overlook the reading I suggested, even though your stuck, and it's old! :) I recommend submitting your resultset - Original Message - From: "Thufir" To: Sent: Tuesday, February 24, 2009 1:23 PM Subject: custom Table I think that the problem with this class is that setColumnNames and setData aren't really setting attributes. I suppose I should make instance attributes like "header" and "data"? (luckily we're moving into JSP soon, but, still...) also, is there a problem with passing ResultSet around to different objects? I read that there's a problem with that. package a00720398.html; //adapted from oreilly sample in ch 16 // Java Servlet Programming, Second Edition // http://oreilly.com/catalog/9780596000400/ import java.sql.*; import org.apache.ecs.html.*; public class ResultSetTable extends Table { private static final boolean isPretty = true; private ResultSet rst = null; ResultSetMetaData rsmd = null; public ResultSetTable() { } public ResultSetTable(ResultSet rst) throws SQLException { this.rst = rst; rsmd = rst.getMetaData(); setBorder(1); setColumnNames(); setData(); } public void setResultSet(ResultSet rst) throws SQLException { this.rst = rst; rsmd = rst.getMetaData(); } private void setColumnNames() throws SQLException { int colCount = rsmd.getColumnCount(); TR tr = new TR(); tr.setPrettyPrint(isPretty); A a = new A(); a.setPrettyPrint(isPretty); a.setHref("/Assignment?crud=D&row=0"); //