0

I have a dynamically created HtmlInputText, which is set to pull its value from a map in a session scoped bean. Like so.

HtmlInputText input = new HtmlInputText();
String expression = "${catalogue.itemValues.A" + item.getId() + "}";
ValueExpression valExpression = expressionFactory.createValueExpression(facesInstance.getELContext(), expression, String.class);
input.setValueExpression("value",valExpression);

where itemValues is a map with a getter of getItemValues() and the key would be A1, A2, etc.

I have programatically added a value to the Map with the key A1 and value 1234. Whenever the JSF page appears, the value is rendered. However, when I change the value and submit the form, the value is not changed.

I have tested with a h:inputText element and linked it to the same key and it is able to update the value and the new value is reflected in the generated HtmlInputText component.

How is this caused and how can I solve it?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

1 Answers1

1

You should be using #{} syntax to bind input values, not the ${} syntax. The #{} can do a get and set, while the ${} can only do a get.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Then you've another problem in the code which is not visible in the code posted so far. Perhaps the way how you're creating/manipulating/storing components is plain wrong? To the point, this job should **not** be done in a getter method and **every** manually created `UIInput`/`UICommand` component must have an unique fixed ID set by `setId()`. Those two are at least the most common beginner's mistakes. – BalusC Jun 16 '12 at 15:41
  • @BalusC Thanks, for me it was that I forgot to add the unique fixed Id to the inputText. – Lyrion Aug 27 '12 at 13:18