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

📄 commandlinkresult.java

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

import pagecode.PageCodeBase;
import commonj.sdo.DataObject;
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 java.sql.Connection;
import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlOutputText;
import javax.faces.component.html.HtmlCommandLink;

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

	private static final String SDOConnection_name = "JSFandSDO_Con";
	private ConnectionWrapper SDOConnectionWrapper;
	protected DataObject productDetailsParameters;
	protected JDBCMediator productDetailsMediator;
	private static final String productDetails_metadataFileName = "/WEB-INF/wdo/productDetails.xml";
	protected static final String[] productDetailsArgNames = { "paramID" };
	protected static final String[] productDetailsArgValues = { "#{param.ID}" };
	protected DataObject productDetails;
	protected HtmlForm form1;
	protected HtmlOutputText text1;
	protected HtmlOutputText text2;
	protected HtmlOutputText text3;
	protected HtmlOutputText text4;
	protected HtmlOutputText text5;
	protected HtmlOutputText text8;
	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=productDetails
	 */
	public String doProductDetailsUpdateAction() {
		try {
			getProductDetailsMediator().applyChanges(
					getRootDataObject(getProductDetails()));
		} catch (Throwable e) {
			logException(e);
		} finally {
			try {
				if (SDOConnectionWrapper != null) {
					SDOConnectionWrapper.getConnection().close();
					SDOConnectionWrapper = null;
				}
			} catch (Throwable e1) {
				logException(e1);
			}
			if (productDetailsMediator != null) {
				productDetailsMediator.setConnectionWrapper(null);
			}
		}
		return "";
	}
	/** 
	 * @action id=productDetails
	 */
	public String doProductDetailsDeleteAction() {
		try {
			DataObject root = getRootDataObject(getProductDetails());
			getProductDetails().delete();
			getProductDetailsMediator().applyChanges(root);
		} catch (Throwable e) {
			logException(e);
		} finally {
			try {
				if (SDOConnectionWrapper != null) {
					SDOConnectionWrapper.getConnection().close();
					SDOConnectionWrapper = null;
				}
			} catch (Throwable e1) {
				logException(e1);
			}
			if (productDetailsMediator != null) {
				productDetailsMediator.setConnectionWrapper(null);
			}
		}
		return "";
	}
	/** 
	 * @paramBean id=productDetails
	 */
	public DataObject getProductDetailsParameters() {
		if (productDetailsParameters == null) {
			try {
				productDetailsParameters = getProductDetailsMediator()
						.getParameterDataObject();
			} catch (MediatorException e) {
				logException(e);
			}
		}
		return productDetailsParameters;
	}
	protected JDBCMediator getProductDetailsMediator() {
		if (productDetailsMediator == null) {
			try {
				productDetailsMediator = JDBCMediatorFactory.soleInstance
						.createMediator(
								getResourceInputStream(productDetails_metadataFileName),
								getSDOConnectionWrapper());
				initSchema(getRealPath(productDetails_metadataFileName),
						productDetailsMediator.getSchema());
			} catch (Throwable e) {
				logException(e);
			}
		} else {
			productDetailsMediator
					.setConnectionWrapper(getSDOConnectionWrapper());
		}
		return productDetailsMediator;
	}
	/** 
	 * This method was created in order to retrieve existing data.  To create new data:
	 *   DataObject graph = getProductDetailsMediator().getEmptyGraph();
	 *   productDetails = graph.createDataObject(0);  
	 *
	 * @action id=productDetails
	 */
	public String doProductDetailsFetchAction() {
		try {
			resolveParams(getProductDetailsParameters(),
					productDetailsArgNames, productDetailsArgValues,
					"productDetails_params_cache");
			DataObject graph = getProductDetailsMediator().getGraph(
					getProductDetailsParameters());
			productDetails = (DataObject) graph.getList(0).get(0);
		} catch (Throwable e) {
			logException(e);
		} finally {
			try {
				if (SDOConnectionWrapper != null) {
					SDOConnectionWrapper.getConnection().close();
					SDOConnectionWrapper = null;
				}
			} catch (Throwable e1) {
				logException(e1);
			}
			if (productDetailsMediator != null) {
				productDetailsMediator.setConnectionWrapper(null);
			}
		}
		return "";
	}
	/** 
	 * @mediatorFactory com.ibm.etools.sdo.rdb.datahandlers.RelationalDataFactory
	 * @mediatorProperties metadataFileName=/WEB-INF/wdo/productDetails.xml
	 * @methodEntry id=productDetails/paramBean=productDetails/action=productDetails
	 * @action FILL
	 */
	public DataObject getProductDetails() {
		if (productDetails == null) {
			doProductDetailsFetchAction();
		}
		return productDetails;
	}
	protected HtmlForm getForm1() {
		if (form1 == null) {
			form1 = (HtmlForm) findComponentInRoot("form1");
		}
		return form1;
	}
	protected HtmlOutputText getText1() {
		if (text1 == null) {
			text1 = (HtmlOutputText) findComponentInRoot("text1");
		}
		return text1;
	}
	protected HtmlOutputText getText2() {
		if (text2 == null) {
			text2 = (HtmlOutputText) findComponentInRoot("text2");
		}
		return text2;
	}
	protected HtmlOutputText getText3() {
		if (text3 == null) {
			text3 = (HtmlOutputText) findComponentInRoot("text3");
		}
		return text3;
	}
	protected HtmlOutputText getText4() {
		if (text4 == null) {
			text4 = (HtmlOutputText) findComponentInRoot("text4");
		}
		return text4;
	}
	protected HtmlOutputText getText5() {
		if (text5 == null) {
			text5 = (HtmlOutputText) findComponentInRoot("text5");
		}
		return text5;
	}
	protected HtmlOutputText getText8() {
		if (text8 == null) {
			text8 = (HtmlOutputText) findComponentInRoot("text8");
		}
		return text8;
	}
	protected HtmlCommandLink getLink3() {
		if (link3 == null) {
			link3 = (HtmlCommandLink) findComponentInRoot("link3");
		}
		return link3;
	}
	
	public String doLink3Action() {
		return "new";
	}

}

⌨️ 快捷键说明

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