且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将输入文本值传递给bean方法,而无需将输入值绑定到bean属性

更新时间:2022-01-12 18:24:39

将该组件绑定为 UIInput#getValue() 将其值作为方法参数传递.

Bind the component as UIInput to the view and use UIInput#getValue() to pass its value as method argument.

<h:inputText binding="#{input1}" />
<h:commandButton value="Test" action="#{myBean.execute(input1.value)}" />

使用

public void execute(String value) {
    // ...
}

请注意,该值已经通过这种方式转换并验证了通常的JSF方式.

Note that the value is this way already converted and validated the usual JSF way.

  • How does the 'binding' attribute work in JSF? When and how should it be used?
  • JSF component binding without bean property