Step 1 :
Create a sequence .
CREATE SEQUENCE id_seq
start with 1
increment by 1;
Step 2 :
Create EO and VO using database table.Edit Entity Object id and select value type as expression and put the bellow value.
(new racle.jbo.server.SequenceImpl("id_seq",adf.object.getDBTransaction())).getSequenceNumber().
Step 3 :
Create form using view object in datacontrols in jsf page and add createInsert,commit,rollback actions bindings to page.
In save button action listener write bellow code
DCBindingContainer bindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
// int id =((BigDecimal)JSFUtils.resolveExpression("#{bindings.Id.inputValue}")).intValue();
int id =((Number)JSFUtils.resolveExpression("#{bindings.Id.inputValue}")).intValue();
DCIteratorBinding roleIter =
bindings.findIteratorBinding("EmpVO1Iterator");
ViewObject obj = roleIter.getViewObject();
Row newRow = obj.createRow();
newRow.setNewRowState(Row.STATUS_INITIALIZED);
newRow.setAttribute("deptId", id);
newRow.setAttribute("EmpId", "some value");
obj.insertRow(newRow);
}
executeMethodBinding("Commit");
Note :
If any one got bellow exception change datatype of ID number to Bigdecimal in EO
java.lang.ArrayIndexOutOfBoundsException: 1 at oracle.sql.NUMBER.toBigDecimal(NUMBER.java:681).
