tags:

views:

73

answers:

1

I have a edit screen which displays a series of editable properties(fields) of an entity. And this list of fields are dynamic,in the sense that any field can be added/removed from the list without any code change. I have a model something like this.

public class Property{

 private String displayName;
 private String value;
 private int displayOrder;
 //other props,getters,setters etc..
}

My backingBean has a map of these properties (for some other reasons,we chose map as the datastructure).

public class BackingBean{

private Map<String,Property> editableProps;
//other props,getters,setters etc..
}

The problem is with iterating over this map and produce a textbox for each of the entry. Since a4j:repeat(richfaces) doesn't iterate over a map,I have decided to use JSTL and the code fragment looks something like this,

<c:forEach items="${mybean.editableProps}"
                var="item" >
    <tr>
     <td>
      <c:out value="${item.value.displayName}"/>
     </td>
     <td>
      <input type="text" value="${item.value.value}" />
     </td>
    </tr>
</c:forEach>

This will work fine except for the fact that the binding of a ui field to bean's property will not happen automatically. If I try using h:inputText inside c:forEach, the component doesn't get rendered.(Guess the jstl var is not available for the jsf). Is there a JSF way of doing all this(Using hashmap)?So that a textbox is produced for each entry in the map and any change to it gets bound the underlying java bean property.?

A: 

If you are using RichFaces then for this situation you should go for RichDataTable

You can create a class like

class MapWrapper{      
private String key;        
private String value;      
//setter getter and const and etc..    
}  

Now Iterate RichDataTable on the List of MapWrapper

org.life.java
datatable cannot iterate over a hashmap.
chedine
edited.8 more to go..
org.life.java