0

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;
}
1
  • any edit in the h:inputText will be reflected in your arrayList...
    – Daniel
    Apr 23, 2012 at 10:52

1 Answer 1

2

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}"
2
  • 1
    The last statement is not true.
    – BalusC
    Apr 23, 2012 at 11:50
  • Thanks BalusC, mixed it up with the inputText value. Edited my post.
    – Matt Handy
    Apr 23, 2012 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.