hpehl / piriti Goto Github PK
View Code? Open in Web Editor NEWJSON and XML Mapper for GWT
JSON and XML Mapper for GWT
What steps will reproduce the problem?
What is the expected output? What do you see instead?
Piriti should just take the runtime value and use the correct Writer.
What version of the product are you using?
0.8, GWT 2.4 devmode
I forgot to mention PropertyInteger extends Property
@mappings({
@mapping(value="fName", path="FirstName"),
@mapping(value="lName", path="LastName")
})
interface ReaderWriter extends XmlReaderWriter{}
with public class Name{
String fName;
String lName"
}
generates a reader and writer looking for the paths lName and fName in the xml. It works correctly if you create and separate reader and writer using the mappings with following Xml:
<Name> <FirstName>john</FirstName> <LastName>doe</LastName> </Name>
What steps will reproduce the problem?
Linking modules
Bootstrap link for command-line module 'XXXXX'
Linking module 'XXXXX'
Invoking Linker Cross-Site-Iframe
[ERROR] The Cross-Site-Iframe linker does not support <script> tags in the gwt.xml files, but the gwt.xml file (or the gwt.xml files which it includes) contains the following script tags:
jsonpath.js
In order for your application to run correctly, you will need to include these tags in your host page directly. In order to avoid this error, you will need to remove the script tags from the gwt.xml file, or add this property to the gwt.xml file: <set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/>
[ERROR] shell failed in doSlowStartup method
Is possible to fix this by adding the file directly to the html file and seting the parameter, but it would be nice if you could mayble avoid using the script tag to fix this issue.
I guess instead of putting the script files in the Module.xml file it probably makes sense to add them to a ClientBundle and use SCriptInjector to inject them
I'm using piriti for XML mapping in GWT application. I have not found the ability to map XML value. For example for this class:
public class Option
{
private String id;
private String text;
}
I want to get this XML:
<option id="1">Java</option>
With pirti I only can get this:
<option id="1">
<text>Java</text>
</option>
My question is whether there is a possibility to get XML value or maybe are you going to upgrade piriti?
A mapping like this
public class Option {
@Path("@id") private String id;
@Path("text()") private String name;
// getters & setters
}
does work for reading, but not for writing.
What steps will reproduce the problem?
@Mappings({
@Mapping( value="display", path="@display"),
@Mapping( value="displayName", path="@displayName"),
@Mapping( value="href", path="@href", convert= UriConverter.class),
@Mapping( value="icon", path="@icon", convert= UriConverter.class),
@Mapping( value="is", path="@is", convert = ContractConverter.class),
@Mapping( value="isNull", path="@isNull"),
@Mapping( value="name", path="@name"),
@Mapping( value="status", path="@status"),
@Mapping( value="writable", path="@writable"),
@Mapping( value="childrens", path="child::*", createWith= ObjCreator.class)
})
public interface ObjXmlReader extends XmlReader<Obj>{}
@Mappings({
@Mapping( value="in", path="@in", convert= ContractConverter.class),
@Mapping( value="out", path="@out", convert= ContractConverter.class)
})
public interface OpXmlReader extends XmlReader<Op>{}
It look like in subClasses, Piriti forgot that the class files was mapped to an attribute of the current element, and instead look for an child element ...
As a result I can't mapp any attributes to subclasses of class Obj.
What version of the product are you using? On what operating system?
Pririti 0.8, Restlet 2.05, Gwt 2.4, Windows XP, Firefox 3.6
https://code.google.com/p/piriti/issues/attachmentText?id=58&aid=580002001&name=Op.java&token=NNIGCtYwlCdmNqfxfDZ_uyyaKcU%3A1351504668855
https://code.google.com/p/piriti/issues/attachmentText?id=58&aid=580002000&name=Obj.java&token=H3VR7g2Mkbdgm-YHrhtQr62Smjg%3A1351504668855
i use lot of modals and end up 66k of piriti json.read, json.write compiled java scripts. Anyway to reduce output size?
What steps will reproduce the problem?
public class SomeClass
{
@Path("field")
public String text;
@Path("field/@name")
public String name;
}
What is the expected output? What do you see instead?
Expected:
<?xml version="1.0" encoding="UTF-8"?>
<someClass>
<field name="nameValue">value</field>
</someClass>
Actual result:
<?xml version="1.0" encoding="UTF-8"?>
<someClass>
<field>value</field>
<field name="nameValue"/>
</someClass>
What version of the product are you using? On what operating system?
0.8, Java 1.6, GWT 2.4.0
Please provide any additional information below.
Mapping XML -> POJO works fine, it's just POJO -> XML that breaks.
Due to this change in GWT 2.6.0:
https://groups.google.com/forum/#!topic/Google-Web-Toolkit/QnD_mq8I1o0
If an object gets read from Json with a null value, it will not be "null" in the javascript object but instead "undefined"
for your info
[WARN] Call to Enum method valueOf when enum obfuscation is enabled: name/pehl/piriti/json/client/AbstractJsonWriter.java:66
[WARN] Call to Enum method valueOf when enum obfuscation is enabled: name/pehl/piriti/json/client/AbstractJsonWriter.java:75
[WARN] Call to Enum method valueOf when enum obfuscation is enabled: name/pehl/piriti/json/client/AbstractJsonWriter.java:85
[WARN] Call to Enum method valueOf when enum obfuscation is enabled: name/pehl/piriti/json/client/AbstractJsonWriter.java:96
[WARN] Call to Enum method valueOf when enum obfuscation is enabled: name/pehl/piriti/json/client/AbstractJsonWriter.java:107
[WARN] Call to Enum method valueOf when enum obfuscation is enabled: name/pehl/piriti/json/client/AbstractJsonWriter.java:118
[WARN] Call to Enum method valueOf when enum obfuscation is enabled: name/pehl/piriti/json/client/AbstractJsonWriter.java:129
[WARN] Call to Enum method valueOf when enum obfuscation is enabled: name/pehl/piriti/converter/client/LongConverter.java:17
[WARN] Call to Enum method valueOf when enum obfuscation is enabled: name/pehl/piriti/converter/client/BooleanConverter.java:27
[WARN] Call to Enum method valueOf when enum obfuscation is enabled: name/pehl/piriti/converter/client/IntegerConverter.java:17
[WARN] Call to Enum method valueOf when enum obfuscation is enabled: name/pehl/piriti/converter/client/DoubleConverter.java:17
The JsonWriter methods can return the resulting JSON as a string only, not as a structured JSONObject, which would be much more suitable for further modification and post-processing. Why is this?
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?
I have the following envrioment
GWT 2.5.1
Piriti 0.10
GWT module has the configured
I have all required libs included on my classpath
I traced it down to when I call read or toXml. if i comment these lines, the program compiles..
data = READER_WRITER_REFERRAL_DETAIL.getXmlWriter().toXml(detail,"detail");
and
detail = READER_WRITER_REFERRAL_DETAIL.getXmlReader().read(doc);
any ideas on how to correct this?
Here is the full source
/**
import name.pehl.piriti.xml.client.XmlReaderWriter;
import name.pehl.totoe.xml.client.Document;
import name.pehl.totoe.xml.client.XmlParser;
import com.google.gwt.core.shared.GWT;
import x.x.x.x.ReferralDetail;
import x.x.x.x.ReferralLabel;
public class RMSXmlUtility {
public interface ReferralDetailReaderWriter extends XmlReaderWriter {}
public static final ReferralDetailReaderWriter READER_WRITER_REFERRAL_DETAIL = GWT.create(ReferralDetailReaderWriter.class);
public interface ReferralLabelReaderWriter extends XmlReaderWriter<ReferralLabel> {}
public static final ReferralLabelReaderWriter READER_WRITER_REFERRAL_LABEL = GWT.create(ReferralLabelReaderWriter.class);
public static ReferralDetail getReferralDetail(String xml) {
ReferralDetail detail = null;
try {
Document doc = new XmlParser().parse(xml);
detail = READER_WRITER_REFERRAL_DETAIL.getXmlReader().read(doc);
doc = null;
}catch(Exception e) {
GWT.log(e.getLocalizedMessage());
}
return detail;
}
public static String toXmlFromReferralDetail(ReferralDetail detail) {
String data = null;
try {
data = READER_WRITER_REFERRAL_DETAIL.getXmlWriter().toXml(detail,"detail");
}catch(Exception e) {
GWT.log(e.getLocalizedMessage());
}
return data;
}
}
*/
When I run the GWT Compiler I ger the following
Here is the error
Compiling module x.x.x.x.RMS
Computing all possible rebind results for 'name.pehl.piriti.xml.client.XmlWriter'
Rebinding name.pehl.piriti.xml.client.XmlWriter
Invoking generator name.pehl.piriti.rebind.xml.XmlWriterGenerator
[ERROR] You must use a subtype of XmlWriter in GWT.create(). E.g.,
interface ModelReader extends XmlWriter {}
ModelReader reader = GWT.create(ModelReader.class);
[ERROR] Errors in 'gen/x/x/apps/rms/client/ui/utility/RMSXmlUtility_ReferralDetailReaderWriterImpl_RMSXmlUtility_ReferralDetailReaderWriterImplXmlWriterImpl.java'
[ERROR] Line 766: Failed to resolve 'name.pehl.piriti.xml.client.XmlWriter' via deferred binding
Computing all possible rebind results for 'name.pehl.piriti.xml.client.XmlWriter'
Rebinding name.pehl.piriti.xml.client.XmlWriter
Invoking generator name.pehl.piriti.rebind.xml.XmlWriterGenerator
[ERROR] You must use a subtype of XmlWriter in GWT.create(). E.g.,
interface ModelReader extends XmlWriter {}
ModelReader reader = GWT.create(ModelReader.class);
[ERROR] Errors in 'gen/x/x/apps/rms/client/ui/utility/RMSXmlUtility_ReferralDetailReaderWriterImpl_RMSXmlUtility_ReferralDetailReaderWriterImplXmlWriterImpl.java'
[ERROR] Line 818: Failed to resolve 'name.pehl.piriti.xml.client.XmlWriter' via deferred binding
Computing all possible rebind results for 'name.pehl.piriti.xml.client.XmlWriter'
Rebinding name.pehl.piriti.xml.client.XmlWriter
Invoking generator name.pehl.piriti.rebind.xml.XmlWriterGenerator
[ERROR] You must use a subtype of XmlWriter in GWT.create(). E.g.,
interface ModelReader extends XmlWriter {}
What steps will reproduce the problem?
What is the expected output? What do you see instead?
Everything works fine with the above setup except Writer does not generate json for the Models in payload. It works fine for Integer and String etc in the payload but not for Models. Looks like it just writes toString() of the Model object. How can I handle that?
What version of the product are you using? On what operating system?
I downloaded the latest one.
Please provide any additional information below.
I am using GWTP with Piriti.
just downloaded zip and tried to build and there is a test failure
testRead(name.pehl.piriti.client.converter.JsonBackAndForthTest) Time elapsed: 0.535 sec <<< FAILURE!
junit.framework.AssertionFailedError: Remote test failed at xx.xx.xx.xxx / Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
expected: <11>, actual: <6>
at junit.framework.Assert.fail(Assert.java:193)
at junit.framework.Assert.failNotEquals(Assert.java:198)
at junit.framework.Assert.assertEquals(Assert.java:94)
at junit.framework.Assert.assertEquals(Assert.java:43)
at name.pehl.piriti.client.converter.AbstractBackAndForthTest.assertDateTime(AbstractBackAndForthTest.java:46)
at name.pehl.piriti.client.converter.AbstractBackAndForthTest.assertBackAndForth(AbstractBackAndForthTest.java:19)
at name.pehl.piriti.client.converter.JsonBackAndForthTest.testRead(JsonBackAndForthTest.java:18)
at name.pehl.piriti.client.converter.__JsonBackAndForthTest_unitTestImpl.doRunTest(__JsonBackAndForthTest_unitTestImpl.java:10)
at junit.framework.TestCase.runTest(TestCase.java:62)
at com.google.gwt.junit.client.GWTTestCase.runBare(GWTTestCase.java:188)
at com.google.gwt.junit.client.GWTTestCase.__doRunTest(GWTTestCase.java:129)
at com.google.gwt.junit.client.impl.GWTRunner.runTest(GWTRunner.java:390)
at com.google.gwt.junit.client.impl.GWTRunner.doRunTest(GWTRunner.java:318)
at com.google.gwt.junit.client.impl.GWTRunner.access$9(GWTRunner.java:312)
at com.google.gwt.junit.client.impl.GWTRunner$TestBlockListener.onSuccess(GWTRunner.java:107)
at com.google.gwt.junit.client.impl.GWTRunner$TestBlockListener.onSuccess(GWTRunner.java:1)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:232)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:258)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:249)
at sun.reflect.GeneratedMethodAccessor64.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:724)
testRead(name.pehl.piriti.client.converter.JsonBackAndForthTest) Time elapsed: 0.553 sec <<< FAILURE!
junit.framework.AssertionFailedError: Remote test failed at xx.xx.xx.xxx / Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.19) Gecko/2010031422 Firefox/3.0.19
expected: <11>, actual: <6>
at junit.framework.Assert.fail(Assert.java:193)
at junit.framework.Assert.failNotEquals(Assert.java:198)
at junit.framework.Assert.assertEquals(Assert.java:94)
at junit.framework.Assert.assertEquals(Assert.java:43)
at name.pehl.piriti.client.converter.AbstractBackAndForthTest.assertDateTime(AbstractBackAndForthTest.java:46)
at name.pehl.piriti.client.converter.AbstractBackAndForthTest.assertBackAndForth(AbstractBackAndForthTest.java:19)
at name.pehl.piriti.client.converter.JsonBackAndForthTest.testRead(JsonBackAndForthTest.java:18)
at name.pehl.piriti.client.converter.__JsonBackAndForthTest_unitTestImpl.doRunTest(__JsonBackAndForthTest_unitTestImpl.java:10)
at junit.framework.TestCase.runTest(TestCase.java:62)
at com.google.gwt.junit.client.GWTTestCase.runBare(GWTTestCase.java:188)
at com.google.gwt.junit.client.GWTTestCase.__doRunTest(GWTTestCase.java:129)
at com.google.gwt.junit.client.impl.GWTRunner.runTest(GWTRunner.java:390)
at com.google.gwt.junit.client.impl.GWTRunner.doRunTest(GWTRunner.java:318)
at com.google.gwt.junit.client.impl.GWTRunner.access$9(GWTRunner.java:312)
at com.google.gwt.junit.client.impl.GWTRunner$TestBlockListener.onSuccess(GWTRunner.java:107)
at com.google.gwt.junit.client.impl.GWTRunner$TestBlockListener.onSuccess(GWTRunner.java:1)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:232)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:258)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:249)
at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:724)
What steps will reproduce the problem?
I added the maven-dependencies as shown in the wiki, added the json-inherits to gwt.xml ( name.pehl.piriti.json.JSON ) and received this error at startup:
Loading inherited module 'name.pehl.piriti.json.JSON'
Loading inherited module 'com.google.gwt.inject.Inject'
[ERROR] Unable to find 'com/google/gwt/inject/Inject.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
[ERROR] Line 5: Unexpected exception while processing element 'inherits'
What version of the product are you using? On what operating system?
GWT 2.4, Eclipse 4.2.0, m2e 1.1.0 on Windows 7
Please provide any additional information below.
Looks to me like GIN is not available, it is not listed as a dependency for piri ( in eclipse m2e dependency hierarchy ) but seems to be neccessary.
Enums serialized via it's ordinal value will get sent in JSON notation as an integer. In piriti in the enum.vm template for the reader there is a check if the sent value is a string. So currently we cannot use enum ordinal serialization. Even if we tried to implement a converter it would not kick in, as it is only called after the string check.
We propose an extension to the enum.vm reader template like the following:
so something like this (beware, not syntax checked or tried)
if (${jsonValue}.isNull() == null)
{
JSONString jsonString = ${jsonValue}.isString();
if (jsonString != null)
{
// [..]
}
else
{
$valueType[] values = $valueType.values();
if (0 <= $jsonValue && $jsonValue < values.length)
{
$value = values[$jsonValue];
}
}
}
would ensure the reader works out of the box with enums serialized as name and as ordinal without any need for configuration.
For the writer something similar, but with some new configuration switch.
if ($value != null)
{
#if ($property.converter)
#createConverter()
String $valueAsString = ${converter}.serialize($value);
#else
#if ($property.asOrdinal)
String $valueAsString = $value.ordinal();
#else
String $valueAsString = String.valueOf($value);
#end
#end
if (isNumber($valueAsString))
{
out.append($valueAsString);
}
else
{
out.append(JsonUtils.escapeValue($valueAsString));
}
}
else
{
out.append("null");
}
Currently Pirity marshals "null" to empty tags:
String foo = null;
becomes
<foo\>
Unmarshalling that back to a java object with JaxB will cause "foo" to be an empty string, rather than null.
Would it be possible to add the ability to omit the tag when marshalling "null"s?
I’m hoping to serialize a list of objects to XML using polymorphic references. My setup seems to work successfully in GWT dev mode, however I run into compile time errors on my official build machine. I have a base class with xml reader/writers defined, subclasses with xml reader/writers also defined, and a wrapper class that contains only a list of base class objects, also with its own xml reader/writer. The compilation error involves the wrapper class, and seems to come from the fact that it both utilizes the @createwith annotation, and also has xml readers/writers defined for it. If I comment out the @createwith annotation, my project compiles successfully. Below is the wrapper class in its entirety. I have attached the error log, which contains 2 distinct errors. First is a classnotfoundexception, but I noticed that this disappears when I comment out the reader/writer in the wrapper class, so perhaps it is a symptom of the second error? Second is an IllegalArgumentException, complaining of object is not an instance of declaring class.
Is it that the existence of the @createwith tag is somehow mucking up compilation? Any insight you could provide would be greatly appreciated. For reference, I am using the following versions:
public class SavedWorkspace {
public interface SavedWorkspaceReader extends XmlReader<SavedWorkspace> {}
public static final SavedWorkspaceReader XmlReader = GWT.create(SavedWorkspaceReader.class);
public interface SavedWorkspaceWriter extends XmlWriter<SavedWorkspace> {}
public static final SavedWorkspaceWriter XmlWriter = GWT.create(SavedWorkspaceWriter.class);
@CreateWith(WorkspaceViewStateCreator.class)
@Path("viewStates/view")
private List<WorkspaceViewState> viewStates;
public SavedWorkspace() {
}
public SavedWorkspace(List<WorkspaceViewState> viewStates) {
this.viewStates = viewStates;
}
public List<WorkspaceViewState> getViewStates() {
return viewStates;
}
public void setViewStates(List<WorkspaceViewState> viewStates) {
this.viewStates = viewStates;
}
}
Hello Harald,
I am using Piriti on a Restlet / Gwt project fro sole time now. I had a probleme while serializing a list of objects ex: List with the objects in the list all extending the original type. In the XML produced I need to have the list elements with theirs tag name to be the name of the extending class. Actually the list elements names are derived from the list name ....
Per example I have a List, and objects Volkswagen, Saab and Renault all extend Car. Say I have such a list and objects Volkswagen, Saab and Renault in it. I'll need the poduced XMl to look like:
To manage that, I had to modify the Velocity templates in pririt-dev, in /src/main/resources/name.pehl.pririti.rebind.xml.writer.property.collection.vm, begining in lines 20, from
if (currentValue != null)
{
#parse($property.templates.elementType)
}
else
{
collectionXmlBuilder.append(nestedPath);
}
to:
if (currentValue != null)
{
#if (!$property.xpath)
String nestedElementName = currentValue.getClass().getName();
nestedPath = nestedElementName.substring(nestedElementName.lastIndexOf(".")+1).toLowerCase();
#end
#parse($property.templates.elementType)
}
else
{
collectionXmlBuilder.append("$property.pathOrName");
}
This way, if in a XMLWrtiter mapping for a collection element, I do not indicate the path, the class name of each collection element is used as the name of the tage, example:
@mapping( value="childrens", path="" ),
I do not have the same problem with the XMLReader part, because I can use this expression:
@mapping( value="childrens", path="child::*", createWith= ObjCreator.class),
Do you think it is something we could push back into piriti ?
Thanks
Laurent.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.