JSF backing bean structure (best practices)

后端 未结 6 786
谎友^
谎友^ 2020-11-28 00:21

I hope that in this post, I can get people\'s opinions on best practices for the interface between JSF pages and backing beans.

One thing that I never can settle on

6条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 00:49

    I like to test business code without View's, so I consider BackingBeans as interfaces from View to Model code. I never put any rule or process in a BackingBean. That code goes into Services or Helpers, allowing reuse.

    If you use validators, put them out of your BackingBean and reference them from your validation method.

    If you access DAOs for filling Selects, Radios, Checkboxes, do that always out of a BackingBean.

    Believe me!. You can inject a JavaBean into a BackingBean, but try to inject a BackingBean into another one. You will be soon in a nigntmare of maintenance and understanding code.

提交回复
热议问题