• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

How to return filePath in addition to dynamic JSON output?  RSS feed

 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a spring based webservice and following is the  DAO method implementation.
I am wondering how do I return the filePath also in addition to the JSON that I am currently returning as shown below:

Brief overview of what I am doing right now:

I am getting the SQL query using this line   and then executing
the content of `SQLQUERY` column which is a SQL Query and outputting it in JSON format.

Do I need to write a separate webservice just to get the name of the file?


 
Marshal
Posts: 24461
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Couldn't you just include the file path in the JSON object you're returning?
 
Jack Tauson
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:Couldn't you just include the file path in the JSON object you're returning?



Actually, I am using this dynamic JSON to buld dynamic tables in the UI. Hence, adding it in the JSON object might mess things on the UI side? I think I should stick with a new web service to get the filePath.
 
Rancher
Posts: 427
6
Fedora IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you want to return the file path along with the JSON string in the same response? you could possibly do it will a multi part response.  Is your UI just taking the values and sticking them on the page without looking at the keys?
 
Jack Tauson
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Al Hobbs wrote:So you want to return the file path along with the JSON string in the same response? you could possibly do it will a multi part response.  Is your UI just taking the values and sticking them on the page without looking at the keys?



Yeah, I was looking for a way to get the file path in same JSON response but looking at the way my UI is dealing with this JSON response, I wonder if it would be appropriate to adjust my JSON to get the filePath or not.

So my UI is doing the following:

Scenario #1:

Let's say a table has 10 different columns with 10 different names and 100 rows, my UI will create a table with 10 different column heading and display the 100 rows in a tabular format

Scenario #2:

Let's say a table has 5 different columns with 5 different names and 50 rows, my UI will create a table with 5 different column heading and display the 50 rows in a tabular format
 
Paul Clapham
Marshal
Posts: 24461
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're on the right track, it depends on your design. It looks like when you download the query data, you don't need to know the file path at that time. And I don't see anywhere that you do use the file path. But that's only because you (thankfully) haven't dumped the whole thing here. So the question for you us, does your design need to get the file path but not the query data for some use case? If so then there's definitely no need to execute the query and collect its data if that use case doesn't need the query data.
 
Al Hobbs
Rancher
Posts: 427
6
Fedora IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that really a good idea to have a DAO that is one size fits all like that? Why don't you have a method for each query?
 
Al Hobbs
Rancher
Posts: 427
6
Fedora IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
especially considering you are using spring why don't you use an ORM or mybatis.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!