在做项目时,有时会碰到一个页面跳转到另外一个明细页面,而且这个明细页面全部由一些弹性域字段组成的,下面是使用co代码动态创建出来的符合这种需求的明细页面,并且可以动态创建多个表格 /*===========================================================================+ | Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA | | All rights reserved. | +===========================================================================+ | HISTORY | +===========================================================================*/ package cux.oracle.apps.pa.statusreport.webui; import oracle.apps.fnd.common.VersionInfo; import oracle.apps.fnd.framework.webui.OAControllerImpl; import oracle.apps.fnd.framework.webui.OAPageContext; import oracle.apps.fnd.framework.webui.beans.OAWebBean; import oracle.apps.fnd.framework.OAApplicationModule; import oracle.apps.fnd.framework.OAViewObject; import oracle.apps.fnd.framework.server.OADBTransaction; import oracle.apps.fnd.framework.webui.beans.table.OATableBean; import oracle.apps.fnd.framework.webui.beans.OADescriptiveFlexBean; import oracle.apps.fnd.framework.webui.beans.layout.OASpacerBean; import oracle.apps.fnd.framework.webui.OAWebBeanConstants; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; /** * Controller for ... */ public class CuxReportDetailCO extends OAControllerImpl { public static final String RCS_ID = "$Header$"; public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion(RCS_ID, "%packagename%"); /** * Layout and page setup logic for a region. * @param pageContext the current OA page context * @param webBean the web bean corresponding to the region */ public void processRequest(OAPageContext pageContext, OAWebBean webBean) { super.processRequest(pageContext, webBean); String versionId = pageContext.getParameter("versionId"); String pageId = pageContext.getParameter("pageId"); renderDescFlex(pageContext, webBean, versionId, pageId); } /** * Procedure to handle form submissions for form elements in * a region. * @param pageContext the current OA page context * @param webBean the web bean corresponding to the region */ public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { super.processFormRequest(pageContext, webBean); } private void renderDescFlex(OAPageContext pageContext, OAWebBean webBean, String versionId, String pageId) { int flexCount = 1; OAApplicationModule am = pageContext.getApplicationModule(webBean); OADBTransaction txn = am.getOADBTransaction(); PreparedStatement ps = null; ResultSet rs = null; String sql = "SELECT pplr.region_source_code,ffc.descriptive_flex_context_name" + " FROM pa_page_layout_regions pplr," + " fnd_descr_flex_contexts_vl ffc" + " WHERE pplr.region_source_type = 'DFF'" + " AND pplr.region_source_code=ffc.descriptive_flex_context_code" + " AND ffc.descriptive_flexfield_name = 'PA_STATUS_REPORT_DESC_FLEX'" + " AND ffc.application_id = 275" + " AND page_id = :1" + " ORDER BY display_order"; try { ps = txn.createPreparedStatement(sql, 1); ps.setString(1, pageId); rs = ps.executeQuery(); while (rs.next()) { String regionSourceCode = rs.getString(1); String flexContextName = rs.getString(2); String voName = "DffVO" + flexCount; OAViewObject vo = (OAViewObject)am.findViewObject(voName); if (vo == null) { vo = (OAViewObject)am.createViewObject(voName, "cux.oracle.apps.pa.statusreport.server.ReportDetailVO"); } vo.setWhereClause(null); vo.setWhereClauseParams(null); vo.setWhereClause(" version_id=:1 AND region_code=:2"); vo.setWhereClauseParam(0, versionId); vo.setWhereClauseParam(1, regionSourceCode); vo.executeQuery(); int rowCount = vo.getRowCount(); OATableBean tableBean = (OATableBean)createWebBean(pageContext, TABLE_BEAN, null, "ResultTable" + flexCount); tableBean.setText(flexContextName); tableBean.setWidth("100%"); webBean.addIndexedChild(tableBean); tableBean.setNumberOfRowsDisplayed(rowCount); OADescriptiveFlexBean descFlex = (OADescriptiveFlexBean)createWebBean(pageContext, DESCRIPTIVE_FLEX_BEAN, null, "DescFF" + flexCount); descFlex.setAttributeValue(OAWebBeanConstants.VIEW_USAGE_NAME, voName); descFlex.setAttributeValue(OAWebBeanConstants.FLEXFIELD_APPLICATION_SHORT_NAME, "PA"); descFlex.setAttributeValue(OAWebBeanConstants.REGION_APPLICATION_ID, new Integer(275)); descFlex.setAttributeValue(OAWebBeanConstants.FLEXFIELD_NAME, "PA_STATUS_REPORT_DESC_FLEX"); descFlex.setFlexContextCode(pageContext, regionSourceCode); descFlex.setContextListRendered(false); descFlex.setReadOnly(true); tableBean.addIndexedChild(descFlex); OASpacerBean spacerBean = (OASpacerBean)createWebBean(pageContext, SPACER_BEAN, null, "SpaceBean" + flexCount); spacerBean.setHeight("15"); webBean.addIndexedChild(spacerBean); flexCount++; } rs.close(); ps.close(); } catch (SQLException se) { } } }