It's all about the answers!

Ask a question

Can valeSetProvider scripts read their data from local text files?


Tom Malnar (23137) | asked May 31 '13, 1:20 p.m.
I'm no dojo expert by any means and I'm looking to see if it is possible to have a dojo script open a file on our server (\\server\somefile) to fetch the data for the result.   I.e. All we do after uploading the script is have to modify the text file on server (dynamic list).

I'm basing on the script example shown here.
/*******************************************************************************
 * Licensed Materials - Property of IBM
 * (c) Copyright IBM Corporation 2011. All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:  
 * Use, duplication or disclosure restricted by GSA ADP Schedule 
 * Contract with IBM Corp. 
 *******************************************************************************/
dojo.provide("com.example.ValueSetProvider");

(function() {
    dojo.declare("com.example.ValueSetProvider", null, {

        getValueSet: function(attributeId, workItem, configuration) {
       
            var result= [];  
            result.push("a");   <-- would like to fetch this from File I/O.
            result.push("b");
            return result;
            
        }
   });
})();

2 answers



permanent link
Karol W (551811) | answered May 31 '13, 3:00 p.m.
I'm not sure if this is possible with ValueSetProvider script (I think it's not.).
Anyway, instead scripts, you should use HTTP Filtered Value Set, which allows you to fetch set of values from XML document via HTTP protocol.

Comments
sam detweiler commented May 31 '13, 3:57 p.m.

right, but you have to have an HTTP server for that..


permanent link
Tom Malnar (23137) | answered May 31 '13, 4:29 p.m.
So I went the http filtered value set route.   I setup apache and serving an xml page. 

<xml>
<node>
<value>Tom 1</value>
</node>
<node>
<value>Tom 2</value>
</node>
<node>
<value>Tom 3</value>
</node>
</xml>

When I run the test everything works,

[HttpFilteredValueSetProvider]Retrieving values from HttpConnector...
[HttpConnector]Retrieving XML document...
[HttpConnector]Issue a new HTTP requestGET /test.xml
Accept: application/xml
Host: 192.168.6.119
Connection: Keep-Alive
[HttpConnector]Got response 'OK'200 OK
Date: Fri, 31 May 2013 20:25:29 GMT
Server: Apache/2.4.2 (Win64) OpenSSL/1.0.1
Last-Modified: Fri, 31 May 2013 20:22:56 GMT
ETag: "8e-4de096164a8bc"
Accept-Ranges: bytes
Content-Length: 142
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/xml
[HttpConnector]Retrieved XML document<xml>
<node>
<value>Tom 1</value>
</node>
<node>
<value>Tom 2</value>
</node>
<node>
<value>Tom 3</value>
</node>
</xml>
[HttpConnector]Identified 3 rowsXPath: //xml/node
[HttpFilteredValueSetProvider]Retrieved 3 values

Yay! But then I tried creating an attribute (small string) and placing it in a presentation.  
No matter what I do, I always get a blank control on the presentation.

Any ideas?

Comments
Tom Malnar commented May 31 '13, 4:40 p.m.

Btw, I wanted to thank you Karol, long ago I looked at both approaches,  but completely forgot about the HTTP filtered approach. 


Thanks!

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.