0

I have concluded that the function cannot be called if I place the h:form within the foreach loop.

If I place the form outside and the button outside the foreach it will call the correct function. But how do I get desired result with one button for each row where i can pass the input text as a new value to the function?

Note that the getSeriesForPlayerIInfo works as it should

<c:forEach var="list" items="#{serviceSeries.getSeriesForPlayerInfo(club.name, player.stringID, aSerie, calendarBean)}">
            <h:form>
            <h:outputText value="   #{list[0] }" />
            <h:outputText value="   #{list[1] }" />
            <h:outputText value="#{serie.getSerieDateString(list[2]) }" />
            <h:outputText value="#{list[3]}"/>
            <h:outputText value="   #{list[4] }" />
            <h:outputText value="   #{list[5] }" />
            <h:outputText value="   #{list[6] }" />
            <h:inputText value="   #{list[7] }" />
            <h:outputText value="   #{list[8] }" />


            <h:commandButton action="#{serviceSeries.PlayerSerie}" value="Uppdatera">
            </h:commandButton>  
            </h:form>
            </c:forEach>
user2130951
  • 2,601
  • 4
  • 31
  • 58
  • Have you tried replacing `` with `` as I suggested on your [other question](http://stackoverflow.com/questions/21115470/page-calling-same-function-twice-jsf#comment31771081_21115470)? Plus you *need* a `` around anything that updates a value/causes an action. – mabi Jan 14 '14 at 15:22
  • Would that really change the problem with the binding only containing one value ? – user2130951 Jan 14 '14 at 15:29
  • 1
    Why do you bind the input component to the view to later on just pass its value as a parameter? Just pass `list[7]` as the second parameter! By the way, it's not necessary to explicitly call the `toString()` method in EL, as it's called by the framework to display the current object value. – Aritz Jan 14 '14 at 15:36
  • Still having problems getting the method call to work. Is there something wrong in the action parameter? – user2130951 Jan 15 '14 at 10:36
  • It will not work sending in list[7] since if I update the text field it will not carry over to list[7] it will just pass the original value – user2130951 Jan 15 '14 at 11:43

1 Answers1

0

In this construct, the <c:forEach> runs during view build time producing the JSF component tree. In effects, you end up with physically multiple <h:inputText> components in JSF component tree, each with the same binding:

<h:inputText ... binding="#{serieScore}" />
<h:inputText ... binding="#{serieScore}" />
<h:inputText ... binding="#{serieScore}" />
...

This is not right! You're binding physically different components to one and same bean property, hereby causing a messed up view state shared between all those components.

Get rid of binding altogether. It's the wrong tool for the job anyway. You should be using the value attribute the right way in order to get/set a value.

<h:inputText value="#{list[7]}" />

Supply if necessary a Converter if it's not a standard type like String, Number, Boolean, etc.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • What you are saying is that I should have a class that emulates the output from the "select xxx from" ? So i could set the list[7] which is impossible as it is now. Since it seems to be read only. – user2130951 Jan 20 '14 at 13:23
  • It's not read only. I'd work on figuring and fixing the "it seems" part. – BalusC Jan 20 '14 at 13:26
  • Probably true that it's not read only. But it's always getting the original value and not the one set by the input field. – user2130951 Jan 20 '14 at 13:48