📄 queryresult.java
字号:
/**
*
*/
package pagecode.queryResult;
import pagecode.PageCodeBase;
import java.util.List;
import com.ibm.websphere.sdo.access.connections.ConnectionManager;
import com.ibm.websphere.sdo.mediator.jdbc.ConnectionWrapperFactory;
import com.ibm.websphere.sdo.mediator.jdbc.ConnectionWrapper;
import com.ibm.websphere.sdo.mediator.JDBCMediator;
import com.ibm.websphere.sdo.mediator.exception.MediatorException;
import com.ibm.websphere.sdo.mediator.jdbc.JDBCMediatorFactory;
import commonj.sdo.DataObject;
import java.sql.Connection;
import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlSelectOneMenu;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.component.UIColumn;
import javax.faces.component.html.HtmlOutputText;
import javax.faces.component.html.HtmlCommandLink;
import javax.faces.event.ValueChangeEvent;
/**
* @author nan
*
*/
public class QueryResult extends PageCodeBase {
private static final String SDOConnection_name = "JSFandSDO_Con";
private ConnectionWrapper SDOConnectionWrapper;
protected DataObject viewFullCatalogParameters;
protected JDBCMediator viewFullCatalogMediator;
private static final String viewFullCatalog_metadataFileName = "/WEB-INF/wdo/viewFullCatalog.xml";
protected static final String[] viewFullCatalogArgNames = {};
protected static final String[] viewFullCatalogArgValues = {};
private static final int viewFullCatalogTargetPageSize = -1;
protected List viewFullCatalog;
protected DataObject productSearchParameters;
protected JDBCMediator productSearchMediator;
private static final String productSearch_metadataFileName = "/WEB-INF/wdo/productSearch.xml";
protected static final String[] productSearchArgNames = { "requestScopesearchBy" };
protected static final String[] productSearchArgValues = { "#{requestScope.searchBy}" };
private static final int productSearchTargetPageSize = -1;
protected List productSearch;
protected HtmlForm form1;
protected HtmlSelectOneMenu menu1;
protected HtmlDataTable table2;
protected UIColumn column6;
protected HtmlOutputText text13;
protected HtmlOutputText text15;
protected HtmlOutputText text17;
protected HtmlOutputText text19;
protected HtmlOutputText text21;
protected HtmlDataTable table1;
protected UIColumn column1;
protected HtmlOutputText text2;
protected HtmlOutputText text4;
protected HtmlOutputText text6;
protected HtmlOutputText text8;
protected HtmlOutputText text10;
protected HtmlOutputText text26;
protected HtmlOutputText text14;
protected UIColumn column7;
protected HtmlOutputText text16;
protected UIColumn column8;
protected HtmlOutputText text18;
protected UIColumn column9;
protected HtmlOutputText text20;
protected UIColumn column10;
protected HtmlOutputText text22;
protected HtmlOutputText text3;
protected UIColumn column2;
protected HtmlOutputText text5;
protected UIColumn column3;
protected HtmlOutputText text7;
protected UIColumn column4;
protected HtmlOutputText text9;
protected UIColumn column5;
protected HtmlOutputText text11;
protected HtmlCommandLink link3;
protected ConnectionWrapper getSDOConnectionWrapper() {
if (SDOConnectionWrapper == null) {
try {
Connection con = ConnectionManager
.createJDBCConnection(SDOConnection_name);
SDOConnectionWrapper = ConnectionWrapperFactory.soleInstance
.createConnectionWrapper(con);
} catch (Throwable e) {
logException(e);
}
}
return SDOConnectionWrapper;
}
/**
* @action id=viewFullCatalog
*/
public String doViewFullCatalogUpdateAction() {
try {
getViewFullCatalogMediator().applyChanges(
getRootDataObject(getViewFullCatalog()));
} catch (Throwable e) {
logException(e);
} finally {
try {
if (SDOConnectionWrapper != null) {
SDOConnectionWrapper.getConnection().close();
SDOConnectionWrapper = null;
}
} catch (Throwable e1) {
logException(e1);
}
if (viewFullCatalogMediator != null) {
viewFullCatalogMediator.setConnectionWrapper(null);
}
}
return "";
}
/**
* @paramBean id=viewFullCatalog
*/
public DataObject getViewFullCatalogParameters() {
if (viewFullCatalogParameters == null) {
try {
viewFullCatalogParameters = getViewFullCatalogMediator()
.getParameterDataObject();
} catch (MediatorException e) {
logException(e);
}
}
return viewFullCatalogParameters;
}
protected JDBCMediator getViewFullCatalogMediator() {
if (viewFullCatalogMediator == null) {
try {
viewFullCatalogMediator = JDBCMediatorFactory.soleInstance
.createMediator(
getResourceInputStream(viewFullCatalog_metadataFileName),
getSDOConnectionWrapper());
initSchema(getRealPath(viewFullCatalog_metadataFileName),
viewFullCatalogMediator.getSchema());
} catch (Throwable e) {
logException(e);
}
} else {
viewFullCatalogMediator
.setConnectionWrapper(getSDOConnectionWrapper());
}
return viewFullCatalogMediator;
}
/**
* @action id=viewFullCatalog
*/
public String doViewFullCatalogFetchAction() {
try {
resolveParams(getViewFullCatalogParameters(),
viewFullCatalogArgNames, viewFullCatalogArgValues,
"viewFullCatalog_params_cache");
DataObject graph = getViewFullCatalogMediator().getGraph(
getViewFullCatalogParameters());
viewFullCatalog = graph.getList(0);
} catch (Throwable e) {
logException(e);
} finally {
try {
if (SDOConnectionWrapper != null) {
SDOConnectionWrapper.getConnection().close();
SDOConnectionWrapper = null;
}
} catch (Throwable e1) {
logException(e1);
}
if (viewFullCatalogMediator != null) {
viewFullCatalogMediator.setConnectionWrapper(null);
}
}
return "";
}
/**
* @mediatorFactory com.ibm.etools.sdo.rdb.datahandlers.RelationalDataFactory
* @mediatorProperties metadataFileName=/WEB-INF/wdo/viewFullCatalog.xml
* @methodEntry id=viewFullCatalog/paramBean=viewFullCatalog/action=viewFullCatalog
* @action FILL
*/
public List getViewFullCatalog() {
if (viewFullCatalog == null) {
doViewFullCatalogFetchAction();
}
return viewFullCatalog;
}
/**
* @action id=productSearch
*/
public String doProductSearchUpdateAction() {
try {
getProductSearchMediator().applyChanges(
getRootDataObject(getProductSearch()));
} catch (Throwable e) {
logException(e);
} finally {
try {
if (SDOConnectionWrapper != null) {
SDOConnectionWrapper.getConnection().close();
SDOConnectionWrapper = null;
}
} catch (Throwable e1) {
logException(e1);
}
if (productSearchMediator != null) {
productSearchMediator.setConnectionWrapper(null);
}
}
return "";
}
/**
* @paramBean id=productSearch
*/
public DataObject getProductSearchParameters() {
if (productSearchParameters == null) {
try {
productSearchParameters = getProductSearchMediator()
.getParameterDataObject();
} catch (MediatorException e) {
logException(e);
}
}
return productSearchParameters;
}
protected JDBCMediator getProductSearchMediator() {
if (productSearchMediator == null) {
try {
productSearchMediator = JDBCMediatorFactory.soleInstance
.createMediator(
getResourceInputStream(productSearch_metadataFileName),
getSDOConnectionWrapper());
initSchema(getRealPath(productSearch_metadataFileName),
productSearchMediator.getSchema());
} catch (Throwable e) {
logException(e);
}
} else {
productSearchMediator
.setConnectionWrapper(getSDOConnectionWrapper());
}
return productSearchMediator;
}
/**
* @action id=productSearch
*/
public String doProductSearchFetchAction() {
try {
resolveParams(getProductSearchParameters(), productSearchArgNames,
productSearchArgValues, "productSearch_params_cache");
DataObject graph = getProductSearchMediator().getGraph(
getProductSearchParameters());
productSearch = graph.getList(0);
} catch (Throwable e) {
logException(e);
} finally {
try {
if (SDOConnectionWrapper != null) {
SDOConnectionWrapper.getConnection().close();
SDOConnectionWrapper = null;
}
} catch (Throwable e1) {
logException(e1);
}
if (productSearchMediator != null) {
productSearchMediator.setConnectionWrapper(null);
}
}
return "";
}
/**
* @mediatorFactory com.ibm.etools.sdo.rdb.datahandlers.RelationalDataFactory
* @mediatorProperties metadataFileName=/WEB-INF/wdo/productSearch.xml
* @methodEntry id=productSearch/paramBean=productSearch/action=productSearch
* @action FILL
*/
public List getProductSearch() {
if (productSearch == null) {
doProductSearchFetchAction();
}
return productSearch;
}
protected HtmlForm getForm1() {
if (form1 == null) {
form1 = (HtmlForm) findComponentInRoot("form1");
}
return form1;
}
protected HtmlSelectOneMenu getMenu1() {
if (menu1 == null) {
menu1 = (HtmlSelectOneMenu) findComponentInRoot("menu1");
}
return menu1;
}
protected HtmlDataTable getTable2() {
if (table2 == null) {
table2 = (HtmlDataTable) findComponentInRoot("table2");
}
return table2;
}
protected UIColumn getColumn6() {
if (column6 == null) {
column6 = (UIColumn) findComponentInRoot("column6");
}
return column6;
}
protected HtmlOutputText getText13() {
if (text13 == null) {
text13 = (HtmlOutputText) findComponentInRoot("text13");
}
return text13;
}
protected HtmlOutputText getText15() {
if (text15 == null) {
text15 = (HtmlOutputText) findComponentInRoot("text15");
}
return text15;
}
protected HtmlOutputText getText17() {
if (text17 == null) {
text17 = (HtmlOutputText) findComponentInRoot("text17");
}
return text17;
}
protected HtmlOutputText getText19() {
if (text19 == null) {
text19 = (HtmlOutputText) findComponentInRoot("text19");
}
return text19;
}
protected HtmlOutputText getText21() {
if (text21 == null) {
text21 = (HtmlOutputText) findComponentInRoot("text21");
}
return text21;
}
protected HtmlDataTable getTable1() {
if (table1 == null) {
table1 = (HtmlDataTable) findComponentInRoot("table1");
}
return table1;
}
protected UIColumn getColumn1() {
if (column1 == null) {
column1 = (UIColumn) findComponentInRoot("column1");
}
return column1;
}
protected HtmlOutputText getText2() {
if (text2 == null) {
text2 = (HtmlOutputText) findComponentInRoot("text2");
}
return text2;
}
protected HtmlOutputText getText4() {
if (text4 == null) {
text4 = (HtmlOutputText) findComponentInRoot("text4");
}
return text4;
}
protected HtmlOutputText getText6() {
if (text6 == null) {
text6 = (HtmlOutputText) findComponentInRoot("text6");
}
return text6;
}
protected HtmlOutputText getText8() {
if (text8 == null) {
text8 = (HtmlOutputText) findComponentInRoot("text8");
}
return text8;
}
protected HtmlOutputText getText10() {
if (text10 == null) {
text10 = (HtmlOutputText) findComponentInRoot("text10");
}
return text10;
}
protected HtmlOutputText getText26() {
if (text26 == null) {
text26 = (HtmlOutputText) findComponentInRoot("text26");
}
return text26;
}
protected HtmlOutputText getText14() {
if (text14 == null) {
text14 = (HtmlOutputText) findComponentInRoot("text14");
}
return text14;
}
protected UIColumn getColumn7() {
if (column7 == null) {
column7 = (UIColumn) findComponentInRoot("column7");
}
return column7;
}
protected HtmlOutputText getText16() {
if (text16 == null) {
text16 = (HtmlOutputText) findComponentInRoot("text16");
}
return text16;
}
protected UIColumn getColumn8() {
if (column8 == null) {
column8 = (UIColumn) findComponentInRoot("column8");
}
return column8;
}
protected HtmlOutputText getText18() {
if (text18 == null) {
text18 = (HtmlOutputText) findComponentInRoot("text18");
}
return text18;
}
protected UIColumn getColumn9() {
if (column9 == null) {
column9 = (UIColumn) findComponentInRoot("column9");
}
return column9;
}
protected HtmlOutputText getText20() {
if (text20 == null) {
text20 = (HtmlOutputText) findComponentInRoot("text20");
}
return text20;
}
protected UIColumn getColumn10() {
if (column10 == null) {
column10 = (UIColumn) findComponentInRoot("column10");
}
return column10;
}
protected HtmlOutputText getText22() {
if (text22 == null) {
text22 = (HtmlOutputText) findComponentInRoot("text22");
}
return text22;
}
protected HtmlOutputText getText3() {
if (text3 == null) {
text3 = (HtmlOutputText) findComponentInRoot("text3");
}
return text3;
}
protected UIColumn getColumn2() {
if (column2 == null) {
column2 = (UIColumn) findComponentInRoot("column2");
}
return column2;
}
protected HtmlOutputText getText5() {
if (text5 == null) {
text5 = (HtmlOutputText) findComponentInRoot("text5");
}
return text5;
}
protected UIColumn getColumn3() {
if (column3 == null) {
column3 = (UIColumn) findComponentInRoot("column3");
}
return column3;
}
protected HtmlOutputText getText7() {
if (text7 == null) {
text7 = (HtmlOutputText) findComponentInRoot("text7");
}
return text7;
}
protected UIColumn getColumn4() {
if (column4 == null) {
column4 = (UIColumn) findComponentInRoot("column4");
}
return column4;
}
protected HtmlOutputText getText9() {
if (text9 == null) {
text9 = (HtmlOutputText) findComponentInRoot("text9");
}
return text9;
}
protected UIColumn getColumn5() {
if (column5 == null) {
column5 = (UIColumn) findComponentInRoot("column5");
}
return column5;
}
protected HtmlOutputText getText11() {
if (text11 == null) {
text11 = (HtmlOutputText) findComponentInRoot("text11");
}
return text11;
}
protected HtmlCommandLink getLink3() {
if (link3 == null) {
link3 = (HtmlCommandLink) findComponentInRoot("link3");
}
return link3;
}
public void handleMenu1ValueChange(ValueChangeEvent valueChangedEvent) {
// Note, valueChangeEvent contains new and old values
// get the new value of Combo Box component and place into a request scope variable.
String val = (String)valueChangedEvent.getNewValue();
getRequestScope().put("searchBy", val);
// forces a new retrieve from the database
productSearch = null;
getProductSearch();
// renders the table
getTable1().setRendered(true);
getText26().setRendered(true);
getLink3().setRendered(true);
}
// closes the filtered Data Table
public String doLink3Action() {
// Type Java code that runs when the component is clicked
getTable1().setRendered(false);
getText26().setRendered(false);
getLink3().setRendered(false);
return "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -