Valuechangelistener Doubt in JSF

后端 未结 3 1788
灰色年华
灰色年华 2020-12-10 16:38

HI,

Please see the following code:

                

        
3条回答
  •  温柔的废话
    2020-12-10 17:07

    Romaintaz already pointed out the most, I just wanted to get straight on your concrete questions:

    What is the advantage of adding the f:valueChangeListener tag inside the h:selectOneMenu tag. I have used the normal attribute valueChangeListener="#{countryBean.changeCountry}".

    As Romaintaz said, the attribute points to a method and the f: tag points to a class. Another advantage is that you can have multiple of them, whenever that is necessary.

    Is it necessary to use onchange="submit() this code to change the values.

    That Javascript doesn't change the values. That Javascript submits the entire form without the need to pressing the submit button yourself, whenever the value has been changed by the enduser. No, that is not necessary. You can also just remove it and expect that the enduser presses the submit button himself. Once again, that JavaScript is not part of JSF.

    What is difference between writing the custom listeners by implementing the ActionListener interface and just using the attribute in the UIComponent tags (action="methodName").

    This question is already asked before: difference between action and actionlistener.

提交回复
热议问题