1

Starting from here I have the following problem:

I'm generating a random number of form fields (It's not that random, but the user can change in any moment their number) and I want to save all this information in a Managed Bean ArrayList property.

<ui:repeat var = "ctr" value = "#{controller.tipCounter}">
    <h:outputLabel for = "tip" value = "#{appMessage['form.tip']} ##{ctr} :" />
    <h:inputText id = "tip" value="#{controller.tipList}" maxlength="100" />
</ui:repeat>

In the controller I have the following property:

private List<String>tipList;
//Get+Set

Besides some undesired behaviour (all the form fields mapping this list have [] as their value) this warnings are thrown:

INFO: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=fm-story:j_idt60:0:tip[severity=(ERROR 2), summary=(Conversion Error setting value '' for 'null Converter'.), detail=(Conversion Error setting value '' for 'null Converter'.)]
sourceId=fm-story:j_idt60:1:tip[severity=(ERROR 2), summary=(Conversion Error setting value '' for 'null Converter'.), detail=(Conversion Error setting value '' for 'null Converter'.)]
Community
  • 1
  • 1
Ionut
  • 2,788
  • 6
  • 29
  • 46

1 Answers1

1

You got a conversion error because you're attempting to set a submitted String value as a List<String> property, for which no standard converter exists and for which you haven't declared any converter.

After all, you shouldn't need any one. This syntax is simply not correct. You need to bind a String value to a String property. You need to reference the list by the index instead. I'm also not sure why you need 2 lists for this. The tipCounter seems totally unnecessary.

Here's a rewrite:

<ui:repeat value="#{controller.tipList}" var="tip" varStatus="loop">
    <h:outputLabel for="tip" value="#{appMessage['form.tip']} ##{loop.count} :" />
    <h:inputText id="tip" value="#{controller.tipList[loop.index]}" maxlength="100" />
</ui:repeat>

You might want to add a <h:message for="tip" /> inside the loop as well.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thank you again!. I've bean meaning to ask you for some time about the documentation you are using. Besides the official JSF Support and JavaServer Faces 2.0 The Complete Reference (You recommended it in some other post) is there anything else you found helpful. It seems that you have a deep understanding and knowledge of JSF an I can imagine that besides lots of practice you have a solid theoretical knowledge. Thanks again! – Ionut Feb 22 '12 at 14:06
  • Understanding how HTTP and JSP/Servlets works has also been very helpful in understanding what JSF is doing under the covers. – BalusC Feb 22 '12 at 14:11