Description


It would be nice, with stateless component to have a simply way to store and load component state. Introduction of structs in 9.5 made this easily possible: ;Trigger Set State ... componentToStruct lvStruct, \"ROOT_ENTITY.MODEL\" structToXml lvXml, lvS ; Store somewhere lvXml ... ;Trigger Get State ... ; restore lvXml from somewhere xmlToStruct lvStruct, lvXml structToComponent lvStruct->ROOT_ENTITY.MODEL ... But with E113 patch it\'s non longer possible because type date fields are converted, during structToXml, in yyyy-mm-dd format and are not understood as date in structToComponent instruction, unless using an xsd schema in xmlToStruct, which is unfortunate. Perhaps a simple /string switch for the structToXml instruction to not convert type in XML type will be sufficient.

Use Case


Start to fill a form. Save form state during a session. Do other stuff with other component. Restore previous state of the form to complete it. Submit the form.

Importance


Normal

Type


Proc Code

Operating System


Not Applicable

Status


Open

3 thoughts on “Component serialization”

  1. Hi Phillipe,looks like a nice functionality the way you put the pseudocode together. ************** AFAIK, compared to the traditional XML/DTD road, the struct does not include a lot of the hidden information about the real “state” of the component. But perhaps someone will give us a more competent view on that funktionality and teh options to make it happen under the new ownership.

  2. Apparently, in version 10, the struct will have state information, and be amenable to the reconnect function. Whether this is back progressed into 9.6 is another matter. It is also passable as a parameter. So (in theory) one could have an ‘in memory’ service to which the state was passed as a struct, without the need to transfer to and from xml. Of course, you couldn’t save this state for later retrieval, it would only be transient within the current process. 

  3. I have also been looking at working around this behaviour. I need to be able to serialise an entity’s records and restore them later and have been using structToXML to achieve this and hit the same problem with the date and time formats being converted into the XML and not being recognised back in on xmlToStruct. I would have that the the member would have had a tag that describes the original datatype but I cannot see it using $dbgString or $tags. I’ve been comparing it to a member derived from a string field containing $date and it looks the same as the member derived from a date field. Yet the member originating from the string field does not get converted in the resulting XML. I was hoping that a tag on the date member would be able be stored as an attribute to the XML element which could then be interpreted when converting back using xmlToStruct.

    My work-around to this is to serialise using JSON instead as the structToJson does not appear to format the date fields at all in the resulting JSON stream, so there is not conversion required when loading back to a struct and it does indeed correctly restore the value to the date field on the entity. The only thing I had to do in my case (where I was selecting individual entities to serialise from the component) was to add a parent to the struct from the jsonToStruct so that it could map back to the correct entity (componentToStruct followed by structToXml includes the entity name in the resulting XML, but it does not include the entity in the JSON stream).

    I hope this helps anyone trying to do the same thing.

Leave a Reply