0

Is it possible to use Malsup's plugin to upload files like this example using JSF 2.2 so I can use its progress bar?

On html forms, it seems to work around the 'name' attribute from the <input type="file">s, all 3 being "myfile[]" in the example. Unfortunately, its equivalent in jsf is <h:inputFile>, which doesn't have a name attribute. Well, <h:inputFile> can have an id and then its name will have the same value in the generated html, but since ids are unique, so will be their names.

The thing is, I don't know how/if the names impact on how the plugin handles a submit with multiple inputs. That's what got me thinking in the first place.

The same "no-name attribute" goes for the <h:form>, but it isn't that bad, since I'll only have 1 form anyway, thus I can just give it an id for a name. It doesn't have an action either, which seems to be used by the plugin, but I can overcome that with a <h:commandButton type="submit" action="someaction">, although I don't know if that's ok with the plugin. At least for the example, it looks good.

I've been playing with this plugin for a couple of days now, but I guess it's time to ask for an explanation. Can someone shed some light on those points? If it's possible with jsf, how would the example's form look like? Bear in mind that my ultimate goal is to try the plugin's progress bar out. Setting those inputs adequately is just a means to achieve that.

Pedral
  • 141
  • 5
  • Wait, why are you preferring a whole jQuery plugin over just adding a `` tag? – BalusC Jan 23 '15 at 08:04
  • I wanna check its progress bar out. I should have stated that before, so it wouldn't look like I was just trying to ajaxify things. I'll add that to my question. – Pedral Jan 23 '15 at 12:46
  • Are you understanding what you can do with JSF? It seems that you're completely missing its point and falling back to "plain vanilla" HTML/JS. You could just look for a JSF progress bar component. If you're so hooked to jQuery, look at PrimeFaces. This JSF component library is completely based on jQuery / jQuery UI. See also http://www.primefaces.org/showcase/ui/misc/progressBar.xhtml Another food for reading: http://stackoverflow.com/questions/4421839/what-is-the-need-of-jsf-when-ui-can-be-achieved-from-css-html-javascript-jquery/ – BalusC Jan 23 '15 at 12:48
  • Well, I do feel like I'm lacking some basic knowledge now that you brought that up. Until now, I've only used pure jsf and maybe I'm too centered around it, even though I knew prime/rich/icefaces were there. So, considering my newbieness, let's say I wish to get primefaces' progress bar. Do I need the whole library or is there a way to get only the bar? Assuming the latter, how do I achieve that? Some food for reading on this topic would be nice. :) – Pedral Jan 23 '15 at 14:00
  • A friend told me I would need the whole primefaces library, just as I thought, but that's not what I want. As a matter of fact, I've coded a progress bar in jQuery, which I'm currently using in my JSF project. The reason I wan't to JSFy this plugin is so I can compare the bars, play around with them, etc. It doesn't seem impossible, I'm just unsure about how the plugin handles those attributes and how to adequately translate some of them from html tags to jsf. – Pedral Jan 24 '15 at 12:50
  • You can of course create a custom component based on it. That's exactly what all those JSF component libraries also do. – BalusC Jan 25 '15 at 21:54

0 Answers0