Best Practice to update computed fields on an xpage using managed beans

你说的曾经没有我的故事 提交于 2019-12-13 07:07:12

问题


I have an xpage with several editable fields and need to update some computed fields dynamically. I am using a managed bean to store all data, all the fields are bound to the bean.

For example sake, say there is an input called input1, and another called input2. I would like to display the sum in a field dynamically, call this field sum1. This field like the others is bound to the managed bean.

I was intending on using either a partial refresh or CSJS to update the sum1 field, and a backend SSJS to write the value to the bean. I also considered binding to a viewScope variable and then setting the bean on submit. I know that I could get either option work, but I am looking for the best practice.

I ask this question because it occurred that since I was already using a bean that maybe my best approach should be to put this logic in the bean itself in the setSum1() and/or getSum1() methods. Perhaps I have been reading too much of Jesse Gallagher's blog, but the thought of the MVC model and separating business logic are ringing in my head.

I hope this isn't too subjective, I am looking for the best practice from those who have more experience using beans than I.


回答1:


Steve, if you have a bean, then you don't need to resort to SSJS. Just write a getSum1() function and bind to #{yourBean.sum1}. When you only have a get function the field automatically becomes readonly.



来源:https://stackoverflow.com/questions/17331200/best-practice-to-update-computed-fields-on-an-xpage-using-managed-beans

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!