|
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622 。
您需要 登录 才可以下载或查看,没有帐号?注册
x
使用emp表动态创建vo,并绑定到动态创建的table(advance table),但为什么显示不出来数据,求高手赐教!!!!!
AM:
public String[][] initVO(){
StringBuffer sb=new StringBuffer(300);
StringBuffer sb1=new StringBuffer(300);
sb.append("select 'no' empno,'name' ename,'job' job,'mgr' mgr,'hiredate' hiredate ,'sal' sal,'comm' comm,'dno'deptno from dual \r\n ");
sb.append("UNION ALL \r\n");
sb.append(" select to_char(empno),to_char(ename),to_char(job),to_char(mgr),to_char(hiredate),to_char(sal),to_char(comm),to_char(deptno) from emp");
//sb.append("select empno,ename,job,mgr,hiredate,sal,comm,deptno from emp");
OAViewObjectImpl vo=this.gettVO1();
vo.setQuery(sb.toString());
if(vo.getFetchedRowCount()==0){
System.out.println("vo is prepared for execute");
vo.setMaxFetchSize(-1);
vo.executeQuery();
}
System.out.println("vo query="+vo.getQuery());
System.out.println("VO criteria"+vo.getViewCriteria());
System.out.println("sql="+sb.toString());
System.out.println("fetchedcount="+vo.getRowCount());
//set the Attribute to updatable
Row row=vo.first();
AttributeDefImpl[] ad=(AttributeDefImpl[])vo.getViewDefinition().getAttributeDefs();
int intAttributeCount = ad.length;
System.out.println("count"+intAttributeCount);
String[] strTitle = new String[]{"no","name","job","mgr","hiredate","sal","comm","dno"};
String[] strAttributeNames = row.getAttributeNames();
//for insert and update
vo.addDynamicAttribute("DUMMY_ATTRIBUTE");
row.remove();
for(int i=0;i<strAttributeNames.length;i++){
System.out.println("strAttributeNames["+i+"]="+strAttributeNames[i]);
}
System.out.println("sb1 rowcount="+vo.getRowCount());
System.out.println("getfetchedrowcount="+vo.getFetchedRowCount());
return new String[][]{strTitle, strAttributeNames};
}
co:
OAApplicationModule am = pageContext.getApplicationModule(webBean);
String[][] strTitleAndAttributeName = (String[][])am.invokeMethod("initVO");
OAAdvancedTableBean tableBean = (OAAdvancedTableBean)webBean.findChildRecursive("adtable");
tableBean.setViewUsageName("tVO1");
tableBean.prepareForRendering(pageContext);
// pageContext..
for (int i = 0; i < strTitleAndAttributeName[0].length; i++)
{
// create a column
OAColumnBean cb = (OAColumnBean)createWebBean(pageContext, COLUMN_BEAN, null, null);
// create MessageStyledText
OAMessageStyledTextBean mst = (OAMessageStyledTextBean)createWebBean(pageContext, MESSAGE_STYLED_TEXT_BEAN, null, null);
mst.setViewAttributeName(strTitleAndAttributeName[1][i]);
mst.setViewUsageName("tVO1");
mst.setTextBinding(strTitleAndAttributeName[1][i]);
cb.addIndexedChild(mst);
// create title
OASortableHeaderBean shb = (OASortableHeaderBean)createWebBean(pageContext, SORTABLE_HEADER_BEAN, null, null);
shb.setPrompt(strTitleAndAttributeName[0][i]);
cb.setColumnHeader(shb);
tableBean.addIndexedChild(cb);
|
|