CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

JQButton - How to specify target as in a link

by JohnFSklavounos » 20 Oct 2014 21:50

Hello,

I have a "How to" kind of question... I have a JQButton which calls the WebApplication.SendFile function. All is well, but I'd like to have the browser open the file in another window or tab the way you would specify in an anchor tag in straight html. I'm hoping there's something I can add to the JQButtonOptions.OnClick.BrowserParams to make that happen.

<a href="wwwroot/temp/file.pdf" target="_blank">Download file here</a>

I can't use a link because the document is generated dynamically...

Any thoughts?

Thanks!
John
John F. Sklavounos
Software Developer
Always learning

XE7: Update 1
FireDAC: 20.0.16277 (Build 1276)
IW: 14.0.41
CG : 2.6.0.100
JohnFSklavounos
 
Posts: 109
Joined: 14 Aug 2013 00:35
Location: Miami, FL

by Jorge Sousa » 20 Oct 2014 23:34

Hi John

It's a very interesting question, maybe i don't have the full answer right now.

When you call WebApplication.SendFile, depends on how browsers are configurated to handle each mime types.

If you need to open a new browser window, maybe its best if you call WebApplication.NewWindow

And you can use a link, despite the fact the document being generated dynamically, you can use IW cache functions, are you familiar with them? Maybe if you give us an hint on how are you creating the docx, we can give you a tip on how to get the correspondant url.

The BrowserParams only serves the purpose of transporting evaluated script expressions in browser, to the server, when they are needed, and only if the control doesn't do already these functions, which are always done in user changeable values, like a edit text, a combo selected index or even a grid selection change.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by JohnFSklavounos » 21 Oct 2014 01:56

Wow, exactly what the doctor ordered. You guys are amazing! 8-)

For anyone's curiosity, when using this method, do not use a windows file system file name in the URL field.

Create your file in the wwwroot\%somefoldername%\... then pass it as an actual URL relative to the root. For example, I used, 'username/sessionid/filename.ext' I did this because I wanted to be able to easily look at the what the users are up to, but feel free to use the IWAppCache if you don't need to see the files being created.

TIWAppCache Class Docs
http://docs.atozed.com/docs.dll/classes/TIWAppCache.html

Remember that if you manage the files & folders on your own, you have to create a way to clean up after yourself or the server is going to get full fast.

You guys are the best!

Thanks,
John
John F. Sklavounos
Software Developer
Always learning

XE7: Update 1
FireDAC: 20.0.16277 (Build 1276)
IW: 14.0.41
CG : 2.6.0.100
JohnFSklavounos
 
Posts: 109
Joined: 14 Aug 2013 00:35
Location: Miami, FL

by Jorge Sousa » 21 Oct 2014 09:45

Hi John

Just one more thing,

And remember that if more than one user / session creates files in some wwwroot folder, make sure that the folder or filename is unique, (or that part of the code is a critical section), if not, the users can be creating the same file to the same folder, at the same time.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by JohnFSklavounos » 21 Oct 2014 19:34

Understood.

:D

Thanks again!
John
John F. Sklavounos
Software Developer
Always learning

XE7: Update 1
FireDAC: 20.0.16277 (Build 1276)
IW: 14.0.41
CG : 2.6.0.100
JohnFSklavounos
 
Posts: 109
Joined: 14 Aug 2013 00:35
Location: Miami, FL


Return to JQButton & JQButtonSet

cron

Who is online

Users browsing this forum: No registered users and 4 guests

Contact Us.