Hi,
I overrided onclick event in the updateDom function. So I would need to
do some rethinking to get the Wt's clicked signal working again I guess.
And the element looks like WPushButton.
WAnchrod had something like this:
element.setAttribute("href", <theurl> )
With the button I could use
element.setAttribute( "onclick", "window.location = 'url'" )
If the target resource has proper mimetype, i.e.
application/octet-stream and has content-disposition: attachement all
browsers just open the save dialog and does not move out from the Wt
application.
Without Content-Disposition header IE will peek the file and open it if
possible but other browsers obey the mime type.
I did not originally try to define it as specialized anchor but using
WPushButton with clicked signal connected to a function that was like this:
{
Wt::JSlot slot;
slot.setJavaScript( "function(obj, event) { window.open( '" +
resource->url() + "' ); }" );
slot.exec();
}
This kind of solution works in many cases. But when the resource content
is generated on the fly and the file contains ascii data (with mime type
application/octet-stream) IE just opens new window and closes it. I
think this is because by default IE wants to query the user if the file
should be downloaded when IE thinks the file opened in new browser
window might be malicious.
So our problem is that we can not download the generated file with IE
with the above solution. One solution would be to use WAnchor but the UI
uses buttons so that would look kind of silly.
BR,
Janne
On 15.10.2010 10:40, Koen Deforche wrote:
> Hey Janne,
>
> 2010/10/15 Janne Rönkkö<[email protected]>:
>> Hi,
>>
>> I'm developing an application that needs a button that triggers
>> downloading of a WResource defined file.
> This is a need that pops up in our projects too, and for which we
> couldn't come up with a good solution.
>
>> We have been using JSlot based solution but this does not work well
>> enough with IE so I went on and quickly hacked a class inherited from
>> WPushButton with implementation similar to WAnchor implementation. This
>> seems to work well.
> But it does not render natively as a button then ?
>
>> Because the implementation needs classes inside Wt's src/web I think I
>> would need to get this button widget to be included into Wt. Would it be
>> possible to include the widget into Wt? I would be willing to contribute
>> the code after cleaning it up.
> How does the generated HTML look like, and why would it not be
> possible to define it as a specialized anchor ?
>
> Regards,
> koen
>
> ------------------------------------------------------------------------------
> Download new Adobe(R) Flash(R) Builder(TM) 4
> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
> Flex(R) Builder(TM)) enable the development of rich applications that run
> across multiple browsers and platforms. Download your free trials today!
> http://p.sf.net/sfu/adobe-dev2dev
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest