Info
- JSF 2.0
- Primefaces 3.4
- Both objects are People objects
I have a simple drop down menu that is contained within a form that submits the selection on form submit (AJAX call):
<h:form>
....
<p:selectOneMenu converter="personconverter"
value="#{searchperson.viewPerson.relatedTo}" filter="true"
filterMatchMode="startsWith">
<f:selectItems value="#{searchperson.people}" var="person"
itemLabel="#{person.fullName}" itemValue="#{person}" />
</p:selectOneMenu>
....
<p:commandButton value="Save"
actionListener="#{searchperson.updatePerson}" />
</h:form>
When I submit the request to the server, the object tied to the selectOneMenu is passed correctly AND I am able to update my backend with this change.
When the page is re-rendered, the value in p:selectOneMenu:
(value="#{searchperson.viewPerson.relatedTo}")
Does not render the new change that was JUST submitted. It renders the last Person object in the people list.
Here are the other pieces:
Converter:
@FacesConverter("personconverter")
public class PersonConverter implements Converter {
@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1, String value) {
People pApi = new People();
Person per = new Person();
try {
per = pApi.getPerson(Long.parseLong(value));
}
catch(Exception e) {
e.printStackTrace();
}
return per;
}
@Override
public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
return String.valueOf(((Person) arg2).getId());
}
}
Object class
@Override
public boolean equals(Object object) {
return true; //just to pass through temporarily
}
@Override
public int hashCode() {
return 0;
}
face-config.xml
<converter>
<converter-for-class>com.obj.Person</converter-for-class>
<converter-class>com.converter.PersonConverter</converter-class>
</converter