object as url parameter

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

object as url parameter

#1

Postby Steve James » Wed Feb 10, 2016 9:48 am

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
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Wed Feb 10, 2016 3:07 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..

Code: Select all

var myObj = new xxx();
client.formSession.setFormSessionAttribute("passedObj", myObj); 
form.callForm("emailForm");
to receive..

Code: Select all

var myObj = client.formSession.getFormSessionAttribute("passedObj"); 
client.formSession.removeFormSessionAttribute("passedObj");       //best to remove it once it's been received 
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#3

Postby Jon » Wed Feb 10, 2016 3:07 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..

Code: Select all

var myObj = new xxx();
client.formSession.setFormSessionAttribute("passedObj", myObj); 
form.callForm("emailForm");
to receive..

Code: Select all

var myObj = client.formSession.getFormSessionAttribute("passedObj"); 
client.formSession.removeFormSessionAttribute("passedObj");       //best to remove it once it's been received 
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#4

Postby Jon » Wed Feb 10, 2016 3:08 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..

Code: Select all

var myObj = new xxx();
client.formSession.setFormSessionAttribute("passedObj", myObj); 
form.callForm("emailForm");
to receive..

Code: Select all

var myObj = client.formSession.getFormSessionAttribute("passedObj"); 
client.formSession.removeFormSessionAttribute("passedObj");       //best to remove it once it's been received 
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#5

Postby Steve James » Wed Feb 10, 2016 3:25 pm

Thanks Jon, it is for 2 different people so different sessions.

I'll stick with the

- stringify / encrypt
- decrypt / parse

approach for the moment then.

When is 5.0.2 due?
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#6

Postby Jon » Wed Feb 10, 2016 4:04 pm

V5.0.2 is planned provisionally for end of March.
0 x

Steve James
Ebase User
Posts: 331
Joined: Mon Mar 10, 2014 8:34 am

#7

Postby Steve James » Fri Feb 12, 2016 1:45 pm

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
0 x


Who is online

Users browsing this forum: No registered users and 6 guests