Giter Club home page Giter Club logo

Comments (20)

ralscha avatar ralscha commented on July 30, 2024

Hi
Looks like a useful addition. Indeed the convert function could be a bit
difficult, because the model generator is using jackson for serialization.
But I'm sure there is a solution for this.
Would be nice if you could contribut some code. I'm happy to integrate this
into the next release.

Ralph

On Sat, Nov 24, 2012 at 2:37 AM, dilbertside [email protected]:

Hi,

I had in mind to upgrade to the new model generator as I have a new grid
to build from a deprecated one.
Every thing is fine so far.
But I face a problem with one single column type 'checkcolumn' which is a
virtual field in the original model.
code
fields: [
....
,{name: 'sl', type: 'string'}
,{name: 'ac', type: 'bool', //Virtual Field
mapping: 'sl', persist: false,
convert: function(v, record) {
var a = record.raw.sl.split('|');
return (a.length > 1);
}
}
],
......

Question is: will it be possible to extend the model generator to produce
this virtual field.
The difficult part is maybe the convert function but I have some ode
somewhere which I made for a metachange store event , I was sending a
convert function from the backend without troubles.
I could contribute for that bit or more if you want.

What do you think?


Reply to this email directly or view it on GitHubhttps://github.com//issues/50.

from extdirectspring.

dilbertside avatar dilbertside commented on July 30, 2024

Ok. I propose a draft on my fork.

On 11/24/2012 09:47 AM, Ralph Schaer wrote:

Hi
Looks like a useful addition. Indeed the convert function could be a bit
difficult, because the model generator is using jackson for
serialization.
But I'm sure there is a solution for this.
Would be nice if you could contribut some code. I'm happy to integrate
this
into the next release.

Ralph

On Sat, Nov 24, 2012 at 2:37 AM, dilbertside
[email protected]:

Hi,

I had in mind to upgrade to the new model generator as I have a new
grid
to build from a deprecated one.
Every thing is fine so far.
But I face a problem with one single column type 'checkcolumn' which
is a
virtual field in the original model.
code
fields: [
....
,{name: 'sl', type: 'string'}
,{name: 'ac', type: 'bool', //Virtual Field
mapping: 'sl', persist: false,
convert: function(v, record) {
var a = record.raw.sl.split('|');
return (a.length > 1);
}
}
],
......

Question is: will it be possible to extend the model generator to
produce
this virtual field.
The difficult part is maybe the convert function but I have some ode
somewhere which I made for a metachange store event , I was sending a
convert function from the backend without troubles.
I could contribute for that bit or more if you want.

What do you think?


Reply to this email directly or view it on
GitHubhttps://github.com//issues/50.


Reply to this email directly or view it on GitHub
#50 (comment).

from extdirectspring.

dilbertside avatar dilbertside commented on July 30, 2024

draft committed;
2 remarks

I suggest the following version
the java script engine will parse it and I guess create an appropriate
object, when the Ext.onReady is called (inconvenience, cannot reload the
model dynamically, and inject it)
@ModelField(mapping="bigValue", persist=false, convert="function(v,
record) { return (record.raw.bigValue > 1000000);}")

 this one is maybe useless as it might not be needed to instantiate 

a function on the fly, but will provide a way to inject the model when
the app is already instanciated
@ModelField(mapping="bigValue", persist=false, convert="new
Function('v', 'record', return (record.raw.bigValue > 1000000);)")


In the unit test I hit a problem as by default the model generator set
mapper.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, false);

problem in the case of the convert function, it is not required,
possible solution json mixin? ;-)

do you have another idea to cancel this quote field name for that single
field?

Regards,

On 11/24/2012 09:47 AM, Ralph Schaer wrote:

Hi
Looks like a useful addition. Indeed the convert function could be a bit
difficult, because the model generator is using jackson for
serialization.
But I'm sure there is a solution for this.
Would be nice if you could contribut some code. I'm happy to integrate
this
into the next release.

Ralph

On Sat, Nov 24, 2012 at 2:37 AM, dilbertside
[email protected]:

Hi,

I had in mind to upgrade to the new model generator as I have a new
grid
to build from a deprecated one.
Every thing is fine so far.
But I face a problem with one single column type 'checkcolumn' which
is a
virtual field in the original model.
code
fields: [
....
,{name: 'sl', type: 'string'}
,{name: 'ac', type: 'bool', //Virtual Field
mapping: 'sl', persist: false,
convert: function(v, record) {
var a = record.raw.sl.split('|');
return (a.length > 1);
}
}
],
......

Question is: will it be possible to extend the model generator to
produce
this virtual field.
The difficult part is maybe the convert function but I have some ode
somewhere which I made for a metachange store event , I was sending a
convert function from the backend without troubles.
I could contribute for that bit or more if you want.

What do you think?


Reply to this email directly or view it on
GitHubhttps://github.com//issues/50.


Reply to this email directly or view it on GitHub
#50 (comment).

from extdirectspring.

dilbertside avatar dilbertside commented on July 30, 2024

actually I'm wrong this
mapper.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, false); has no
incidence...

On 11/24/2012 09:47 AM, Ralph Schaer wrote:

Hi
Looks like a useful addition. Indeed the convert function could be a bit
difficult, because the model generator is using jackson for
serialization.
But I'm sure there is a solution for this.
Would be nice if you could contribut some code. I'm happy to integrate
this
into the next release.

Ralph

On Sat, Nov 24, 2012 at 2:37 AM, dilbertside
[email protected]:

Hi,

I had in mind to upgrade to the new model generator as I have a new
grid
to build from a deprecated one.
Every thing is fine so far.
But I face a problem with one single column type 'checkcolumn' which
is a
virtual field in the original model.
code
fields: [
....
,{name: 'sl', type: 'string'}
,{name: 'ac', type: 'bool', //Virtual Field
mapping: 'sl', persist: false,
convert: function(v, record) {
var a = record.raw.sl.split('|');
return (a.length > 1);
}
}
],
......

Question is: will it be possible to extend the model generator to
produce
this virtual field.
The difficult part is maybe the convert function but I have some ode
somewhere which I made for a metachange store event , I was sending a
convert function from the backend without troubles.
I could contribute for that bit or more if you want.

What do you think?


Reply to this email directly or view it on
GitHubhttps://github.com//issues/50.


Reply to this email directly or view it on GitHub
#50 (comment).

from extdirectspring.

dilbertside avatar dilbertside commented on July 30, 2024

ok got it by using @JsonRawValue

On 11/24/2012 09:47 AM, Ralph Schaer wrote:

Hi
Looks like a useful addition. Indeed the convert function could be a bit
difficult, because the model generator is using jackson for
serialization.
But I'm sure there is a solution for this.
Would be nice if you could contribut some code. I'm happy to integrate
this
into the next release.

Ralph

On Sat, Nov 24, 2012 at 2:37 AM, dilbertside
[email protected]:

Hi,

I had in mind to upgrade to the new model generator as I have a new
grid
to build from a deprecated one.
Every thing is fine so far.
But I face a problem with one single column type 'checkcolumn' which
is a
virtual field in the original model.
code
fields: [
....
,{name: 'sl', type: 'string'}
,{name: 'ac', type: 'bool', //Virtual Field
mapping: 'sl', persist: false,
convert: function(v, record) {
var a = record.raw.sl.split('|');
return (a.length > 1);
}
}
],
......

Question is: will it be possible to extend the model generator to
produce
this virtual field.
The difficult part is maybe the convert function but I have some ode
somewhere which I made for a metachange store event , I was sending a
convert function from the backend without troubles.
I could contribute for that bit or more if you want.

What do you think?


Reply to this email directly or view it on
GitHubhttps://github.com//issues/50.


Reply to this email directly or view it on GitHub
#50 (comment).

from extdirectspring.

ralscha avatar ralscha commented on July 30, 2024

This @JsonRawValue is interesting. Maybe this could also solve my problem
with directFn,read,... methods. Right now I remove the quotes with a call
to string.replaceAll call.

On Sat, Nov 24, 2012 at 5:03 AM, dilbertside [email protected]:

@JsonRawValue

from extdirectspring.

dilbertside avatar dilbertside commented on July 30, 2024

ah that's the reason I saw those regexes, get it now.

certainly, will do and avoid overhead: end result faster.

I still have pending problem with the test
a single quote is added to the string to compare
});'

in
compareExtJs4Model(ModelGenerator.generateJavascript(BeanWithAnnotations.class,
OutputFormat.EXTJS4, true),
true);
in testGenerateJavascriptClassOfQOutputFormatBoolean

I don't understand why as I stick to your model as close as possible

On 11/24/2012 12:11 PM, Ralph Schaer wrote:

This @JsonRawValue is interesting. Maybe this could also solve my problem
with directFn,read,... methods. Right now I remove the quotes with a call
to string.replaceAll call.

On Sat, Nov 24, 2012 at 5:03 AM, dilbertside
[email protected]:

@JsonRawValue


Reply to this email directly or view it on GitHub
#50 (comment).

from extdirectspring.

ralscha avatar ralscha commented on July 30, 2024

Don't have a problem with this test. It's only missing the two new fields.
I don't have a ' at the end.

On Sat, Nov 24, 2012 at 5:17 AM, dilbertside [email protected]:

ah that's the reason I saw those regexes, get it now.

certainly, will do and avoid overhead: end result faster.

I still have pending problem with the test
a single quote is added to the string to compare
});'

in
compareExtJs4Model(ModelGenerator.generateJavascript(BeanWithAnnotations.class,

OutputFormat.EXTJS4, true),
true);
in testGenerateJavascriptClassOfQOutputFormatBoolean

I don't understand why as I stick to your model as close as possible

On 11/24/2012 12:11 PM, Ralph Schaer wrote:

This @JsonRawValue is interesting. Maybe this could also solve my problem
with directFn,read,... methods. Right now I remove the quotes with a call
to string.replaceAll call.

On Sat, Nov 24, 2012 at 5:03 AM, dilbertside
[email protected]:

@JsonRawValue


Reply to this email directly or view it on GitHub
<
https://github.com/ralscha/extdirectspring/issues/50#issuecomment-10673725>.


Reply to this email directly or view it on GitHubhttps://github.com//issues/50#issuecomment-10673767.

from extdirectspring.

ralscha avatar ralscha commented on July 30, 2024

I'm wondering if we can improve this a bit more. If I'm understand this
correctly then
private boolean aBooleanVirtual;
is an useless instance variable.

Maybe we can put two @ModelField annotation on one field. Something like
this:

@ModelFields({
@ModelField,
@ModelField(mapping="bigValue", persist=false, convert="function(v,
record) { return (record.raw.bigValue >
1000000);}")
})
private BigInteger bigValue;

On Sat, Nov 24, 2012 at 5:28 AM, Ralph Schaer [email protected] wrote:

Don't have a problem with this test. It's only missing the two new fields.
I don't have a ' at the end.

On Sat, Nov 24, 2012 at 5:17 AM, dilbertside [email protected]:

ah that's the reason I saw those regexes, get it now.

certainly, will do and avoid overhead: end result faster.

I still have pending problem with the test
a single quote is added to the string to compare
});'

in
compareExtJs4Model(ModelGenerator.generateJavascript(BeanWithAnnotations.class,

OutputFormat.EXTJS4, true),
true);
in testGenerateJavascriptClassOfQOutputFormatBoolean

I don't understand why as I stick to your model as close as possible

On 11/24/2012 12:11 PM, Ralph Schaer wrote:

This @JsonRawValue is interesting. Maybe this could also solve my
problem
with directFn,read,... methods. Right now I remove the quotes with a
call
to string.replaceAll call.

On Sat, Nov 24, 2012 at 5:03 AM, dilbertside
[email protected]:

@JsonRawValue


Reply to this email directly or view it on GitHub
<
https://github.com/ralscha/extdirectspring/issues/50#issuecomment-10673725>.


Reply to this email directly or view it on GitHubhttps://github.com//issues/50#issuecomment-10673767.

from extdirectspring.

dilbertside avatar dilbertside commented on July 30, 2024

Well, agree, Java speaking it is useless.
But in terms of extjs model we still need it, the generator need to
build this variable and its name.
So it will be used by Extjs library.
Without name this virtual field is useless on extjs side.

If you are concerned about having this variable being jsonified at
runtime, it is better to include @JsonInclude(Include.NON_NULL)
So this variable won't be instantiated at runtime by being set at null
permanently.

If you want to keep your proposition it should be amended as following:

@ModelFields({
@ModelField,
@ModelField(value=aBooleanVirtual, mapping="bigValue", persist=false,
convert="function(v,
record) { return (record.raw.bigValue >1000000);}")
})
private BigInteger bigValue;

what I would propose to keep it simple is to :
@model(...)
@JsonInclude(Include.NON_NULL)
public class BeanWithAnnotations {
private BigInteger bigValue;

 @ModelField(mapping="bigValue", persist=false, convert="function(v, 

record) { return (record.raw.bigValue > 1000000);}")
private boolean aBooleanVirtual = null;
}

Inconvenience with my system is the developer responsibility to add this
include.
But it keeps things flexible for unexpected use.


or why not provide a singular implementation expanding your idea.
@ModelFields({
@ModelField,
@virtualfield(value=aBooleanVirtual, mapping="bigValue", persist=false,
convert="function(v,
record) { return (record.raw.bigValue >1000000);}")
})
private BigInteger bigValue;

Order is very important, this virtual field HAS to be created after the
mapped field (in our case bigValue)
in that case it could be also

@ModelFields({
@ModelField("bigValueCustomName"),
@virtualfield(value=aBooleanVirtual, convert="function(v,
record) { return (record.raw.bigValueCustomName >1000000);}")
})
private BigInteger bigValue;

will produce:

... , {
name : 'bigValueCustomName',
type : 'int'
}, {
name : 'aBooleanVirtual',
type : 'boolean',
mapping : 'bigValueCustomName',
persist : false,
convert : function(v, record) { return
(record.raw.bigValueCustomName > 1000000);}
},...

What do you think?

On 11/24/2012 12:39 PM, Ralph Schaer wrote:

I'm wondering if we can improve this a bit more. If I'm understand this
correctly then
private boolean aBooleanVirtual;
is an useless instance variable.

Maybe we can put two @ModelField annotation on one field. Something like
this:

@ModelFields({
@ModelField,
@ModelField(mapping="bigValue", persist=false, convert="function(v,
record) { return (record.raw.bigValue >
1000000);}")
})
private BigInteger bigValue;

On Sat, Nov 24, 2012 at 5:28 AM, Ralph Schaer [email protected]
wrote:

Don't have a problem with this test. It's only missing the two new
fields.
I don't have a ' at the end.

On Sat, Nov 24, 2012 at 5:17 AM, dilbertside
[email protected]:

ah that's the reason I saw those regexes, get it now.

certainly, will do and avoid overhead: end result faster.

I still have pending problem with the test
a single quote is added to the string to compare
});'

in

compareExtJs4Model(ModelGenerator.generateJavascript(BeanWithAnnotations.class,

OutputFormat.EXTJS4, true),
true);
in testGenerateJavascriptClassOfQOutputFormatBoolean

I don't understand why as I stick to your model as close as possible

On 11/24/2012 12:11 PM, Ralph Schaer wrote:

This @JsonRawValue is interesting. Maybe this could also solve my
problem
with directFn,read,... methods. Right now I remove the quotes with a
call
to string.replaceAll call.

On Sat, Nov 24, 2012 at 5:03 AM, dilbertside
[email protected]:

@JsonRawValue


Reply to this email directly or view it on GitHub
<

https://github.com/ralscha/extdirectspring/issues/50#issuecomment-10673725>.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/50#issuecomment-10673767.


Reply to this email directly or view it on GitHub
#50 (comment).

from extdirectspring.

ralscha avatar ralscha commented on July 30, 2024

You are right. Let's keep it simple and go with your initial approach with
the two instance variables.
@JsonInclude(Include.NON_NULL) solves the serialization issue quite nicely.

Let me know when your code is ready then I will integrate it into the
current codebase.
Ralph

On Sat, Nov 24, 2012 at 11:10 AM, dilbertside [email protected]:

Well, agree, Java speaking it is useless.
But in terms of extjs model we still need it, the generator need to
build this variable and its name.
So it will be used by Extjs library.
Without name this virtual field is useless on extjs side.

If you are concerned about having this variable being jsonified at
runtime, it is better to include @JsonInclude(Include.NON_NULL)
So this variable won't be instantiated at runtime by being set at null
permanently.

If you want to keep your proposition it should be amended as following:

@ModelFields({
@ModelField,
@ModelField(value=aBooleanVirtual, mapping="bigValue", persist=false,
convert="function(v,
record) { return (record.raw.bigValue >1000000);}")
})
private BigInteger bigValue;

what I would propose to keep it simple is to :
@model(...)
@JsonInclude(Include.NON_NULL)
public class BeanWithAnnotations {
private BigInteger bigValue;

@ModelField(mapping="bigValue", persist=false, convert="function(v,
record) { return (record.raw.bigValue > 1000000);}")
private boolean aBooleanVirtual = null;
}

Inconvenience with my system is the developer responsibility to add this
include.
But it keeps things flexible for unexpected use.


or why not provide a singular implementation expanding your idea.
@ModelFields({
@ModelField,
@virtualfield(value=aBooleanVirtual, mapping="bigValue", persist=false,
convert="function(v,
record) { return (record.raw.bigValue >1000000);}")
})
private BigInteger bigValue;

Order is very important, this virtual field HAS to be created after the
mapped field (in our case bigValue)
in that case it could be also

@ModelFields({
@ModelField("bigValueCustomName"),
@virtualfield(value=aBooleanVirtual, convert="function(v,
record) { return (record.raw.bigValueCustomName >1000000);}")
})
private BigInteger bigValue;

will produce:

... , {
name : 'bigValueCustomName',
type : 'int'
}, {
name : 'aBooleanVirtual',
type : 'boolean',
mapping : 'bigValueCustomName',
persist : false,
convert : function(v, record) { return
(record.raw.bigValueCustomName > 1000000);}
},...

What do you think?

On 11/24/2012 12:39 PM, Ralph Schaer wrote:

I'm wondering if we can improve this a bit more. If I'm understand this
correctly then
private boolean aBooleanVirtual;
is an useless instance variable.

Maybe we can put two @ModelField annotation on one field. Something like
this:

@ModelFields({
@ModelField,
@ModelField(mapping="bigValue", persist=false, convert="function(v,
record) { return (record.raw.bigValue >
1000000);}")
})
private BigInteger bigValue;

On Sat, Nov 24, 2012 at 5:28 AM, Ralph Schaer [email protected]
wrote:

Don't have a problem with this test. It's only missing the two new
fields.
I don't have a ' at the end.

On Sat, Nov 24, 2012 at 5:17 AM, dilbertside
[email protected]:

ah that's the reason I saw those regexes, get it now.

certainly, will do and avoid overhead: end result faster.

I still have pending problem with the test
a single quote is added to the string to compare
});'

in

compareExtJs4Model(ModelGenerator.generateJavascript(BeanWithAnnotations.class,

OutputFormat.EXTJS4, true),
true);
in testGenerateJavascriptClassOfQOutputFormatBoolean

I don't understand why as I stick to your model as close as possible

On 11/24/2012 12:11 PM, Ralph Schaer wrote:

This @JsonRawValue is interesting. Maybe this could also solve my
problem
with directFn,read,... methods. Right now I remove the quotes with a
call
to string.replaceAll call.

On Sat, Nov 24, 2012 at 5:03 AM, dilbertside
[email protected]:

@JsonRawValue


Reply to this email directly or view it on GitHub
<

#50 (comment)
.


Reply to this email directly or view it on
GitHub<
#50 (comment)
.


Reply to this email directly or view it on GitHub
<
https://github.com/ralscha/extdirectspring/issues/50#issuecomment-10673909>.


Reply to this email directly or view it on GitHubhttps://github.com//issues/50#issuecomment-10676058.

from extdirectspring.

dilbertside avatar dilbertside commented on July 30, 2024

code is ready on my side with latest push, very simple to implement, but
got problems to run unittests, always fail in my env.
Either Eclipse or CLI fail.
It is annoying as I fail to see what's wrong. I got nothing different
than my fork.

Fortunately, code is valid for Touch with no change.

On 11/24/2012 06:53 PM, Ralph Schaer wrote:

You are right. Let's keep it simple and go with your initial approach
with
the two instance variables.
@JsonInclude(Include.NON_NULL) solves the serialization issue quite
nicely.

Let me know when your code is ready then I will integrate it into the
current codebase.
Ralph

On Sat, Nov 24, 2012 at 11:10 AM, dilbertside
[email protected]:

Well, agree, Java speaking it is useless.
But in terms of extjs model we still need it, the generator need to
build this variable and its name.
So it will be used by Extjs library.
Without name this virtual field is useless on extjs side.

If you are concerned about having this variable being jsonified at
runtime, it is better to include @JsonInclude(Include.NON_NULL)
So this variable won't be instantiated at runtime by being set at null
permanently.

If you want to keep your proposition it should be amended as following:

@ModelFields({
@ModelField,
@ModelField(value=aBooleanVirtual, mapping="bigValue", persist=false,
convert="function(v,
record) { return (record.raw.bigValue >1000000);}")
})
private BigInteger bigValue;

what I would propose to keep it simple is to :
@model(...)
@JsonInclude(Include.NON_NULL)
public class BeanWithAnnotations {
private BigInteger bigValue;

@ModelField(mapping="bigValue", persist=false, convert="function(v,
record) { return (record.raw.bigValue > 1000000);}")
private boolean aBooleanVirtual = null;
}

Inconvenience with my system is the developer responsibility to add
this
include.
But it keeps things flexible for unexpected use.


or why not provide a singular implementation expanding your idea.
@ModelFields({
@ModelField,
@virtualfield(value=aBooleanVirtual, mapping="bigValue", persist=false,
convert="function(v,
record) { return (record.raw.bigValue >1000000);}")
})
private BigInteger bigValue;

Order is very important, this virtual field HAS to be created after the
mapped field (in our case bigValue)
in that case it could be also

@ModelFields({
@ModelField("bigValueCustomName"),
@virtualfield(value=aBooleanVirtual, convert="function(v,
record) { return (record.raw.bigValueCustomName >1000000);}")
})
private BigInteger bigValue;

will produce:

... , {
name : 'bigValueCustomName',
type : 'int'
}, {
name : 'aBooleanVirtual',
type : 'boolean',
mapping : 'bigValueCustomName',
persist : false,
convert : function(v, record) { return
(record.raw.bigValueCustomName > 1000000);}
},...

What do you think?

On 11/24/2012 12:39 PM, Ralph Schaer wrote:

I'm wondering if we can improve this a bit more. If I'm understand
this
correctly then
private boolean aBooleanVirtual;
is an useless instance variable.

Maybe we can put two @ModelField annotation on one field.
Something like
this:

@ModelFields({
@ModelField,
@ModelField(mapping="bigValue", persist=false, convert="function(v,
record) { return (record.raw.bigValue >
1000000);}")
})
private BigInteger bigValue;

On Sat, Nov 24, 2012 at 5:28 AM, Ralph Schaer [email protected]
wrote:

Don't have a problem with this test. It's only missing the two new
fields.
I don't have a ' at the end.

On Sat, Nov 24, 2012 at 5:17 AM, dilbertside
[email protected]:

ah that's the reason I saw those regexes, get it now.

certainly, will do and avoid overhead: end result faster.

I still have pending problem with the test
a single quote is added to the string to compare
});'

in

compareExtJs4Model(ModelGenerator.generateJavascript(BeanWithAnnotations.class,

OutputFormat.EXTJS4, true),
true);
in testGenerateJavascriptClassOfQOutputFormatBoolean

I don't understand why as I stick to your model as close as
possible

On 11/24/2012 12:11 PM, Ralph Schaer wrote:

This @JsonRawValue is interesting. Maybe this could also
solve my
problem
with directFn,read,... methods. Right now I remove the quotes
with a
call
to string.replaceAll call.

On Sat, Nov 24, 2012 at 5:03 AM, dilbertside
[email protected]:

@JsonRawValue


Reply to this email directly or view it on GitHub
<

#50 (comment)

.


Reply to this email directly or view it on
GitHub<

#50 (comment)

.


Reply to this email directly or view it on GitHub
<

https://github.com/ralscha/extdirectspring/issues/50#issuecomment-10673909>.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/50#issuecomment-10676058.


Reply to this email directly or view it on GitHub
#50 (comment).

from extdirectspring.

dilbertside avatar dilbertside commented on July 30, 2024

I saw you solved the regex api replace on branch next.

If you could push a snapshot, I'll be able to test this enhancement and
changes in a real case scenario.

Thank you.

On 11/24/2012 06:53 PM, Ralph Schaer wrote:

You are right. Let's keep it simple and go with your initial approach
with
the two instance variables.
@JsonInclude(Include.NON_NULL) solves the serialization issue quite
nicely.

Let me know when your code is ready then I will integrate it into the
current codebase.
Ralph

On Sat, Nov 24, 2012 at 11:10 AM, dilbertside
[email protected]:

Well, agree, Java speaking it is useless.
But in terms of extjs model we still need it, the generator need to
build this variable and its name.
So it will be used by Extjs library.
Without name this virtual field is useless on extjs side.

If you are concerned about having this variable being jsonified at
runtime, it is better to include @JsonInclude(Include.NON_NULL)
So this variable won't be instantiated at runtime by being set at null
permanently.

If you want to keep your proposition it should be amended as following:

@ModelFields({
@ModelField,
@ModelField(value=aBooleanVirtual, mapping="bigValue", persist=false,
convert="function(v,
record) { return (record.raw.bigValue >1000000);}")
})
private BigInteger bigValue;

what I would propose to keep it simple is to :
@model(...)
@JsonInclude(Include.NON_NULL)
public class BeanWithAnnotations {
private BigInteger bigValue;

@ModelField(mapping="bigValue", persist=false, convert="function(v,
record) { return (record.raw.bigValue > 1000000);}")
private boolean aBooleanVirtual = null;
}

Inconvenience with my system is the developer responsibility to add
this
include.
But it keeps things flexible for unexpected use.


or why not provide a singular implementation expanding your idea.
@ModelFields({
@ModelField,
@virtualfield(value=aBooleanVirtual, mapping="bigValue", persist=false,
convert="function(v,
record) { return (record.raw.bigValue >1000000);}")
})
private BigInteger bigValue;

Order is very important, this virtual field HAS to be created after the
mapped field (in our case bigValue)
in that case it could be also

@ModelFields({
@ModelField("bigValueCustomName"),
@virtualfield(value=aBooleanVirtual, convert="function(v,
record) { return (record.raw.bigValueCustomName >1000000);}")
})
private BigInteger bigValue;

will produce:

... , {
name : 'bigValueCustomName',
type : 'int'
}, {
name : 'aBooleanVirtual',
type : 'boolean',
mapping : 'bigValueCustomName',
persist : false,
convert : function(v, record) { return
(record.raw.bigValueCustomName > 1000000);}
},...

What do you think?

On 11/24/2012 12:39 PM, Ralph Schaer wrote:

I'm wondering if we can improve this a bit more. If I'm understand
this
correctly then
private boolean aBooleanVirtual;
is an useless instance variable.

Maybe we can put two @ModelField annotation on one field.
Something like
this:

@ModelFields({
@ModelField,
@ModelField(mapping="bigValue", persist=false, convert="function(v,
record) { return (record.raw.bigValue >
1000000);}")
})
private BigInteger bigValue;

On Sat, Nov 24, 2012 at 5:28 AM, Ralph Schaer [email protected]
wrote:

Don't have a problem with this test. It's only missing the two new
fields.
I don't have a ' at the end.

On Sat, Nov 24, 2012 at 5:17 AM, dilbertside
[email protected]:

ah that's the reason I saw those regexes, get it now.

certainly, will do and avoid overhead: end result faster.

I still have pending problem with the test
a single quote is added to the string to compare
});'

in

compareExtJs4Model(ModelGenerator.generateJavascript(BeanWithAnnotations.class,

OutputFormat.EXTJS4, true),
true);
in testGenerateJavascriptClassOfQOutputFormatBoolean

I don't understand why as I stick to your model as close as
possible

On 11/24/2012 12:11 PM, Ralph Schaer wrote:

This @JsonRawValue is interesting. Maybe this could also
solve my
problem
with directFn,read,... methods. Right now I remove the quotes
with a
call
to string.replaceAll call.

On Sat, Nov 24, 2012 at 5:03 AM, dilbertside
[email protected]:

@JsonRawValue


Reply to this email directly or view it on GitHub
<

#50 (comment)

.


Reply to this email directly or view it on
GitHub<

#50 (comment)

.


Reply to this email directly or view it on GitHub
<

https://github.com/ralscha/extdirectspring/issues/50#issuecomment-10673909>.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/50#issuecomment-10676058.


Reply to this email directly or view it on GitHub
#50 (comment).

from extdirectspring.

ralscha avatar ralscha commented on July 30, 2024

Everything is integrated. Unittests are fixed. One of the files contained
an empty line at the end.

There is a 1.2.3-SNAPSHOT that contains everything:
https://oss.sonatype.org/content/repositories/snapshots/ch/ralscha/extdirectspring/1.2.3-SNAPSHOT/extdirectspring-1.2.3-20121124.142141-14.jar

Ralph

On Sat, Nov 24, 2012 at 12:44 PM, dilbertside [email protected]:

I saw you solved the regex api replace on branch next.

If you could push a snapshot, I'll be able to test this enhancement and
changes in a real case scenario.

Thank you.

On 11/24/2012 06:53 PM, Ralph Schaer wrote:

You are right. Let's keep it simple and go with your initial approach
with
the two instance variables.
@JsonInclude(Include.NON_NULL) solves the serialization issue quite
nicely.

Let me know when your code is ready then I will integrate it into the
current codebase.
Ralph

On Sat, Nov 24, 2012 at 11:10 AM, dilbertside
[email protected]:

Well, agree, Java speaking it is useless.
But in terms of extjs model we still need it, the generator need to
build this variable and its name.
So it will be used by Extjs library.
Without name this virtual field is useless on extjs side.

If you are concerned about having this variable being jsonified at
runtime, it is better to include @JsonInclude(Include.NON_NULL)
So this variable won't be instantiated at runtime by being set at null
permanently.

If you want to keep your proposition it should be amended as following:

@ModelFields({
@ModelField,
@ModelField(value=aBooleanVirtual, mapping="bigValue", persist=false,
convert="function(v,
record) { return (record.raw.bigValue >1000000);}")
})
private BigInteger bigValue;

what I would propose to keep it simple is to :
@model(...)
@JsonInclude(Include.NON_NULL)
public class BeanWithAnnotations {
private BigInteger bigValue;

@ModelField(mapping="bigValue", persist=false, convert="function(v,
record) { return (record.raw.bigValue > 1000000);}")
private boolean aBooleanVirtual = null;
}

Inconvenience with my system is the developer responsibility to add
this
include.
But it keeps things flexible for unexpected use.


or why not provide a singular implementation expanding your idea.
@ModelFields({
@ModelField,
@virtualfield(value=aBooleanVirtual, mapping="bigValue", persist=false,
convert="function(v,
record) { return (record.raw.bigValue >1000000);}")
})
private BigInteger bigValue;

Order is very important, this virtual field HAS to be created after the
mapped field (in our case bigValue)
in that case it could be also

@ModelFields({
@ModelField("bigValueCustomName"),
@virtualfield(value=aBooleanVirtual, convert="function(v,
record) { return (record.raw.bigValueCustomName >1000000);}")
})
private BigInteger bigValue;

will produce:

... , {
name : 'bigValueCustomName',
type : 'int'
}, {
name : 'aBooleanVirtual',
type : 'boolean',
mapping : 'bigValueCustomName',
persist : false,
convert : function(v, record) { return
(record.raw.bigValueCustomName > 1000000);}
},...

What do you think?

On 11/24/2012 12:39 PM, Ralph Schaer wrote:

I'm wondering if we can improve this a bit more. If I'm understand
this
correctly then
private boolean aBooleanVirtual;
is an useless instance variable.

Maybe we can put two @ModelField annotation on one field.
Something like
this:

@ModelFields({
@ModelField,
@ModelField(mapping="bigValue", persist=false, convert="function(v,
record) { return (record.raw.bigValue >
1000000);}")
})
private BigInteger bigValue;

On Sat, Nov 24, 2012 at 5:28 AM, Ralph Schaer <[email protected]

wrote:

Don't have a problem with this test. It's only missing the two new
fields.
I don't have a ' at the end.

On Sat, Nov 24, 2012 at 5:17 AM, dilbertside
[email protected]:

ah that's the reason I saw those regexes, get it now.

certainly, will do and avoid overhead: end result faster.

I still have pending problem with the test
a single quote is added to the string to compare
});'

in

compareExtJs4Model(ModelGenerator.generateJavascript(BeanWithAnnotations.class,

OutputFormat.EXTJS4, true),
true);
in testGenerateJavascriptClassOfQOutputFormatBoolean

I don't understand why as I stick to your model as close as
possible

On 11/24/2012 12:11 PM, Ralph Schaer wrote:

This @JsonRawValue is interesting. Maybe this could also
solve my
problem
with directFn,read,... methods. Right now I remove the quotes
with a
call
to string.replaceAll call.

On Sat, Nov 24, 2012 at 5:03 AM, dilbertside
[email protected]:

@JsonRawValue


Reply to this email directly or view it on GitHub
<

#50 (comment)

.


Reply to this email directly or view it on
GitHub<

#50 (comment)

.


Reply to this email directly or view it on GitHub
<

#50 (comment)
.


Reply to this email directly or view it on
GitHub<
#50 (comment)
.


Reply to this email directly or view it on GitHub
<
https://github.com/ralscha/extdirectspring/issues/50#issuecomment-10676397>.


Reply to this email directly or view it on GitHubhttps://github.com//issues/50#issuecomment-10676841.

from extdirectspring.

dilbertside avatar dilbertside commented on July 30, 2024

It works wonderfully.
I tried this virtual field, and generation works seamlessly.

Thank you very much for your great reactivity.

On 11/24/2012 10:25 PM, Ralph Schaer wrote:

Everything is integrated. Unittests are fixed. One of the files contained
an empty line at the end.

There is a 1.2.3-SNAPSHOT that contains everything:
https://oss.sonatype.org/content/repositories/snapshots/ch/ralscha/extdirectspring/1.2.3-SNAPSHOT/extdirectspring-1.2.3-20121124.142141-14.jar

Ralph

On Sat, Nov 24, 2012 at 12:44 PM, dilbertside
[email protected]:

I saw you solved the regex api replace on branch next.

If you could push a snapshot, I'll be able to test this enhancement and
changes in a real case scenario.

Thank you.

On 11/24/2012 06:53 PM, Ralph Schaer wrote:

You are right. Let's keep it simple and go with your initial approach
with
the two instance variables.
@JsonInclude(Include.NON_NULL) solves the serialization issue quite
nicely.

Let me know when your code is ready then I will integrate it into the
current codebase.
Ralph

On Sat, Nov 24, 2012 at 11:10 AM, dilbertside
[email protected]:

Well, agree, Java speaking it is useless.
But in terms of extjs model we still need it, the generator need to
build this variable and its name.
So it will be used by Extjs library.
Without name this virtual field is useless on extjs side.

If you are concerned about having this variable being jsonified at
runtime, it is better to include @JsonInclude(Include.NON_NULL)
So this variable won't be instantiated at runtime by being set
at null
permanently.

If you want to keep your proposition it should be amended as
following:

@ModelFields({
@ModelField,
@ModelField(value=aBooleanVirtual, mapping="bigValue",
persist=false,
convert="function(v,
record) { return (record.raw.bigValue >1000000);}")
})
private BigInteger bigValue;

what I would propose to keep it simple is to :
@model(...)
@JsonInclude(Include.NON_NULL)
public class BeanWithAnnotations {
private BigInteger bigValue;

@ModelField(mapping="bigValue", persist=false, convert="function(v,
record) { return (record.raw.bigValue > 1000000);}")
private boolean aBooleanVirtual = null;
}

Inconvenience with my system is the developer responsibility to add
this
include.
But it keeps things flexible for unexpected use.


or why not provide a singular implementation expanding your idea.
@ModelFields({
@ModelField,
@virtualfield(value=aBooleanVirtual, mapping="bigValue",
persist=false,
convert="function(v,
record) { return (record.raw.bigValue >1000000);}")
})
private BigInteger bigValue;

Order is very important, this virtual field HAS to be created
after the
mapped field (in our case bigValue)
in that case it could be also

@ModelFields({
@ModelField("bigValueCustomName"),
@virtualfield(value=aBooleanVirtual, convert="function(v,
record) { return (record.raw.bigValueCustomName >1000000);}")
})
private BigInteger bigValue;

will produce:

... , {
name : 'bigValueCustomName',
type : 'int'
}, {
name : 'aBooleanVirtual',
type : 'boolean',
mapping : 'bigValueCustomName',
persist : false,
convert : function(v, record) { return
(record.raw.bigValueCustomName > 1000000);}
},...

What do you think?

On 11/24/2012 12:39 PM, Ralph Schaer wrote:

I'm wondering if we can improve this a bit more. If I'm
understand
this
correctly then
private boolean aBooleanVirtual;
is an useless instance variable.

Maybe we can put two @ModelField annotation on one field.
Something like
this:

@ModelFields({
@ModelField,
@ModelField(mapping="bigValue", persist=false,
convert="function(v,
record) { return (record.raw.bigValue >
1000000);}")
})
private BigInteger bigValue;

On Sat, Nov 24, 2012 at 5:28 AM, Ralph Schaer
<[email protected]

wrote:

Don't have a problem with this test. It's only missing the
two new
fields.
I don't have a ' at the end.

On Sat, Nov 24, 2012 at 5:17 AM, dilbertside
[email protected]:

ah that's the reason I saw those regexes, get it now.

certainly, will do and avoid overhead: end result faster.

I still have pending problem with the test
a single quote is added to the string to compare
});'

in

compareExtJs4Model(ModelGenerator.generateJavascript(BeanWithAnnotations.class,

OutputFormat.EXTJS4, true),
true);
in testGenerateJavascriptClassOfQOutputFormatBoolean

I don't understand why as I stick to your model as close as
possible

On 11/24/2012 12:11 PM, Ralph Schaer wrote:

This @JsonRawValue is interesting. Maybe this could also
solve my
problem
with directFn,read,... methods. Right now I remove the
quotes
with a
call
to string.replaceAll call.

On Sat, Nov 24, 2012 at 5:03 AM, dilbertside
[email protected]:

@JsonRawValue


Reply to this email directly or view it on GitHub
<

#50 (comment)

.


Reply to this email directly or view it on
GitHub<

#50 (comment)

.


Reply to this email directly or view it on GitHub
<

#50 (comment)

.


Reply to this email directly or view it on
GitHub<

#50 (comment)

.


Reply to this email directly or view it on GitHub
<

https://github.com/ralscha/extdirectspring/issues/50#issuecomment-10676397>.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/50#issuecomment-10676841.


Reply to this email directly or view it on GitHub
#50 (comment).

from extdirectspring.

ralscha avatar ralscha commented on July 30, 2024

Made a small changes that allows the use of @JsonIgnore on the virtual field.

 private BigInteger bigValue;

 @ModelField(mapping="bigValue", persist=false, convert="function(v,

record) { return (record.raw.bigValue > 1000000);}")
@JsonIgnore
private boolean aBooleanVirtual = null;

from extdirectspring.

dilbertside avatar dilbertside commented on July 30, 2024

Subtle change and it works.

I removed the @JsonInclude(Include.NON_NULL)
and add @JsonIgnore, the virtual Field has been generated.
with visibility private or public.
I tend to remove this boilerplate code of getter and setters by abusing
@JsonProperty when building json bean

So we have 2 solutions to generate that virtual field.

Documentation should be amended: as it is stated:
https://github.com/ralscha/extdirectspring/wiki/ModelGenerator excerpt
"The generator tries to read all public accessible properties. If a
field should not be part of the generated code annotate it with
@JsonIgnore
http://fasterxml.github.com/jackson-annotations/javadoc/2.0.2/com/fasterxml/jackson/annotation/JsonIgnore.html.
"
in fact that one will be generated despite @JsonIgnore
http://fasterxml.github.com/jackson-annotations/javadoc/2.0.2/com/fasterxml/jackson/annotation/JsonIgnore.html.

On 11/25/2012 05:45 PM, Ralph Schaer wrote:

Made a small changes that allows the use of @JsonIgnore on the virtual
field.

| private BigInteger bigValue;

@ModelField(mapping="bigValue", persist=false, convert="function(v,
|

record) { return (record.raw.bigValue > 1000000);}")
@JsonIgnore
private boolean aBooleanVirtual = null;


Reply to this email directly or view it on GitHub
#50 (comment).

from extdirectspring.

ralscha avatar ralscha commented on July 30, 2024

I updated the doc. It's still true that @JsonIgnore prevents the field
from being written into the model code. But if @ModelField or
@ModelAssociation is present on the field too @JsonIgnore is ignored (only
for model generation, Jackson still ignores the field during serialization
and deserialization).

On Sun, Nov 25, 2012 at 3:46 PM, dilbertside [email protected]:

Subtle change and it works.

I removed the @JsonInclude(Include.NON_NULL)
and add @JsonIgnore, the virtual Field has been generated.
with visibility private or public.
I tend to remove this boilerplate code of getter and setters by abusing
@JsonProperty when building json bean

So we have 2 solutions to generate that virtual field.

Documentation should be amended: as it is stated:
https://github.com/ralscha/extdirectspring/wiki/ModelGenerator excerpt
"The generator tries to read all public accessible properties. If a
field should not be part of the generated code annotate it with
@JsonIgnore
<
http://fasterxml.github.com/jackson-annotations/javadoc/2.0.2/com/fasterxml/jackson/annotation/JsonIgnore.html>.

"
in fact that one will be generated despite @JsonIgnore
<
http://fasterxml.github.com/jackson-annotations/javadoc/2.0.2/com/fasterxml/jackson/annotation/JsonIgnore.html

.

On 11/25/2012 05:45 PM, Ralph Schaer wrote:

Made a small changes that allows the use of @JsonIgnore on the virtual
field.

| private BigInteger bigValue;

@ModelField(mapping="bigValue", persist=false, convert="function(v,
|

record) { return (record.raw.bigValue > 1000000);}")
@JsonIgnore

private boolean aBooleanVirtual = null;


Reply to this email directly or view it on GitHub
<
https://github.com/ralscha/extdirectspring/issues/50#issuecomment-10691822>.


Reply to this email directly or view it on GitHubhttps://github.com//issues/50#issuecomment-10694091.

from extdirectspring.

dilbertside avatar dilbertside commented on July 30, 2024

Ok, in clear you removed the previous constraint which would limit the
model generator to build a field if @JsonIgnore was present

Except one case, the generator puts back @JsonIgnore to what it should
be limited to: I mean Json serialization

It gives more flexibility to the developer to control his model
generation (design) and its Json serialization(runtime).

We can imagine a case where @JsonIgnore is useful: it is the case user
credential hash not to be serialized over the wire, model field and json
serialization value would be cancelled.

On 11/26/2012 02:53 PM, Ralph Schaer wrote:

I updated the doc. It's still true that @JsonIgnore prevents the field
from being written into the model code. But if @ModelField or
@ModelAssociation is present on the field too @JsonIgnore is ignored
(only
for model generation, Jackson still ignores the field during
serialization
and deserialization).

On Sun, Nov 25, 2012 at 3:46 PM, dilbertside
[email protected]:

Subtle change and it works.

I removed the @JsonInclude(Include.NON_NULL)
and add @JsonIgnore, the virtual Field has been generated.
with visibility private or public.
I tend to remove this boilerplate code of getter and setters by abusing
@JsonProperty when building json bean

So we have 2 solutions to generate that virtual field.

Documentation should be amended: as it is stated:
https://github.com/ralscha/extdirectspring/wiki/ModelGenerator excerpt
"The generator tries to read all public accessible properties. If a
field should not be part of the generated code annotate it with
@JsonIgnore
<

http://fasterxml.github.com/jackson-annotations/javadoc/2.0.2/com/fasterxml/jackson/annotation/JsonIgnore.html>.

"
in fact that one will be generated despite @JsonIgnore
<

http://fasterxml.github.com/jackson-annotations/javadoc/2.0.2/com/fasterxml/jackson/annotation/JsonIgnore.html

.

On 11/25/2012 05:45 PM, Ralph Schaer wrote:

Made a small changes that allows the use of @JsonIgnore on the
virtual
field.

| private BigInteger bigValue;

@ModelField(mapping="bigValue", persist=false, convert="function(v,
|

record) { return (record.raw.bigValue > 1000000);}")
@JsonIgnore

private boolean aBooleanVirtual = null;


Reply to this email directly or view it on GitHub
<

https://github.com/ralscha/extdirectspring/issues/50#issuecomment-10691822>.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/50#issuecomment-10694091.


Reply to this email directly or view it on GitHub
#50 (comment).

from extdirectspring.

ralscha avatar ralscha commented on July 30, 2024

Version 1.2.3 released

from extdirectspring.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.