Friday, May 28, 2010

Plan to crush #1318

Goal: Get a new repeat tag working, the new repeat tag should incorporate jquery with the formentry module

Sub Goal:
1) Get new repeat tag display functioning
the general move is use jquery to clone and insert the new row of html control , to work this out,
we need to consider how to copy and insert all html controls with in a repeat tag


2)Get new repeat tag submit functioning
the module use a hashmap to store the {widget : htmlcontrol} name pair. The problem is when a new html controller has been generated by jquery/javascript, the module has no way to know about their existence.

The possible flow:

Form Creation
1) user edit a form, a tag

2)user submit/save/edit the form

Form Preview()
the html form is generated by createForm in formentrysession
we can handle the tag in line 247: applyTags function
The applyTagsHelper will do the job.
so
1) add a entry in the applicationContext.xml to relate with a handler
2)Create a new handler

the handler is used for generate required jquery/html for the newrepeat tag

input:

< newrepeat >
< template >
< obs conceptid = "123" >
< /template >
< /newrepeat >

Output(Mode = view):

< script .... the javascript/jquery to clone and insert the template >
< span ... the template html generated based on concept with id="123" >
....
< /span >

< span ... 1 generated html on concept with id="123" >
....
< /span >

Form Enter
To handle new repeat tag enter(save), 2 things needs to be done:
1) mapping a repeated widget with a htmlid

input Original:

< newrepeat >
< template >
< obs conceptid = "123" >
< /template >
< /newrepeat >

input intermidate:


Output(Mode = edit):

< script .... the javascript/jquery to clone and insert the template >
< span any exsiting obs that are associated with this encounter >
...
< /span >
< span ... the template html generated based on concept with id="123" >
....
< /span >

< span ... 1 generated html on concept with id="123" >
....
< /span >

Output(Mode = input):

< script .... the javascript/jquery to clone and insert the template >
< span ... the template html generated based on concept with id="123" >
....
< /span >

< span ... 1 generated html on concept with id="123" >
....
< /span >

Saturday, May 22, 2010

HTML Widget Model, the work flow

1) HTML Widget flow

a) jsp parser encounter a custom tag in a jsp page, i.e. <>

b) trace back based on the tld <>, found the definition in
"/WEB-INF/view/module/htmlwidgets/resources/htmlwidgets.tld"

c) the tag class in the tld file will lead to
org.openmrs.module.htmlwidgets.web.taglib.WidgetTag

c1) WidgetTag class has properties named : name, object, property
this will populated by the attributes of the same name based on demonstration.jsp:
the known attributes are:
id="defaultField${p.key}" // represents the id of the input field
name="${p.key}" // represents the name of the input field
object="${demo}" // represents the object whose property are editing
property="${p.key}" // represents the name of the property/field to edit
// on the object

d) in WidgetTag, the actual widget type will be figured out by reflection, then associate the tag with a Taghandle class.

g) TagHandle itself is a abstract class,openmrs has a ulti method to match a subclass according to the actual type of the tag.
This method works like this:
it will call openmrs api to return a list of loaded spring beans.
if a bean has a annotation and matches the type. it should be returned

f) why handler classes are treated as beans?
In ApplicationContext-Service. we see a line
< package="org.openmrs"> < type="annotation" expression="org.openmrs.annotation.Handler">

... < /context:include-filter>

This line will let spring to include any class which has a @handler annotation and load them as beans into spring Context(finally figure it out, phew~~) when refreshing the context.


Monday, May 17, 2010

Good Resources for Spring MVC3

1) official doc 3.x
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mvc.html

2) InfoQ doc 2.5
http://www.infoq.com/articles/spring-2.5-ii-spring-mvc

3) About 3.x REST style conversion
http://blog.m1key.me/2010/01/rest-with-spring-30-spring-mvc-and-dojo.html

Summary May 17th

1) a machine for future demonstration

http://columbia.cs.uga.edu:8381/

2) a simple application that using spring MVC3

http://columbia.cs.uga.edu:8381/MyFirstSpringMVC3/

Next, start learning jquery

Tuesday, May 4, 2010

Weekly Summary May 04

Last week tasks:
1)Communicate with mentor.
2)Reading module source code
3)study the overview
http://openmrs.org/wiki/HTML_Form_Entry_Module_Technical_Overview