Difference between value and binding

前端 未结 2 1824
孤街浪徒
孤街浪徒 2021-01-31 17:37

What is the difference between using value and binding with JavaServer Faces, and when would you use one as opposed to the other? To make it clearer what my question is, a coup

2条回答
  •  野性不改
    2021-01-31 18:30

    Sometimes we don't really need to apply the value of UIComponent to a bean property. For example you might need to access the UIComponent and work with it without applying its value to the model property. In such cases it's good to use a backing bean rather than a regular bean. On the other hand in some situations we might need to work with the values of the UIComponent without any need of programmatic access to them. In this case you can just go with the regular beans.

    So, the rule is that use a backing bean only when you need programmatic access to the components declared in the view. In other cases use the regular beans.

提交回复
热议问题