restrict image file size in alloy UI - jsp-tags

I am making a simple form using Alloy UI. It has an image upload field. I want to restrict image file size say, to less than 10MB.
I have tried <aui:validator name="min"> and <aui:validator name="max"> in my view.jsp.
But, this is not working.
What should be used here to restrict image file size?

It seems you want a validation of file size on the client side i.e. using Alloy UI javascript, so I am sorry to bring to your notice that this is not possible in pre-HTML5 browsers due to some security reasons but this is possible with browsers which support the File-API in HTML5. Here is a good-demo site for the file-API.
So for now I would suggest that you do this server-side as a fallback mechanism & there are different plugins available to help you do this using Ajax or just go with plain server-side validation.
You can also try using flash with alloy-ui to check file-size as liferay does in its Documents & Media portlet. The drawback with this approach is that it requires flash to be installed in your browser.
Here is a SO answer which may help you give more information about client-side validation alongwith a demo.
Hope this would give you some lead.

Related

Upload multiple files on a domino server with SSJS

I need to upload multiple files (doc, jpg, pdf) and want to do this via Ajax. There are several description for clientside code, for instant here. So this part is covered well. But I did not find a counterpart description how to laod and store those docs with SSJS code on a domino server.
Can anyone give some hints where to find a description or may have some code snippets ?
Also it would be interesting to learn about incremental upload methods.
As ever, it's worth checking OpenNTF. Here are a couple of controls designed for that, YouAtNotes HTML5 Multiple File Upload and XPages Async Multiple File Uploader.

Does someone know of 'iPaper-secure'-like service?

I've been using Scribd secure and their javascript/PHP api for few years. I've made a custom upload page where I upload books and automatically disable printing/downloading/copying, because this is what my client wants. Those books are then embedded into a page on my site.
I was never really satisfied with Scribd API and their 'iPaper secure' because it is not really secure but I wasn't able to find better solution for displaying documents to registered members while restricting save/copy/print. And Scribd developer support was very bad. But I lived with that.
Unfortunately, I just noticed that printing is no longer disabled on my 'secured' documents, because Scribd removed this option almost 3 years ago, without my knowledge :)
Please, does anybody know of any way for me to host books 'securely'?
Thanx in advance!
There are several PDF to html converters which would allow you to put the content on your site (with full control) or you could use something like PDF.js to display files.

Pre-generating a JSF based web app for better performance and offline mode

I have a JSF web application, where the dynamic content is based on data taken from a database.
Since all the data is available in advance, I would like to see if there is a way to pre-generate all the pages into their final HTML format on the server, so that the user experiences much better performance and doesn't have to wait for the page generation.
Moreover - my app is running on mobile devices and I want to have the option of using it offline, by downloading everything to the device in advance (assume I don't need any business logic to work at real time).
So, I'm not talking here about the built-in caching of JSF - I'm looking for a kind of method that converts a JSF app into some static website that works much faster and can run offline as well.
Thanks.
You can use HTML5 for offline cache.
See a few articles about it here:
Tutorial
Tutorial
There are more examples on the internet for HTML5 and working offline

Is there a security threat if I enable a user to add CSS?

Is it not secure to enable user to add his own rules of CSS to his personal page, in (for example) a social website ?
It is not secure. There are multiple ways to embed JavaScript in CSS such that it gets executed by at least some browsers. Google "XSS CSS" and look through the top hits.
Don't do this unless you're willing to do hardcore sanitization of the CSS, and to clean up the mess when your sanitization is inevitably bypassed and your users' cookies are compromised.
Allowing them to enter the CSS as free-form text (or upload a file) could lead to security problems. It might be safer to give them a Control Panel that lets them customize the look and feel (with limiations of course, it might be impossible to build a form that lets them customize EVERYthing), and implement the customization via CSS, while storing their settings as values in a structured set of database tables.
I think somebody answered this question before.
History lesson: myspace allowed custom CSS and scripts. For those of you not hanging around on the web in 2003 or so, this was a major security threat. Later on, the mass of user generated CSS which had been a selling point became a major detriment to the platform as many changes and improvements could not be made as they effectively had created a public API for their CSS hooks.
So it is a really, really bad idea to let users do CSS.

Hosting Google Apps UI in my app

I'm investigating the possibility of re-using Google Apps/Docs in a local hybrid desktop/browser application.
I've been going through the Google documentation on manipulating docs, eg. the Spreadsheet. I can't seem to find any info on actually hosting the UI. Is this possible, or does it require some form of permission from Google?
You want to basically embed an browser control in your application pointed at the URL of a Google Apps doc? You could use the Google Document List API to retrieve the documents for a user, then use the URLs of those documents in your embedded browser control.
You don't need Google's permission to do that; you're writing a browser with some extra smarts built in.
What do you mean by "hosting the UI?" These apps are HTML/CSS/JavaScript. Are you thinking about embedding them in AIR or Titanium, or in some kind of web control in another app?
i briefly looked into doing this, and figured if i really wanted to i could just load the gdocs page content dynamically, and use javascript to strip away the superflous elements like header and footer. but instead i'll probably just use an OS alternate because they have come a long way and I want rich hooks.

Resources