Hi,
is it possible to have fields which values can exists across forms within a project?
fields that retain across forms?
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 305
- Joined: Thu Jul 02, 2015 8:32 am
- Location: Indonesia
-
- Ebase User
- Posts: 331
- Joined: Mon Mar 10, 2014 8:34 am
No I don't believe you can but you can pass the value of a field in form A into form B either via url parameter or callForm
See
http://dev-docs.verj.io/ufs/doc/javadoc ... bForm.html and look at the callForm options.
See
http://dev-docs.verj.io/ufs/doc/javadoc ... bForm.html and look at the callForm options.
0 x
-
- Ebase User
- Posts: 305
- Joined: Thu Jul 02, 2015 8:32 am
- Location: Indonesia
Yes, I am aware of that method. Just think it rather bothersome if the field needed more than 2.
Steve James wrote:No I don't believe you can but you can pass the value of a field in form A into form B either via url parameter or callForm
See
http://dev-docs.verj.io/ufs/doc/javadoc ... bForm.html and look at the callForm options.
0 x
-
- Ebase User
- Posts: 331
- Joined: Mon Mar 10, 2014 8:34 am
How about create a KVP object and pass that as a single object into the new form, then populate each KVP into the appropriate field.
Build the field object as you want eg all fields, or just push the fields you want.
You've now got an object with all the field names/values you want. You could pass this as a single url parameter if it isn't too big; I encrypt the object then decrypt it in form2 (see http://forum.ebasetech.com/forum/viewtopic.php?t=1044), otherwise turn it into a cookie or session variable.
If form 2 is intended for a different session then maybe insert it into a db table and pass an id as the url parameter for retrieval.
In form 2 just retrieve the object and loop through it to populate the fields.
Build the field object as you want eg all fields, or just push the fields you want.
Code: Select all
var ary = [];
for (var field in Iterator(fields.iterator()) )
{
var thisValue = {'name':field.elementName,'value':field.value};
ary.push(thisValue);
}
If form 2 is intended for a different session then maybe insert it into a db table and pass an id as the url parameter for retrieval.
In form 2 just retrieve the object and loop through it to populate the fields.
Code: Select all
ary.forEach(function(f){
fields.getField(f.name).setValue(f.value);
})
0 x
-
- Ebase User
- Posts: 305
- Joined: Thu Jul 02, 2015 8:32 am
- Location: Indonesia
Thank you for the idea.
Seems interesting. Will try to figure it out.
Once again thank you.
Seems interesting. Will try to figure it out.
Once again thank you.

Steve James wrote:How about create a KVP object and pass that as a single object into the new form, then populate each KVP into the appropriate field.
Build the field object as you want eg all fields, or just push the fields you want.You've now got an object with all the field names/values you want. You could pass this as a single url parameter if it isn't too big; I encrypt the object then decrypt it in form2 (see http://forum.ebasetech.com/forum/viewtopic.php?t=1044), otherwise turn it into a cookie or session variable.Code: Select all
var ary = []; for (var field in Iterator(fields.iterator()) ) { var thisValue = {'name':field.elementName,'value':field.value}; ary.push(thisValue); }
If form 2 is intended for a different session then maybe insert it into a db table and pass an id as the url parameter for retrieval.
In form 2 just retrieve the object and loop through it to populate the fields.
Code: Select all
ary.forEach(function(f){ fields.getField(f.name).setValue(f.value); })
0 x
-
- Ebase Staff
- Posts: 89
- Joined: Mon Sep 10, 2007 11:48 am
Easiest thing is to use a form session object - that's what they're for. Just put whatever shared state you need into an object and pin it in form session state, e.g.
and then use it like this from any form:
or
If you want to share state between any form running in your browser session (like in different browser tabs or in pop-up windows) use HTTP session state instead. Or, if you want everyone using your app to be able to share the state use Servlet Context instead. See client.httpSession and client.getHttpSession().getServletContext() for reference.
Dave
Code: Select all
// function to define an object to hold state
function setUpStateObject() {
var s = function() {
var orgID;
this.getOrgID = function() {return orgID;}
this.setOrgID = function(id) {orgID = id;}
}
if (client.formSession.getFormSessionAttribute('state') == null) {
// create a new object
client.formSession.setFormSessionAttribute('state', new s());
}
}
Code: Select all
client.formSession.getFormSessionAttribute('state').getOrgID();
Code: Select all
client.formSession.getFormSessionAttribute('state').setOrgID(someValue);
Dave
0 x
-
- Ebase User
- Posts: 305
- Joined: Thu Jul 02, 2015 8:32 am
- Location: Indonesia
Thank you very much for a detail explaination.
Really appreciate it.
Really appreciate it.
Dave wrote:Easiest thing is to use a form session object - that's what they're for. Just put whatever shared state you need into an object and pin it in form session state, e.g.
and then use it like this from any form:Code: Select all
// function to define an object to hold state function setUpStateObject() { var s = function() { var orgID; this.getOrgID = function() {return orgID;} this.setOrgID = function(id) {orgID = id;} } if (client.formSession.getFormSessionAttribute('state') == null) { // create a new object client.formSession.setFormSessionAttribute('state', new s()); } }
orCode: Select all
client.formSession.getFormSessionAttribute('state').getOrgID();
If you want to share state between any form running in your browser session (like in different browser tabs or in pop-up windows) use HTTP session state instead. Or, if you want everyone using your app to be able to share the state use Servlet Context instead. See client.httpSession and client.getHttpSession().getServletContext() for reference.Code: Select all
client.formSession.getFormSessionAttribute('state').setOrgID(someValue);
Dave
0 x
Who is online
Users browsing this forum: No registered users and 16 guests