I have a data entry form where user enters lots of data. When user comes to the page to view existing data, the page should be displayed in read-only mode (all values shown as text), when he clicks ‘Edit’ button, normal form with all input controls should be shown so that user can change and save data.
We are using JSF 2.0 with PrimeFaces library. It is easy to achieve above behavior for text box and text area but not for Checkbox, multi-select, radio,….. controls. Is there any easy way available to achieve above behavior rather than writing our own code (which may run into lot of lines thus making backing bean code ugly)
Thanks for your help…
I’m not sure why you think that you need additional backing bean code for this. You’ve all the needed values in the backing bean already. Your problem is more in the presentation of those values. Just display them in the desired format by writing the view code accordingly. Perhaps you were thinking it too the hard way.
Instead of a select boolean checkbox, you could display for example a “Yes” or “No” value.
Instead of a select one menu/radio, you could just display the value in an output text.
Instead of a select many listbox/checkbox, you could just display for example all values comma separated in a loop.
You could wrap it all in a tag file or a composite to minimize boilerplate and code repetition.