I read this question and I will look at beanutils, but I would need something more specific. I have a JSF form so after posting it the JSF framework will do the job for me taking the post parameters (key-value pairs), converting them appropriately and putting in the associated bean properties. I would like to have some fields in the the form precompiled based on key-value pairs. Can I achieve this goal liveraging the power of jsf ?
To put in other words I have key-value pairs and I want to use them to fill some fields in an existing JSF form avoiding manual compilation of them.
The task is further complicated because in the form I have some html selects.
They correspond to dictionary objects which have an ID and a description. Unfortunately in the corresponding key-value pair I have the field name and the description, not the id.
Update with additional informations
the form is already existing and all fields are ammaped to an enity, lets say of type Person, this way:
<h:inputText value="#{bean.person.name}" />
<h:inputText value="#{bean.person.state}" />
Somewhere else I have strings like these ones:
name=Bruno
state=Germany
The beanutils approach seems promising, I want to avoid hardcoding the names of the fields in the code.
The initialization code would become:
public void preCreate()
{
selectedPerson = new Person();
fillFields(myMap, selectedPerson);
}