i am trying the following:
class MyGrid extends FlexTable
....
interface MyGridJsonizer extends Jsonizer
public String toJsonString(MyGrid g)
{
final MyGridJsonizer jsonizer = (MyJsonizer)
GWT.create(MyJsonizer.class);
return jsonizer.asString(g);
}
In hosted mode I am getting the following error:
[ERROR] Errors in 'transient source for
com.google.gwt.user.client.ui.__HTMLTableJsonizer_impl__'
[ERROR] Line 5: Cannot instantiate the type HTMLTable
HTMLTable is in my classpath since the gwt-user.jar is.
Is this an issue with inheritence ? do I have to define a Jsonizer
interface for each super class ?
Do Jsonizer interfaces have to be in the same package as the classes
themselves ?
What do I have ot do to solve this issue ?
- Ron
thanks.
while testing i further found the following issues:
1. In the example it should be
RootPanel.get("slot1").add(searchButton); the slot names are wrong.
2. The following code throws an error although it should not:
Person p = new Person();
PersonJsonizer jsonizer =
(PersonJsonizer)GWT.create(PersonJsonizer.class);
String t = jsonizer.asString(p);
p = (Person) JsonizerParser.parse(jsonizer, t);
I have been able to follow this to:
BeanJsonizer:
if(!jsonizer.containsRequiredProperties(values))
returning false.
3. I have the following questions/suggestions:
Why do you require the interface PersonJsonizer ? Would it not be
enough to have Person implement some marker interface for example
"Jsonizable" which would indicate to the Generator that this class has
to be processed ? this interface would be sufficient to trigger the
generator.
Why not put in the json object a property javaClass : <full java class
name> ?
This will avoid having to know in advance which jsonizer is required.
It would also enable working with java json-rpc (which sets this
property) and reduce the call to : JsonizerParser.parse(t); the
correct jsonizer could be found within the parse method by reading
this property.
- Ron
I know the need of include the class name in the JSON object, but the
jsonizer was first designed to support generic and plain JSON. I'm
currently developing a new version of the API wich supports several
JSON variants.
Using a Jsonizable interface for bean demarcation also requires
another interface to dejsonize beans. I'm thinking in a Jsonizer
refatorization to avoid these troubles.