public
String commandButton_action()
... {
// Add event code here...
ResultSet rs=null;
try...{
Class.forName("oracle.jdbc.OracleDriver");
String url="jdbc:oracle:thin:@<host>:<port>:<database>";
Connection connection = DriverManager.getConnection(url,
"OE", "<password>");
Statement stmt=connection.createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery((String)inputText1.getValue());
dataTable1.setBorder(5);
dataTable1.setCellpadding("1");
dataTable1.setVar("catalog");
HtmlOutputText headerComponent = new HtmlOutputText();
headerComponent.setValue("CatalogId");
column1.setHeader(headerComponent);
headerComponent = new HtmlOutputText();
headerComponent.setValue("Journal");
column2.setHeader(headerComponent);
headerComponent = new HtmlOutputText();
headerComponent.setValue("Publisher");
column3.setHeader(headerComponent);
headerComponent = new HtmlOutputText();
headerComponent.setValue("Edition");
column4.setHeader(headerComponent);
headerComponent = new HtmlOutputText();
headerComponent.setValue("Title");
column5.setHeader(headerComponent);
headerComponent = new HtmlOutputText();
headerComponent.setValue("Author");
column6.setHeader(headerComponent);
HtmlOutputText column1Text=new HtmlOutputText();
ValueBinding vb =
FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.id}");
column1Text.setValueBinding("value", vb);
column1.getChildren().add(column1Text);
HtmlOutputText column2Text=new HtmlOutputText();
vb =
FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.journal}");
column2Text.setValueBinding("value", vb);
column2.getChildren().add(column2Text);
HtmlOutputText column3Text=new HtmlOutputText();
vb =
FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.publisher}");
column3Text.setValueBinding("value", vb);
column3.getChildren().add(column3Text);
HtmlOutputText column4Text=new HtmlOutputText();
vb =
FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.edition}");
column4Text.setValueBinding("value", vb);
column4.getChildren().add(column4Text);
HtmlOutputText column5Text=new HtmlOutputText();
vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.title}");
column5Text.setValueBinding("value", vb);
column5.getChildren().add(column5Text);
HtmlOutputText column6Text=new HtmlOutputText();
vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.author}");
column6Text.setValueBinding("value", vb);
column6.getChildren().add(column6Text);
ResultSetDataModel dataModel=new ResultSetDataModel();
dataModel.setWrappedData(rs);
dataTable1.setValue(dataModel);
}
catch(SQLException e)...{}
catch(ClassNotFoundException e)...{}
finally...{ rs.close();
stmt.close();
connection.close();
}
return null;
}
... {
// Add event code here...
ResultSet rs=null;
try...{
Class.forName("oracle.jdbc.OracleDriver");
String url="jdbc:oracle:thin:@<host>:<port>:<database>";
Connection connection = DriverManager.getConnection(url,
"OE", "<password>");
Statement stmt=connection.createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery((String)inputText1.getValue());
dataTable1.setBorder(5);
dataTable1.setCellpadding("1");
dataTable1.setVar("catalog");
HtmlOutputText headerComponent = new HtmlOutputText();
headerComponent.setValue("CatalogId");
column1.setHeader(headerComponent);
headerComponent = new HtmlOutputText();
headerComponent.setValue("Journal");
column2.setHeader(headerComponent);
headerComponent = new HtmlOutputText();
headerComponent.setValue("Publisher");
column3.setHeader(headerComponent);
headerComponent = new HtmlOutputText();
headerComponent.setValue("Edition");
column4.setHeader(headerComponent);
headerComponent = new HtmlOutputText();
headerComponent.setValue("Title");
column5.setHeader(headerComponent);
headerComponent = new HtmlOutputText();
headerComponent.setValue("Author");
column6.setHeader(headerComponent);
HtmlOutputText column1Text=new HtmlOutputText();
ValueBinding vb =
FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.id}");
column1Text.setValueBinding("value", vb);
column1.getChildren().add(column1Text);
HtmlOutputText column2Text=new HtmlOutputText();
vb =
FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.journal}");
column2Text.setValueBinding("value", vb);
column2.getChildren().add(column2Text);
HtmlOutputText column3Text=new HtmlOutputText();
vb =
FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.publisher}");
column3Text.setValueBinding("value", vb);
column3.getChildren().add(column3Text);
HtmlOutputText column4Text=new HtmlOutputText();
vb =
FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.edition}");
column4Text.setValueBinding("value", vb);
column4.getChildren().add(column4Text);
HtmlOutputText column5Text=new HtmlOutputText();
vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.title}");
column5Text.setValueBinding("value", vb);
column5.getChildren().add(column5Text);
HtmlOutputText column6Text=new HtmlOutputText();
vb = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{catalog.author}");
column6Text.setValueBinding("value", vb);
column6.getChildren().add(column6Text);
ResultSetDataModel dataModel=new ResultSetDataModel();
dataModel.setWrappedData(rs);
dataTable1.setValue(dataModel);
}
catch(SQLException e)...{}
catch(ClassNotFoundException e)...{}
finally...{ rs.close();
stmt.close();
connection.close();
}
return null;
}