As far as I remember I have got js exceptions when AdvancedCriteria object was complicated enough (using JSON.encode/decode).
Could be corrected till now.
MichalG
Announcement
Collapse
No announcement yet.
X
-
That's a reasonable approach, and when we've implemented saved search we've done so via JSON serialization.
Leave a comment:
-
Is there any reason that JSON.encode/decode is not a good idea for this? (I know there is the issue of trusting the code since it is an eval to decode it)
I want to persist Criteria (eg, save a filter view)
Leave a comment:
-
Hi MichailG,
Thank you for the tip. I was thinking about something similar, but Isomoprhic has specifically stated the using this in JS space could introduce unwanted side effects, so I would like to avoid this, if possible. (I am well aware that I am not proficient in JS to understart all possible implications.)
Thank you anyway:
Csillag
Leave a comment:
-
Hi Csillag,
This is what I am using to make a true copy of the whole DSRequest:
Code:public static native JavaScriptObject deepCopy(JavaScriptObject obj) /*-{ // http://oranlooney.com/functional-javascript/ // A clone of an object is an empty object // with a prototype reference to the original. // a private constructor, used only by this one clone. function Clone() { } Clone.prototype = obj; var c = new Clone(); c.constructor = Clone; return c; }-*/;
MichalG
Leave a comment:
-
The solution is to write the code as previously suggested. It's not especially difficult; a helper method may be added one day that simply does exactly what we suggest you do now, but there is no ETA for such helper and it is not clear that it is even worthwhile. So please proceed.
Leave a comment:
-
Is there really no solution for this? (Either I don't properly understand what was proposed, or there must be a better way...)
Leave a comment:
-
Originally posted by IsomorphicFor now we'd recommend simply doing this in Java manually (creating a new instance, and looping through the various properties creating new sub-criterion instances). This should be relatively straightforward to achieve.
Does not really seem straightforward to me. (And especially not future-proof, since the Criteria system is expected to evolve over time.)
So, it would help a lot is there was an other solution.
Thank you for your help:
Csillag
Leave a comment:
-
You could handle this in JavaScript via JSNI but there are some wrinkles around the Java <--> JavaScript data translation etc that could make this trickier than expected or introduce unexpected side effects.
For now we'd recommend simply doing this in Java manually (creating a new instance, and looping through the various properties creating new sub-criterion instances). This should be relatively straightforward to achieve.
Leave a comment:
-
OK, so what's the recommended approach to do this manually?
My guess would be that this should be probably handled in JS. Is there a way to serialize / deserialize, or uneval / eval a criteria, or something like that? Or does one have to recursively loop over the object manually?
(I am not really proficient in JS.)
Thank you for your help:
Csillag
Leave a comment:
-
There is not currently a shortcut to implementing a recursive copy.
Leave a comment:
-
How to copy a Criteria object
Hi there,
I would like to make an exact copy of a criteria object, so that I can modify the old and the new copies independently. How do I do that?
The incoming criteria might be an AdvancedCriteria or a simple one, and it might contain array elements, too.
Thank you for yout help:
CsillagTags: None
Leave a comment: