How to programatically insert a row in a table with the help of view object object
try{
FacesContext fcc=FacesContext.getCurrentInstance();
HttpServletRequest req=(HttpServletRequest)fcc.getExternalContext().getRequest();
HttpSession session =req.getSession();
String amDef = "model.applicationmodule.AppModule";
String config = "AppModuleLocal";
ApplicationModule am =Configuration.createRootApplicationModule(amDef, config);
String[] volist = amm.getViewObjectNames();
ViewObject vo=null;
vo=amm.findViewObject(volist[i]);
vo.executeQuery();
CityViewRowImpl cvri=(CityViewRowImpl)vo.createRow();
cvri.setAttribute("State", "NewYork");
cvri.setAttribute("City1", "Washington");
vo.insertRow(cvri);
am.getTransaction().commit();
}catch(Exception e){
e.printStackTrace();
}
.
try{
FacesContext fcc=FacesContext.getCurrentInstance();
HttpServletRequest req=(HttpServletRequest)fcc.getExternalContext().getRequest();
HttpSession session =req.getSession();
String amDef = "model.applicationmodule.AppModule";
String config = "AppModuleLocal";
ApplicationModule am =Configuration.createRootApplicationModule(amDef, config);
String[] volist = amm.getViewObjectNames();
ViewObject vo=null;
vo=amm.findViewObject(volist[i]);
vo.executeQuery();
CityViewRowImpl cvri=(CityViewRowImpl)vo.createRow();
cvri.setAttribute("State", "NewYork");
cvri.setAttribute("City1", "Washington");
vo.insertRow(cvri);
am.getTransaction().commit();
}catch(Exception e){
e.printStackTrace();
}
.
No comments:
Post a Comment