Accessing form elements from Smart Client vs Web

Questions and answers for designing and implementing forms in Servoy

Accessing form elements from Smart Client vs Web

Postby sergei.sheinin » Thu May 15, 2014 9:57 am

There is a Multiselect Listbox on form called "table_list". While using "Debug Smart Client" I was able to use this function to get selected values:

Code: Select all
elements.table_list.getSelectedElements()


However when I use Web Client - it doesn't work, simply returns blank.

In manuals I was able to find a full notation using form path like so:

Code: Select all
forms.table_maker.elements.table_list.getSelectedElements()


When I use it word "elements" gets underlined with warning: "The property elements is private"


How can I access form elements from both smart client and web client? I am new to Servoy.


Please help,
thank you.
Sergei Sheinin
JavaScript, RDBMS
http://js2dx.com
sergei.sheinin
 
Posts: 79
Joined: Wed May 07, 2014 3:22 pm

Re: Accessing form elements from Smart Client vs Web

Postby sergei.sheinin » Fri May 16, 2014 8:40 am

Would someone please answer this question? I'm very curious to know. The manual seems straight forward on using complete path to form elements like so:

Code: Select all
forms.table_maker.elements.table_list.getSelectedElements()


But there is the "The property elements is private" warning in my Servoy set up. What am I overlooking?
Sergei Sheinin
JavaScript, RDBMS
http://js2dx.com
sergei.sheinin
 
Posts: 79
Joined: Wed May 07, 2014 3:22 pm

Re: Accessing form elements from Smart Client vs Web

Postby jdbruijn » Fri May 16, 2014 9:15 am

Have a look at the encapsulation properties of the form, the elements are probably hidden. Which results in this warning.
Jos de Bruijn
Focus Feedback BV
Servoy Certified Developer
Image
jdbruijn
 
Posts: 492
Joined: Sun Apr 11, 2010 6:34 pm

Re: Accessing form elements from Smart Client vs Web

Postby sovanm » Fri May 16, 2014 9:24 am

Hi ,

Its seems to be bug.
I have tried to reproduce it.

Placed a multiselect list box inside a tab and tried to get the values from the parent form. In case of smart client it return me an array of selected values but in case of web client it just returned a blank array. I make sure that the encapsulation is turned off.

I have also attached a solution with with this post. Sheinin, Please verify if you get the same problem.

Thanks,
Sovan
Attachments
multiSelectListBoxBug.servoy
(4.47 KiB) Downloaded 302 times
sovanm
 
Posts: 99
Joined: Fri Oct 28, 2011 1:55 pm
Location: Bhubaneswar, India

Re: Accessing form elements from Smart Client vs Web

Postby sergei.sheinin » Fri May 16, 2014 5:49 pm

Yes, I made sure Encapsulation has "Hide Elements" unchecked and still seeing the error.


Really a BUG? :shock:
Attachments
servoy_form_elements.png
servoy_form_elements.png (77.81 KiB) Viewed 8569 times
Sergei Sheinin
JavaScript, RDBMS
http://js2dx.com
sergei.sheinin
 
Posts: 79
Joined: Wed May 07, 2014 3:22 pm

Re: Accessing form elements from Smart Client vs Web

Postby mboegem » Sat May 17, 2014 3:52 pm

try to force-rebuild: choose menu 'Project > Clean'
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1750
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Accessing form elements from Smart Client vs Web

Postby sergei.sheinin » Sat May 17, 2014 6:42 pm

mboegem wrote:try to force-rebuild: choose menu 'Project > Clean'



The error message changed to:

Code: Select all
"The property table_maker from the instance forms is private"


Before clean it used to say

Code: Select all
"The property elements is private"



Any ideas?
Sergei Sheinin
JavaScript, RDBMS
http://js2dx.com
sergei.sheinin
 
Posts: 79
Joined: Wed May 07, 2014 3:22 pm

Re: Accessing form elements from Smart Client vs Web

Postby mboegem » Sat May 17, 2014 9:41 pm

sergei.sheinin wrote:Any ideas?

Yes, you have 'hide in scripting' checked at the encapsulation properties.
Untick this option, rebuild again and the message should be gone.

However, reading your first post we're a bit off topic here.
the initial question was why you couldn't get the values from your listbox in web client.
I really don't see how using the full reference: forms.table_maker.elements etc.
would make a difference to elements.table_list_getSelectedElements()

If it doesn't work, just attach a dataprovider to the listbox and read that value.
If you find it uncomfortable having the values as a CR separated list, use this:
Code: Select all
foundset.<MyDataprovider>.split('\n')


Hope this helps
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1750
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Accessing form elements from Smart Client vs Web

Postby sergei.sheinin » Sun May 18, 2014 6:10 am

Very interesting suggestion about data provider. I have these lines of code in the form's js:

Code: Select all
var test = "console.log('"+elements.table_list.getSelectedElements()+"')"
plugins.WebClientUtils.executeClientSideJS(test)


which produced blank output. As soon as I attached data provider - a global variable that is never used - the above lines of code started working.


Why does attaching a data provider that is never used in the project's code have such affect on "elements.table_list.getSelectedElements()"? Could it indeed be a bug as was suggested earlier in the thread?
Attachments
without_dp.png
Without data provider
without_dp.png (36.5 KiB) Viewed 8504 times
with_dp.png
With data provider
with_dp.png (33.81 KiB) Viewed 8504 times
Sergei Sheinin
JavaScript, RDBMS
http://js2dx.com
sergei.sheinin
 
Posts: 79
Joined: Wed May 07, 2014 3:22 pm

Re: Accessing form elements from Smart Client vs Web

Postby mboegem » Sun May 18, 2014 10:14 am

sergei.sheinin wrote:Why does attaching a data provider that is never used in the project's code have such affect on "elements.table_list.getSelectedElements()"? Could it indeed be a bug as was suggested earlier in the thread?


I don't know how Servoy deals with the listbox in the background, so I can't answer that question.

What interests me though is why you didn't have a dataprovider attached to the listbox?
I mean: a dataprovider is where your values end up in the first place and it's easier to grab those values.
If the dataprovider is a column in a table you will have the values directly in your database without a single line of code...
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1750
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Accessing form elements from Smart Client vs Web

Postby sergei.sheinin » Sun May 18, 2014 11:57 am

mboegem wrote:What interests me though is why you didn't have a dataprovider attached to the listbox?
I mean: a dataprovider is where your values end up in the first place and it's easier to grab those values.
If the dataprovider is a column in a table you will have the values directly in your database without a single line of code...


I use "valuelist" property of listbox equal "tableListValues" with the following .js code:

[code]
var qry = "SELECT DISTINCT table_name FROM dictionary"
var dataset = databaseManager.getDataSetByQuery(databaseManager.getDataSourceServerName(controller.getDataSource()), qry, null, 100)
application.setValueListItems('tableListValues', dataset)
[/quote]

I must be "SELECT DISTINCT..." from a DB table in this case.
Sergei Sheinin
JavaScript, RDBMS
http://js2dx.com
sergei.sheinin
 
Posts: 79
Joined: Wed May 07, 2014 3:22 pm


Return to Forms

Who is online

Users browsing this forum: No registered users and 2 guests

cron