Download sample application - CallingEntityMethodFromView.zip, this sample implements Java classes for EO and VO.
In EmployeesImpl.java, implementation class for EO, I have created simple custom method - calculateEmployeeRate(). This method multiplies salary with commission value per row:
Then you need to create VO and VO row implementation classes:
Create method in VO implementation class. This method should accept a row, based on this row it will retrieve EO implementation class and invoke custom method available there:
In order to make it work from ViewController, expose method you just created in VO implementation class through Client Interface:
Any exposed method can be declared in Page Definition. Pay attention for parameter value, I specified to accept current row. This means method in VO implementation always will get current row and based on it will invoke my custom method in EO:
On runtime, press Calculate Rate button that invokes custom logic in Model, and you will get result:
2 comments:
Hi Andrew,
Nice Post. Seems like tweaking :-) . But i really am very intersted in trying to know a use case when i should use this. It seen every thing that i can do in the EOImpl , i can do in the viewRowImpl. Am i correct. If possible please let me know a use case for this.
Thanks
-Pradip
Hi Pradip,
You should think simple about it. Use EO Impl for those cases, when method can be shared across multiple VO's.
I'm not talking about those cases when you implement validation, override doDML(), etc.
Regards,
Andrejus
Post a Comment