Hi All,
I’m playing around with the option to add a field to a form and then set the dataprovider to “none” (This is one of the options when you click the dataprovider property of a field).
The reason why I want to use a field without a dataprivider attached is that this field needs to be on every form I make, can hold different values on every form and is basically only a field to control the GUI.
What I need to be able to do with it is, for example:
- attach a value list and then fire a datachange event when another item from the valuelist is selected (field can be Radios of ComboBox)
- add a value into the field and read the value during a method (textfield or Calender field)
What have I notices trying this?
- onDataChange events are not fired (any type of field)
- onAction is not fired (Radios/Checks/Combo fields)
- cannot get the fields value (at all for Calender field, only possible to get selected text on textfields)
Now, this list is probably not conclusive, nor are all mentioned issues solemnly issues when working with Dataprovider = None.
So, are the things I’ve notices bugs? Am I doing something wrong? Am I using something that is not supported? etc, etc…
Paul
And add to that: Connot set the value of the field though scripting.
Paul
you can only do this by yourself by using beans.
Then you can throw a textfield on a form that is not attached to anything.
And you handle the get/set of the data yourself.
do those beasn work with Servoy stylesheets?
Paul
Mmm, too bad.
Will support for fields without dataprovider never come (get/setValue functions, onDataChange and onAction methods)?
If so, I guess showing the -none- option in the Dataprovider selection dialog, when clicking on the dataprovider property of an element is a bug.
Paul
just use a global attached to that field
they it works just as you want.
This makes me think of my 4D adventures. One thing I did appreciate about 4D was his ability to visualise “local” variables on a form. In Servoy terms this would be translated too visualising form properties in conjunction with the possibility to declare in code custom properties for your form object.
I suppose the difficulty lies in passing a javascript variable to a java object as a property.
It sure would make for much cleaner coding.
We would have
1)solution level globals --created on solution start/destroyed on solution end
2) form level properties – instanciated on form load, garbage collection on form unload
3)local vars
So as I see it we only need to open up the form properties for declaring on the fly properties AND a means of coupling these to interface elements (labels, fields,…)
Basically, you explain properly what I mean.
The reason I would like to have the -none- dataprovider option to work, is that I currently have the situation where I would have to create 2 Global variables per form showing. Meaning: if I show 1 form in 5 different places, I would need to create the 2 * 5 globals.
And I really do not need to store the variables globally… ![Sad :(]()
The option of displaying values not linked to fields in a DB (or globals in Servoys terms) is something I also had in my 5 minutes with MS Access and something I got used to live without in Servoy. But now it becomes relevant again in my solution…
Paul
Odysseus:
In Servoy terms this would be translated too visualising form properties in conjunction with the possibility to declare in code custom properties for your form object.
I suppose the difficulty lies in passing a javascript variable to a java object as a property.
It sure would make for much cleaner coding.
We would have
1)solution level globals --created on solution start/destroyed on solution end
2) form level properties – instanciated on form load, garbage collection on form unload
3)local vars
So as I see it we only need to open up the form properties for declaring on the fly properties AND a means of coupling these to interface elements (labels, fields,…)
I’d like this in Servoy too!
Another reason to have the Datarpovider = -None- option working:
Search fields:
In my solution, on many of the forms I have multiple fields where the user can enter search criteria and then hit a search button, executing the search.
Currently, for every search criteria, I have to create a global variable, cluttering up the list of global variables, while basically, there’s no need to store the values as global variables.
All that is needed, are input fields and the ability to read them in a method. (for this specific purpose, onAction and onDataChange aren’t really necessary)
Paul
Hi Paul,
why don’t you declare 2 ‘generic’ globals that you reuse on every form?
The downside is that you may need to clear them (or populate them with some data) each time your users go to a new layout.
I’m considering having a table storing what each user has searched for on each layout. I would read this information when the form is shown and save information into the table when the user triggers a search… you would need to write 2 global methods with a little handcoded SQL, but it should not take long…
Well, offcourse there are workarounds, but… ![Smile :)]()
Some forms have more search criterias. Also, with the setup of my solution, it would be possible that two different forms are shown at the same time (Splitpanes, dialogs, tabpanels etc) and then, using the same global would not give the desired situation.
Paul
Ok, my scenario may be simpler than yours at present, but I could also end up with more forms showing at the same time…
I have created a table of predefined search criteria, linked to specific forms – could be linked to tables I suppose.
My users will see a combobox with options like
“Name contains”
“Company contains”
“Active”
“Joined after”
for each option I have stored a SQL “WHERE” statement, and the type of input I expect (such as Date, Text, Integer). This way I know how to treat my reusable global search field (use as is, check if a valid number, check if valid date).
When the form loads the first time, I query my search criteria table and build the combobox list.
In your case, you could do this every time the number/types of forms shown change. You would build a list for searching all forms visible at any time. You may end up with something like:
“Subscriber Name contains”
“Subscriber Company contains”
“Subscriber Active”
“Subscriber Joined after”
“-”
“Invoice Number”
“Invoice Unpaid”
“-”
“Sales Number”
etc…
You would need to store your SQL "SELECT"s with the searches to do this.
This could also be extended to allow searches like
“Subscriber Company contains” + “Invoice Unpaid”
Yes, that is different stuff as to what I have.
I have, for example a table view, with, lets say, 5 columns. I want to give the user the ability to search for values in each of the columns + combinations.
in this case, I have 5 criteria fields, where the user can type something, and when he/she hits the search button, I gather the content of the criteria fields, and performs a find/search method.
The reason why I got started on this subject is that many of my forms show transaction based records (with start and enddates). On every form, there has to be a All/As of: toggle (Radio’s) and when the “As of:” option is selected, a datefield is enabled, for the user to enter any date into.
On every form, these two criteria (toggle All/AsOf and the datefield) can contain different values and the actions that need to happen are onDateChange actions (trigger a method with loadAll when the toggle is set to All and trigger a search when the toggle goes to As of, or when the datefield changes.
Now, since the values can be different for every form, I would have to create these globals for every form + everytime the form is shown somewhere.
Result: quite an extensive list of globals…
Paul
i will give you a hidden feature then:
make a calculation that doesn’t return a thing:
return;
Then now you have a in mem record based local variable.
Que?!?
Could you elaborate on that? Because I do not follow how this hidden feature will help us…
Paul
not all youre things. But i see request for local variables. Thats just a calculation that returns nothing.
What you want is just a bean there is no other way.
Hi Jan,
Any chance you can post the source code for a very simple bean, designed to hold a property related to a form?
you have to fill the data yourself. (onRecordSelection)
Because that is what he asked he wanted form element that is not binded to an dataprovider.. But can be read in javascript.
Just see the swing beans like JTextField or something like that.