0
votes

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

1 Answers

6
votes

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.