Menno
Menno

Reputation: 12621

Retrieving inputvalue from JSF-repeat

I have recently come across a question involving JSF and Javabeans. To get a value from an input you need a declared property with getter and setter in the bean. Now I am trying to generate a list of entities to edit a value (in this code example called number), but how can i retrieve these values (as the ID of h:inputText is empty at this point)?

I have tried to name this ID "name_#{bean.id}", but there is no way to set this value in the bean.

Any help would be appreciated!

index.xhtml

<ui:repeat var="entity" value="#{bean.getEntities()}"> 
    <p>
    Value:
    <h:inputText id="" value="#{entity.number}" />
    </p>
</ui:repeat>

Bean.java

public List<Entity> getEntities() {
    return entities;
}

Upvotes: 0

Views: 131

Answers (1)

Matt Handy
Matt Handy

Reputation: 30025

You don't need the client id of the inputText to get the values to the server. As stated in Daniel's comment changes are saved if you submit the surrounding form.

You don't even need to set the id parameter. JSF does it for you.

But your value attribute is not correct. It needs to be

value="#{bean.entities}"

Upvotes: 2

Related Questions