|
|
发表于 2011/7/22 12:50:02
|
显示全部楼层
今天空下来,做了一下动态生成switcher的代码,
假设SQL文如下:
[tr] [td=21] StringBuffer sbfSQL = new StringBuffer(200);[/td] [/tr]
[tr] [td] // set title in the advancedTable[/td] [/tr]
[tr] [td] sbfSQL.append("SELECT '名' user_name, 'ID' user_id, '開始日' start_date, 'SWITCHER_FLAG' switcher_flag FROM dual ");[/td] [/tr]
[tr] [td] sbfSQL.append("UNION ALL ");[/td] [/tr]
[tr] [td] sbfSQL.append("SELECT fu.user_name, to_char(fu.user_id), to_char(fu.start_date), CASE WHEN fu.user_id > 1180 THEN 'big' ELSE 'small' END FROM fnd_user fu");
CO的processRequest中追加的代码如下
[tr] [td=21] OAAdvancedTableBean tableBean = (OAAdvancedTableBean)webBean.findChildRecursive("region6");[/td] [/tr]
[tr] [td][/td] [/tr]
[tr] [td] // create switcher[/td] [/tr]
[tr] [td] OAColumnBean cb = (OAColumnBean)createWebBean(pageContext, COLUMN_BEAN, null, null);[/td] [/tr]
[tr] [td] tableBean.addIndexedChild(cb);[/td] [/tr]
[tr] [td][/td] [/tr]
[tr] [td] OAMessageStyledTextBean mst = (OAMessageStyledTextBean)createWebBean(pageContext, MESSAGE_STYLED_TEXT_BEAN, null, "big");[/td] [/tr]
[tr] [td] mst.setViewAttributeName("USER_NAME");[/td] [/tr]
[tr] [td][/td] [/tr]
[tr] [td] OAMessageTextInputBean mti = (OAMessageTextInputBean)createWebBean(pageContext, MESSAGE_TEXT_INPUT_BEAN, null, "small");[/td] [/tr]
[tr] [td] mti.setViewAttributeName("USER_NAME");[/td] [/tr]
[tr] [td][/td] [/tr]
[tr] [td] OASwitcherBean switcher = (OASwitcherBean)createWebBean(pageContext, SWITCHER_BEAN, null, null);[/td] [/tr]
[tr] [td] switcher.setViewAttributeName("SWITCHER_FLAG");[/td] [/tr]
[tr] [td] switcher.setNamedChild(mst.getID(), mst);[/td] [/tr]
[tr] [td] switcher.setNamedChild(mti.getID(), mti);[/td] [/tr]
[tr] [td] cb.addIndexedChild(switcher);[/td] [/tr]
[tr] [td][/td] [/tr]
[tr] [td] OASortableHeaderBean shb = (OASortableHeaderBean)createWebBean(pageContext, SORTABLE_HEADER_BEAN, null, null);[/td] [/tr]
[tr] [td] shb.setPrompt("SWITCHER_FLAG");[/td] [/tr]
[tr] [td] cb.setColumnHeader(shb);[/td][/tr]
[/td][/tr]
|
|