简体   繁体   English

在UIInput组件中使用带有参数的方法时,如何调用setter方法?

[英]How to invoke setter method when using methods with arguments in UIInput components?

Before I have used methods with arguments to obtain the values of a component on my JSF page, for example 例如,在我将带有参数的方法用于在JSF页面上获取组件的值之前

<h:dataTable value="#{myBean.getMyList(argument)}">

However now I need the same principle, but using it on a value attribute of an inputText element, so it would be more or less like this: 但是现在我需要相同的原理,但是要在inputText元素的value属性上使用它,所以它或多或少像这样:

<h:inputText value="#{myBean.getMyValue(argment)}">

The problem is that the second method will not invoke the setter method, when executing the element from af:ajax element. 问题是,从af:ajax元素执行元素时,第二个方法将不会调用setter方法。

What would be another way of passing values to the setter and getter methods on the backingBean?. 将值传递到backingBean上的setter和getter方法的另一种方式是什么?

Thanks a lot. 非常感谢。

It's indeed not possible to set a value on an EL expression which does not represent a getter. 实际上,不可能在不代表getter的EL表达式上设置值。 You'd need to turn myValue into a Map<String, Object> and use the following notation. 您需要将myValue转换为Map<String, Object>并使用以下表示法。

<h:inputText value="#{myBean.myValue[argument]}">

This will then call the put() method on the Map . 然后,它将在Map上调用put()方法。 Note that you don't need a setter for myValue here. 请注意,这里不需要myValue的设置myValue

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM