1

I wonder how I could bind

<h:inputText />

with specify field 'surname' of object user stored in map in backing bean

@ApplicationScoped
@Named
public class AttributesRepository {

   private Map<String,User> map;

   /*getter setter*/

} 

It is possible to do something like that:

<h:inputText value="#{attributesRepository.map['first'].surname}" /> 

I go the following

java.lang.NumberFormatException: For input string: "surname"
   at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
   at java.lang.Integer.parseInt(Integer.java:580)
   at java.lang.Integer.parseInt(Integer.java:615)
   at javax.el.ArrayELResolver.toInteger(ArrayELResolver.java:378)
   at javax.el.ArrayELResolver.getValue(ArrayELResolver.java:198)
   at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
   at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
   at com.sun.el.parser.AstValue.getValue(AstValue.java:140)
   at com.sun.el.parser.AstValue.getValue(AstValue.java:204)
   at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
   at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
   at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
   at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
   at javax.faces.component.UIOutput.getValue(UIOutput.java:174)
   at javax.faces.component.UIInput.getValue(UIInput.java:291)
   at org.primefaces.util.ComponentUtils.getValueToRender(ComponentUtils.java:94)
   at org.primefaces.util.ComponentUtils.getValueToRender(ComponentUtils.java:58)
   at org.primefaces.component.inputtext.InputTextRenderer.encodeMarkup(InputTextRenderer.java:71)
   at org.primefaces.component.inputtext.InputTextRenderer.encodeEnd(InputTextRenderer.java:52)
   at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
   at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)

or meaby is there other way to use for example converter on inputText. I dont have idea what I could do.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
Michał Ziembiński
  • 1,124
  • 2
  • 10
  • 31

0 Answers0