Update/Insert new VO programatically
JZWLMar 8 2012 — edited Jun 7 2012Hi all (status newbie),
JDEV version : (Studio Edition Version 11.1.1.5.0)
I would like to have a VO which would insert a new row into a table. I have the VO created for that table based on the table Entity object, How can do an insert into that VO using the ViewDefImpl class from the backend. ( Creating an custom method in the viewImpl class and exposing it to the client option couldn't be used due to some webservice calls that needs to done before the insert operation.)
Current solution I have is like a custom method inside the Viewimpl class and invoke it inside from the Backend (given below) , but then there will some code which touched the Entity object directly which iam trying to avoid.
public custominsertmethod(String variables){
//get enitytdefenition object
//Create a new entity instance and call the commit
CurrencyEOImpl Currency =
(CurrencyEOEOImpl)CurrencyEODefObject.createInstance2(getDBTransaction(),
null);
Currency .setId(questionid);
Currency .setEnglishDescription(desc);
try {
getDBTransaction().commit();
} catch (JboException ex) {
getDBTransaction().rollback();
throw ex;
}
}
now I am able to retrieve the complete VO values like this , Please enlighten me of any major issues that may come with approach at runtime, like performance memory mismanagement or so. etc
if(CurrencyVO().isExecuted()){
while(CurrencyVO().hasNext()){
Row currency = CurrencyVO().next();
//Id ,EnglishDescription
currencyMap.put(currency.getAttribute("Id"), currency.getAttribute("EnglishDescription"));
}
Thanks
JZWL