Introduction:
JSF: MVC framework as Struts
DWR: java Ajax framework
Json: a data format definition like XML, YAML. We could use DWR or jsonlib to marshal/unmarshal between json and objects.
How to use?
1, when should we use json or not?
do JSF as much as possible;
only when dynamic collection size on page, do Json
2, when should we use DWR json convertor configuration or customize json convertor by java?
page scope update, do Ajax by DWR as much as possible;
otherwise, do JSF action by json convertor (consolidate convertor by jsonlib or dwr?)
DWR convertor VS Jsonlib convertor:
DWR:
convertor setting by xml, annotation or java;
Jsonlib:
convertor setting by java (only check @Transient), but more professional overall;
Requirement:
1, simple convertion, no VO or DTO:
PO to json: 1, cycle detect; 2,include/exclude;
Json to PO: 1, the same js handle; 2, ajax by dwr; jsf by hidden string
2, one PO map into two JSON model for different domains (e.g. bind different convertor by spring to different domain serviceImpl)
Not to do list:
1, do not use duplicated convertors definition in java/xml/annotation
2, do not DTO or VO when convert between json and objects
3, do not parse or transfer useless fields, e.g. use include / exclude configuration instead during convert objects into json; use "delete" during convert json into object
4, do not use json if could use JSF