Saturday, November 21, 2009

11G : How to insert the Row Progamatically in ADF Table?

public String Insert() {

try{
FacesContext fctx=FacesContext.getCurrentInstance();
HttpServletRequest req = (HttpServletRequest)fctx.getExternalContext().getRequest();
HttpSession session=req.getSession();
String username=(String)session.getAttribute("username");
String amDef = "mail.model.queries.AppModule";
String config = "AppModuleLocal";
ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
ViewObject mailVO=am.findViewObject("MailView1");
mailVO.executeQuery();
MailViewRowImpl mailRow=(MailViewRowImpl)mailVO.createRow();


 SequenceImpl mailSeq = new SequenceImpl("TEST_MAIL_SEQ", am );

 mailRow.setMailId(mailSeq .getSequenceNumber());
mailRow.setReceiver(to);
mailRow.setSender(username);
mailRow.setCc(cc);
mailRow.setCc(bcc);
mailRow.setCc(subject);
mailRow.setCc(message);

mailVO.insertRow(mailRow);
am.getTransaction().commit();
}catch(Exception e){

}
finally{
            if(am=null){
                Configuration.releaseRootApplicationModule(am, true);
            }
}

return "success";
}