⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commandlink.java

📁 IBM RSA下的JSF开发示例
💻 JAVA
字号:
/**
 * 
 */
package pagecode.passData;

import pagecode.PageCodeBase;

import com.ibm.faces.component.html.HtmlOutputLinkEx;
import com.ibm.faces.component.html.HtmlScriptCollector;
import javax.faces.component.html.HtmlForm;
import javax.faces.component.UIColumn;
import javax.faces.component.html.HtmlOutputText;
import javax.faces.component.html.HtmlDataTable;
import javax.faces.component.html.HtmlCommandLink;
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;

/**
 * @author nan
 *
 */
public class CommandLink extends PageCodeBase {

	protected HtmlScriptCollector scriptCollector1;
	protected HtmlForm form1;
	protected UIColumn column4;
	protected HtmlOutputText text7;
	protected HtmlOutputText text1;
	protected HtmlOutputText text3;
	protected HtmlOutputText text5;
	protected HtmlOutputText text6;
	protected HtmlOutputText text11;
	protected HtmlOutputText text12;
	protected HtmlDataTable table1;
	protected HtmlOutputText text8;
	protected UIColumn column1;
	protected HtmlOutputText text2;
	protected UIColumn column2;
	protected HtmlOutputText text4;
	protected UIColumn column3;
	protected HtmlCommandLink link1;
	protected HtmlOutputLinkEx linkEx1;
	protected UIColumn column5;
	private static final String SDOConnection_name = "JSFandSDO_Con";
	private ConnectionWrapper SDOConnectionWrapper;
	protected DataObject productsParameters;
	protected JDBCMediator productsMediator;
	private static final String products_metadataFileName = "/WEB-INF/wdo/products.xml";
	protected static final String[] productsArgNames = {};
	protected static final String[] productsArgValues = {};
	private static final int productsTargetPageSize = -1;
	protected List products;

	protected HtmlScriptCollector getScriptCollector1() {
		if (scriptCollector1 == null) {
			scriptCollector1 = (HtmlScriptCollector) findComponentInRoot("scriptCollector1");
		}
		return scriptCollector1;
	}

	protected HtmlForm getForm1() {
		if (form1 == null) {
			form1 = (HtmlForm) findComponentInRoot("form1");
		}
		return form1;
	}

	protected UIColumn getColumn4() {
		if (column4 == null) {
			column4 = (UIColumn) findComponentInRoot("column4");
		}
		return column4;
	}

	protected HtmlOutputText getText7() {
		if (text7 == null) {
			text7 = (HtmlOutputText) findComponentInRoot("text7");
		}
		return text7;
	}

	protected HtmlOutputText getText1() {
		if (text1 == null) {
			text1 = (HtmlOutputText) findComponentInRoot("text1");
		}
		return text1;
	}

	protected HtmlOutputText getText3() {
		if (text3 == null) {
			text3 = (HtmlOutputText) findComponentInRoot("text3");
		}
		return text3;
	}

	protected HtmlOutputText getText5() {
		if (text5 == null) {
			text5 = (HtmlOutputText) findComponentInRoot("text5");
		}
		return text5;
	}

	protected HtmlOutputText getText6() {
		if (text6 == null) {
			text6 = (HtmlOutputText) findComponentInRoot("text6");
		}
		return text6;
	}

	protected HtmlOutputText getText11() {
		if (text11 == null) {
			text11 = (HtmlOutputText) findComponentInRoot("text11");
		}
		return text11;
	}

	protected HtmlOutputText getText12() {
		if (text12 == null) {
			text12 = (HtmlOutputText) findComponentInRoot("text12");
		}
		return text12;
	}

	protected HtmlDataTable getTable1() {
		if (table1 == null) {
			table1 = (HtmlDataTable) findComponentInRoot("table1");
		}
		return table1;
	}

	protected HtmlOutputText getText8() {
		if (text8 == null) {
			text8 = (HtmlOutputText) findComponentInRoot("text8");
		}
		return text8;
	}

	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 UIColumn getColumn2() {
		if (column2 == null) {
			column2 = (UIColumn) findComponentInRoot("column2");
		}
		return column2;
	}

	protected HtmlOutputText getText4() {
		if (text4 == null) {
			text4 = (HtmlOutputText) findComponentInRoot("text4");
		}
		return text4;
	}

	protected UIColumn getColumn3() {
		if (column3 == null) {
			column3 = (UIColumn) findComponentInRoot("column3");
		}
		return column3;
	}

	protected HtmlCommandLink getLink1() {
		if (link1 == null) {
			link1 = (HtmlCommandLink) findComponentInRoot("link1");
		}
		return link1;
	}

	protected UIColumn getColumn5() {
		if (column5 == null) {
			column5 = (UIColumn) findComponentInRoot("column5");
		}
		return column5;
	}

	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=products
	 */
	public String doProductsUpdateAction() {
		try {
			getProductsMediator()
					.applyChanges(getRootDataObject(getProducts()));
		} catch (Throwable e) {
			logException(e);
		} finally {
			try {
				if (SDOConnectionWrapper != null) {
					SDOConnectionWrapper.getConnection().close();
					SDOConnectionWrapper = null;
				}
			} catch (Throwable e1) {
				logException(e1);
			}
			if (productsMediator != null) {
				productsMediator.setConnectionWrapper(null);
			}
		}
		return "";
	}

	/** 
	 * @paramBean id=products
	 */
	public DataObject getProductsParameters() {
		if (productsParameters == null) {
			try {
				productsParameters = getProductsMediator()
						.getParameterDataObject();
			} catch (MediatorException e) {
				logException(e);
			}
		}
		return productsParameters;
	}

	protected JDBCMediator getProductsMediator() {
		if (productsMediator == null) {
			try {
				productsMediator = JDBCMediatorFactory.soleInstance
						.createMediator(
								getResourceInputStream(products_metadataFileName),
								getSDOConnectionWrapper());
				initSchema(getRealPath(products_metadataFileName),
						productsMediator.getSchema());
			} catch (Throwable e) {
				logException(e);
			}
		} else {
			productsMediator.setConnectionWrapper(getSDOConnectionWrapper());
		}
		return productsMediator;
	}

	/** 
	 * @action id=products
	 */
	public String doProductsFetchAction() {
		try {
			resolveParams(getProductsParameters(), productsArgNames,
					productsArgValues, "products_params_cache");
			DataObject graph = getProductsMediator().getGraph(
					getProductsParameters());
			products = graph.getList(0);
		} catch (Throwable e) {
			logException(e);
		} finally {
			try {
				if (SDOConnectionWrapper != null) {
					SDOConnectionWrapper.getConnection().close();
					SDOConnectionWrapper = null;
				}
			} catch (Throwable e1) {
				logException(e1);
			}
			if (productsMediator != null) {
				productsMediator.setConnectionWrapper(null);
			}
		}
		return "";
	}

	/** 
	 * @mediatorFactory com.ibm.etools.sdo.rdb.datahandlers.RelationalDataFactory
	 * @mediatorProperties metadataFileName=/WEB-INF/wdo/products.xml
	 * @methodEntry id=products/paramBean=products/action=products
	 * @action FILL
	 */
	public List getProducts() {
		if (products == null) {
			doProductsFetchAction();
		}
		return products;
	}
	
	public String doLink1Action() {
		return "next";
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -