天天看點

Transformation available that removes all elements from form message type

the elements which are used in the form message type for a specific form can be classfied as four types:

direct binding.

example: in direct binding, the element path is just specified in the attribute “field.bind.ref”, as shown below.

relative binding.

example: form template field form message type instance

a ( parent ) $record.deliverynote.material

a ( child ) $.id

b ( child ) $.itemid

c ( child ) $.name

if some node in the same hierarchy are bound to the same parent node in the form message type, for this example “a” is bound to $record.deliverynote.material.id and “b” is bound to $record.deliverynote.material.itemid and “c” is bound to $record.deliverynote.material.name. to enhance performance, we use relative binding. the parent of a,b, and c is bound to $record.deliverynote.material and “a” now is bound to $.id and “b” $.itemid and “c” $.name.

direct scripting.

as mentioned by patrick, it is impossible to fulfill some special requirement sometimes so java script is used to handle with some form message type elements.

all the script texts for a field is located in the field.event.script node in the xml source.

we call some type as “direct scripting” because the specified form message type elements can still be found in the script text, as example below:

$deliverynote.logisticpackage.material.purchaseorderitemreference.id ( just concatenate the path after “resolvenode” function ).

relative scripting.

we call “relative scripting” because the path of the form message type elements used is more implicit to be detected compared with direct scripting. relative scripting is mainly used to benefit from making table accessible and efe compatible.

example: var d = this.datanode.parent.parent.

we cannot get anything from the script above until going up in the form message type instance hierarchy. field “txtluid” is relatively bound to “targetlogisticsareadescription”.

so we can know that in this script, the element logisticpackage.logisticunitid and logisticpackage.plannedlogisticunitquantity is used.

to achieve this:

step1: load the xml source of a template into memory. you can find that i just ignore the xml source " content balalala" because those source are irrrelevant for field binding path and the more important thing is , i find the java dom can not handle with some special locale characters, for example ,the locale characters in chinese, so i just ignore them.

step2: build the xml source got from step1 into dom tree.

an example of dom tree looks like below. here what you have to do is just to go through the node for master page and the one for body page recursively and get all the subnode filtered by node name “field”.

this is because only element “field” and “subform” can have binding path from technical side, if you need also to extract binding path of subform, you must also handle with the node whose name is “subform”.

Transformation available that removes all elements from form message type

step3: suppose you have already get a node for “field”, you can find from the xml source for this field below and know that the binding path is located in the subnode named “bind”, attribute “ref”.

you can get its binding path such as below:

whole source code

要擷取更多jerry的原創文章,請關注公衆号"汪子熙":

Transformation available that removes all elements from form message type

繼續閱讀