Hi,
I would like my POJO entities to have dynamic properties. This way i could easily decorate my object graph with JSF specific information.
For example:
[i]public class Category extends HashMap<String, Object>{
private String name;
private List<Category> subCategories = new ArrayList<Category>();
public Category(String name) {
this.name = name;
}
public List<Category> getSubCategories() {
return subCategories;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setSubCategories(List<Category> subCategories) {
this.subCategories = subCategories;
}
}[/i]
My managed bean:
[i]
@ManagedBean
@RequestScoped
public class TestBean {
private List<Category> categories = new ArrayList<Category>();
public List<Category> getCategories() {
return categories;
}
@PostConstruct
public void init() {
Category rootCat = new Category("rootCategory");
rootCat.getSubCategories().add(new Category("child1"));
rootCat.getSubCategories().add(new Category("child2"));
this.categories.add(rootCat);
}
}[/i]
My xhtml page:
[i]
<ui:repeat var="root" value="#{testBean.categories}">
#{root.name}
<ui:repeat var="child" value="#{root.subCategories}">
#{child.name}
</ui:repeat>
</ui:repeat>[/i]
The problem is if the Category pojo extends the Hasmap, the page does not show anything. If i remove the extension, than it is ok.
Why?
Thanks.
[Message sent by forum member 'gabox01']
http://forums.java.net/jive/thread.jspa?messageID=396714