0

I am having an functionality through which I am displaying the properties of a document on JSF. The properties are coming through a map and I am iterating it over the JSF as follows:

<af:iterator var="list" value="#{MainContentBean.documentProperties}" id="i1">
    <af:inputText label="#{list.key}" id="it1"editable="always" value="list.value">                
</af:iterator>

This is working fine till I want to use it only for the display purpose, but if I want to make it up datatable, i.e the user can change the values of the input text box it's not working. The input text box is always displayed in read only mode if the setters and getters are not present. The values I am getting in map is uncertain, so in this situation, how can I generate setters and getters for each property value at runtime? Is this possible to do that?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Durgesh Sahu
  • 247
  • 1
  • 5
  • 19
  • Please add tag for JSF also :) – Amit Deshpande Aug 29 '12 at 09:51
  • It is possible, but tricky. It is usually simpler to a) generate them at compile time b) include them in your source (using your IDE to generate them) – Peter Lawrey Aug 29 '12 at 09:53
  • What is `af:` namespace for? Is "documentProperies" a Map and you want to make a class from it on runtime? Do I understand you right? You don't know properties on comile-time? – Piotr Gwiazda Aug 29 '12 at 09:56
  • Yes peter its easy to generate them at compile time but as i don't know what i am gonna get in the property map, so its useless to create setters and getters at compile time. – Durgesh Sahu Aug 29 '12 at 10:04
  • Yes Piotr Gwiazda, you got it right, the documentProperties is the map which i am iterating over the jsf, and its value is not known to me a compile time. – Durgesh Sahu Aug 29 '12 at 10:05

1 Answers1

1

Yes, it is possible using cglib. Take a look at "Adding setter/getters with cglib to compete with RoR... Dumb idea? Input from Crazy Bob"

Also, take a look at this answer which suggest using ASM

Community
  • 1
  • 1
Boris Pavlović
  • 63,078
  • 28
  • 122
  • 148