Skip to content
This repository has been archived by the owner on Mar 15, 2022. It is now read-only.

Node annotated with @Native is not serialised - does @Native work at all? #22

Open
gallafent opened this issue Aug 7, 2014 · 1 comment

Comments

@gallafent
Copy link

I have a class which looks something like this (names changed to protect the innocent ;):

package com.com.com;

import name.pehl.piriti.commons.client.Native;
import name.pehl.piriti.xml.client.XmlWriter;
import name.pehl.totoe.xml.client.Node;

class Request
{
    public interface ReqWriter extends XmlWriter<Request> {}
    public static final ReqWriter WRITER = GWT.create(ReqWriter.class);

    @Native Node anXMLFragment;
}

I assign a Node which I have previously obtained from a NodeList generated by totoe's selectNodes to anXMLFragment, but when I serialise a Request using Request. WRITER. toXml (req), the XML element is empty: <anXMLFragment />.

I walked through in the debugger, and saw this generated code:

                // parsing template name/pehl/piriti/rebind/xml/writer/property/any.vm
                if (logger.isLoggable(FINE)) 
                {
                    logger.log(FINE, "Processing name.pehl.totoe.xml.client.Node anXMLFragment");
                }
                name.pehl.totoe.xml.client.Node value1007 = null;
                                                            value1007 = model.anXMLFragment;
                                                                        boolean value1007CreateRequired;
    if (value1007 != null)
{
            XmlWriter<name.pehl.totoe.xml.client.Node> value1007Writer = xmlRegistry.getWriter(name.pehl.totoe.xml.client.Node.class);
        if (value1007Writer != null)
        {
            XmlBuilder nestedXmlBuilder = new XmlBuilder("anXMLFragment");
            ((AbstractXmlWriter<name.pehl.totoe.xml.client.Node>)value1007Writer).appendModel(nestedXmlBuilder, value1007);
            xmlBuilder.append(nestedXmlBuilder);
        }
        else
        {
           xmlBuilder.append("anXMLFragment");
        }

The call to xmlRegistry.getWriter returns null, and so only the empty element is written. I looked in the xmlRegistry instance, and can see that there is indeed no writer for name.pehl.totoe.xml.client.Node in its set of writers.

What's going on here? Do I need to do something in order to get a “pass-through” writer for Node added to the registry? … or am I doing something else wrong, … or is this a bug?

@gallafent gallafent changed the title Node annotated with @Native is not serialised Node annotated with @Native is not serialised - does @Native work at all? Aug 7, 2014
@gallafent
Copy link
Author

I experimentally altered the element to be @Native String anXMLFragment (and serialised the Element I have into that String before serialising the Request), and discovered that in this case the reserved characters are being encoded rather than passed through. This suggests that @Native is not implemented for serialisation!
I only see response tests at https://github.com/hpehl/piriti/tree/646ee1b0164cbb4ff6415d823ee4536cc0e50ee7/dev/src/test/java/name/pehl/piriti/client/native_ , which does back up that feeling I think.
Is that the case, then, that @Native is only implemented for deserialisation, not for serialisation?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant