Reputation: 624
I have jsf/primeface form components in my project. Also there are db table which describe which field should be required or hidden. This table is used by another system (which is not java related) so my project should also use that db table.
The problem is those fields and its ids are described as numbers in the db and in my project jsf/primefaces components have human readable ids. For example "name" field in db table has id = 1, required = 0, hidden = 1 and in xhtml I have:
<p:inputtext id="idName" required="false" rendered="true"...>
Is there any approach so that I can easily map idName
component to database entry but not changing db table structure?
Upvotes: 0
Views: 404
Reputation: 1109570
Just create an entity representing the field:
public class Field {
private Long id;
private boolean required;
private boolean hidden;
// ...
}
and use it in your view as follows:
<p:inputText value="#{bean.values[field.id]}" required="#{field.required}" rendered="#{not field.hidden}" />
whereby #{bean.values}
refers a Map<Long, Object>
.
Upvotes: 2