Author: craigmcc Date: Sat Feb 4 18:11:17 2006 New Revision: 374957 URL: http://svn.apache.org/viewcvs?rev=374957&view=rev Log: Clean up the debugging print statements, and add a bit more data to the demo data source.
Removed: struts/shale/trunk/sql-browser/src/web/messages.jspf struts/shale/trunk/sql-browser/src/web/welcome.jsp Modified: struts/shale/trunk/sql-browser/src/java/org/apache/shale/examples/sqlbrowser/Listener.java struts/shale/trunk/sql-browser/src/java/org/apache/shale/examples/sqlbrowser/Query.java struts/shale/trunk/sql-browser/src/web/WEB-INF/faces-config.xml struts/shale/trunk/sql-browser/src/web/query.jsp Modified: struts/shale/trunk/sql-browser/src/java/org/apache/shale/examples/sqlbrowser/Listener.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/sql-browser/src/java/org/apache/shale/examples/sqlbrowser/Listener.java?rev=374957&r1=374956&r2=374957&view=diff ============================================================================== --- struts/shale/trunk/sql-browser/src/java/org/apache/shale/examples/sqlbrowser/Listener.java (original) +++ struts/shale/trunk/sql-browser/src/java/org/apache/shale/examples/sqlbrowser/Listener.java Sat Feb 4 18:11:17 2006 @@ -137,11 +137,37 @@ "state varchar(2)" + ")", "insert into zip_codes (zip_code, city, state) " + - "values ('97062', 'Tualatin', 'OR')", + "values ('97005', 'Beaverton', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97006', 'Beaverton', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97007', 'Beaverton', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97008', 'Beaverton', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97075', 'Beaverton', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97076', 'Beaverton', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97077', 'Beaverton', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97078', 'Beaverton', 'OR')", "insert into zip_codes (zip_code, city, state) " + "values ('97034', 'Lake Oswego', 'OR')", "insert into zip_codes (zip_code, city, state) " + "values ('97035', 'Lake Oswego', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97062', 'Tualatin', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97068', 'West Linn', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97140', 'Sherwood', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97223', 'Tigard', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97224', 'Tigard', 'OR')", + "insert into zip_codes (zip_code, city, state) " + + "values ('97281', 'Tigard', 'OR')", }; Modified: struts/shale/trunk/sql-browser/src/java/org/apache/shale/examples/sqlbrowser/Query.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/sql-browser/src/java/org/apache/shale/examples/sqlbrowser/Query.java?rev=374957&r1=374956&r2=374957&view=diff ============================================================================== --- struts/shale/trunk/sql-browser/src/java/org/apache/shale/examples/sqlbrowser/Query.java (original) +++ struts/shale/trunk/sql-browser/src/java/org/apache/shale/examples/sqlbrowser/Query.java Sat Feb 4 18:11:17 2006 @@ -23,7 +23,6 @@ import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.sql.SQLException; -import java.util.Iterator; import java.util.List; import javax.faces.application.FacesMessage; import javax.faces.component.UIColumn; @@ -153,7 +152,6 @@ } - // ------------------------------------------------- View Controller Methods @@ -174,36 +172,25 @@ // Look up the appropriate data source // FIXME - add JNDI lookup support for non-internal - System.err.println("prerender(): Acquire DataSource and Connection"); DataSource ds = (DataSource) context.getExternalContext().getApplicationMap().get(Listener.INTERNAL_DATA_SOURCE); conn = ds.getConnection(); // Execute the requested query - System.err.println("prerender(): Prepare and execute query"); stmt = conn.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = stmt.executeQuery(); - // Acquire the result set metadata - System.err.println("prerender(): Acquiring result set metadata"); - ResultSetMetaData rsmd = rs.getMetaData(); - System.err.println("prerender(): There are " + rsmd.getColumnCount() + " columns"); - // Set up the data model for our result set - System.err.println("prerender(): Wiring up our data model"); + ResultSetMetaData rsmd = rs.getMetaData(); resultSetDataModel = new ResultSetDataModel(rs); - System.err.println("prerender(): There are " + resultSetDataModel.getRowCount() + " rows"); results.setFirst(0); - results.setRows(10); // Dynamically create columns as needed - System.err.println("prerender(): Dynamically creating columns"); - List children = results.getChildren(); + List<Object> children = results.getChildren(); children.clear(); for (int i = 1; i <= rsmd.getColumnCount(); i++) { // SQL stuff is one-relative - System.err.println("prerender(): Adding column '" + rsmd.getColumnName(i) + "'"); UIColumn column = new UIColumn(); column.setId("column" + i); children.add(column); @@ -218,12 +205,11 @@ data.setId("data" + i); data.setValueBinding("value", context.getApplication().createValueBinding("#{current['" + rsmd.getColumnName(i) + "']}")); - System.err.println("prerender(): Value binding is " + data.getValueBinding("value").getExpressionString()); column.getChildren().add(data); } - // Position to first row to ensure that we can - System.err.println("prerender(): Check positionability of initial rows"); +/* + // Position to first few rows to ensure that we can for (int i = 0; i < 10; i++) { resultSetDataModel.setRowIndex(i); System.err.println("prerender(): Row " + i + " exists? " + resultSetDataModel.isRowAvailable()); @@ -232,15 +218,13 @@ } System.err.println("prerender(): Row " + i + " data: " + resultSetDataModel.getRowData()); } +*/ // Set the completed flag to indicate that we should display the results - System.err.println("prerender(): Marking request as completed"); completed = true; } catch (Exception e) { - System.err.println("prerender(): Encountered Exception"); - e.printStackTrace(System.err); context.addMessage (null, new FacesMessage("Exception executing this query: " + e)); while (e != null) { @@ -266,58 +250,28 @@ @Destroy public void destroy() { - System.err.println("destroy(): Clean up after rendering completed"); - System.err.println("destroy(): There were " + resultSetDataModel.getRowCount() + " rows"); - // Close the result set (if any) that we opened if (rs != null) { try { - System.err.println("destroy(): Closing result set"); rs.close(); } catch (SQLException e) { - System.err.println("destroy(): Exception closing result set"); - e.printStackTrace(System.err); } } // Close the statement (if any) that we opened if (stmt != null) { try { - System.err.println("destroy(): Closing statement"); stmt.close(); } catch (SQLException e) { - System.err.println("destroy(): Exception closing statement"); - e.printStackTrace(System.err); } } // Close the connection (if any) that we opened if (conn != null) { try { - System.err.println("destroy(): Closing connection"); conn.close(); } catch (SQLException e) { - System.err.println("destroy(): Exception closing connection"); - e.printStackTrace(System.err); } - } - - System.err.println("destroy(): Walk component tree for the table"); - walk(FacesContext.getCurrentInstance(), results, 0); - System.err.println("destroy(): All done"); - - } - - - private void walk(FacesContext context, UIComponent component, int indent) { - - for (int i = 0; i < indent; i++) { - System.err.print(" "); - } - System.err.println("clientId=" + component.getClientId(context) + ", type=" + component.getClass()); - Iterator kids = component.getChildren().iterator(); - while (kids.hasNext()) { - walk(context, (UIComponent) kids.next(), indent + 2); } } Modified: struts/shale/trunk/sql-browser/src/web/WEB-INF/faces-config.xml URL: http://svn.apache.org/viewcvs/struts/shale/trunk/sql-browser/src/web/WEB-INF/faces-config.xml?rev=374957&r1=374956&r2=374957&view=diff ============================================================================== --- struts/shale/trunk/sql-browser/src/web/WEB-INF/faces-config.xml (original) +++ struts/shale/trunk/sql-browser/src/web/WEB-INF/faces-config.xml Sat Feb 4 18:11:17 2006 @@ -26,60 +26,7 @@ <faces-config> + <!-- ========== Look Ma, no hands! ========== --> - <!-- ========================= Locale Management ========================= --> - - - <!-- Uncomment the following element and configure the default and - supported locales for your application --> -<!-- - <application> - <locale-config> - <default-locale>en</default-locale> - <supported-locale>en</supported-locale> - <supported-locale>fr</supported-locale> - <supported-locale>de</supported-locale> - <supported-locale>es</supported-locale> - </locale-config> - </application> ---> - - - <!-- Uncomment the following element (after fixing the package name as needed) - if your localized message bundle contains replacements for the standard - converter or validator error messages. --> -<!-- - <application> - <message-bundle>org.apache.shale.blank.Bundle</message-bundle> - </application> ---> - - - <!-- ============================== /welcome.jsp ========================= --> - - - <!-- - <managed-bean> - <managed-bean-name>welcome</managed-bean-name> - <managed-bean-class>org.apache.shale.blank.WelcomeBean</managed-bean-class> - <managed-bean-scope>request</managed-bean-scope> - </managed-bean> - --> - - <!-- This simple example has no navigation rules, but if it did they could - go right here. JavaServer Faces lets you organize the elements of the - configuration resources in whatever order makes sense. In most cases, - it will be easiest to group the settings related to each individual - page, or group of related pages, together. - --> -<!-- - <navigation-rule> - <from-view-id>/welcome.jsp</from-view-id> - <navigation-case> - <from-outcome>next</from-outcome> - <to-view-id>/nextpage.jsp</to-view-id> - </navigation-case> - </navigation-rule> ---> </faces-config> Modified: struts/shale/trunk/sql-browser/src/web/query.jsp URL: http://svn.apache.org/viewcvs/struts/shale/trunk/sql-browser/src/web/query.jsp?rev=374957&r1=374956&r2=374957&view=diff ============================================================================== --- struts/shale/trunk/sql-browser/src/web/query.jsp (original) +++ struts/shale/trunk/sql-browser/src/web/query.jsp Sat Feb 4 18:11:17 2006 @@ -22,7 +22,6 @@ <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %> <f:view> -<%-- <%@ include file="messages.jspf"%> --%> <html> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]