What's the best way to pass an object as a url parameter?
I have a form that sends an email, rather than attaching a load of url parameters and as the number of fields / the object can change I've been encrypting a stringified version of the object and then decrypting / parsing at the other end. Is this the right / best approach?
I came across fields.OBJ.stringValue so hoped I could do away with the encryption/parsing.
The stringValue of the object contains hard returns so I've tried encoding the value but the link in the email fails to run (not quite got to the bottom of why). I've not got to the other end ie attempting to read the object back in.
Thanks
object as url parameter
Moderators: Jon, Steve, Ian, Dave
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
You should be able to pass the object using its stringvalue and then receive it in a called form just by specifying the field as a URL parameter. But.. this is a bit of a problematic area and has been changed recently (change will be in 5.0.2). The passed value (this is a serialized string representation of the object) will be quite long, say 1 - 2K, but it should still work. It is possible that in V5.0.1 it will result in a much longer string, say 60K or so, and there may be problems receiving this.
Another approach is to store the object in a session variable or a form session variable, and this should work fine when using call form. There is no serialization involved in this approach - the object is stored as a native rhino object.
e.g. to pass..
to receive..
Another approach is to store the object in a session variable or a form session variable, and this should work fine when using call form. There is no serialization involved in this approach - the object is stored as a native rhino object.
e.g. to pass..
Code: Select all
var myObj = new xxx();
client.formSession.setFormSessionAttribute("passedObj", myObj);
form.callForm("emailForm");
Code: Select all
var myObj = client.formSession.getFormSessionAttribute("passedObj");
client.formSession.removeFormSessionAttribute("passedObj"); //best to remove it once it's been received
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
You should be able to pass the object using its stringvalue and then receive it in a called form just by specifying the field as a URL parameter. But.. this is a bit of a problematic area and has been changed recently (change will be in 5.0.2). The passed value (this is a serialized string representation of the object) will be quite long, say 1 - 2K, but it should still work. It is possible that in V5.0.1 it will result in a much longer string, say 60K or so, and there may be problems receiving this.
Another approach is to store the object in a session variable or a form session variable, and this should work fine when using call form. There is no serialization involved in this approach - the object is stored as a native rhino object.
e.g. to pass..
to receive..
Another approach is to store the object in a session variable or a form session variable, and this should work fine when using call form. There is no serialization involved in this approach - the object is stored as a native rhino object.
e.g. to pass..
Code: Select all
var myObj = new xxx();
client.formSession.setFormSessionAttribute("passedObj", myObj);
form.callForm("emailForm");
Code: Select all
var myObj = client.formSession.getFormSessionAttribute("passedObj");
client.formSession.removeFormSessionAttribute("passedObj"); //best to remove it once it's been received
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
You should be able to pass the object using its stringvalue and then receive it in a called form just by specifying the field as a URL parameter. But.. this is a bit of a problematic area and has been changed recently (change will be in 5.0.2). The passed value (this is a serialized string representation of the object) will be quite long, say 1 - 2K, but it should still work. It is possible that in V5.0.1 it will result in a much longer string, say 60K or so, and there may be problems receiving this.
Another approach is to store the object in a session variable or a form session variable, and this should work fine when using call form. There is no serialization involved in this approach - the object is stored as a native rhino object.
e.g. to pass..
to receive..
Another approach is to store the object in a session variable or a form session variable, and this should work fine when using call form. There is no serialization involved in this approach - the object is stored as a native rhino object.
e.g. to pass..
Code: Select all
var myObj = new xxx();
client.formSession.setFormSessionAttribute("passedObj", myObj);
form.callForm("emailForm");
Code: Select all
var myObj = client.formSession.getFormSessionAttribute("passedObj");
client.formSession.removeFormSessionAttribute("passedObj"); //best to remove it once it's been received
0 x
-
- Ebase User
- Posts: 331
- Joined: Mon Mar 10, 2014 8:34 am
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
-
- Ebase User
- Posts: 331
- Joined: Mon Mar 10, 2014 8:34 am
Thanks, just a note of caution for anyone thinking of this. The url parameter once passed becomes "object" in the address bar once the page loads (ie instead of the stringValue).
This would be an issue if the form is likely to be saved as a favourite/bookmark.
Also it is interesting how big stringValue is in comparison to the stringified object or encrypted value.
eg with a test object
minified object 119 chrs
encrypted value of stringified object 241 chrs
stringValue of object 2197 chrs.
thanks
This would be an issue if the form is likely to be saved as a favourite/bookmark.
Also it is interesting how big stringValue is in comparison to the stringified object or encrypted value.
eg with a test object
minified object 119 chrs
encrypted value of stringified object 241 chrs
stringValue of object 2197 chrs.
thanks
0 x
Who is online
Users browsing this forum: Bing [Bot] and 7 guests