0

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);
}
Community
  • 1
  • 1
Filippo
  • 1,123
  • 1
  • 11
  • 28

1 Answers1

0

Finally I focused the problem better.

The beanutils approach seemed overkill since the beginning because I have to add new libraries to the server and to write some converters. But the converters and all the validation logic was still there in the jsf page.

What I really needed was a simple way to put some text inside the input fields in the form, a task which can be easily accomplished with some javascript.

Filippo
  • 1,123
  • 1
  • 11
  • 28