Primefaces 2.2.1 with FileUpload from Primefaces 3.0 - jsf

Related to the last comment on this question, i would like to know if anyone managed to use the HTML5-Fileupload of Primefaces 3.0 with an older Primefaces version.
We have a lot of trouble with the old flash-version of the fileupload.
I know that the best option would be to update the whole project to the new primefaces version but it´s not possible for this project.

This is not going to be trivial. That you're already asking this question already indicates that it's going to be a long journey. I'd rather use a barebones and to-the-point file upload component of another component library such as Tomahawk's <t:inputFileUpload>. It only doesn't support asynchronous uploading and you need to make the submit button of the form a non-ajax one, but it does the job you want it to do without much hassle.
You can find in this answer detailed step-by-step instructions how to integrate and use it in your project: JSF 2.0 File upload. In case of PrimeFaces, you only need to make sure that you have removed PrimeFaces' own file upload filter from the web.xml, otherwise it would consume the uploaded file before Tomahawk's own filter get the chance.

Thats very difficult, I have many problems with fileupload and finally migate to 3.0 but witch are problems?.
If you wanna to change fileupload you will can change source code in library is not very smarted if you desnt know jquery ui o you can use other framework or use directly.
http://www.matlus.com/html5-file-upload-with-progress/
good luck

Related

Websphere 8.0/MyFaces2.0 and PrimeFaces 6 not compatible?

I'm currently trying to use PrimeFaces (not mobile) for my WebSphere 8.0 application. The basic stuff like p:dataTable seems to work. But if I want to use the fancy stuff of PrimeFaces, like filter columns or pagination, there is either a NullPointerException or the additional function is not rendered at all.
The Nullpointer occurred when entering something in the generated filtering field in the table. The setter method that is called is given null as parameter.
The pagination on the other hand is not even being rendered. (I used the templates of the PrimeFace showcase)
Weird thing is, the sorting by column function is working fine.
I haven't done any big adjustments, just put the .jar file to my classpath and disabled all themes of PrimeFaces in my web.xml. That's it.
When I inspect the network and stuff in chrome there is no exception thrown in the console when loading the page.
Now I'm thinking that this version of PrimeFaces is not compatible with MyFaces2.0 that is used by WAS8.0.
Is that the case? If so, what version of PF would be compatible? Or would it be possible to load a newer Version of MyFaces and dependencies and put it in WAS to use this version instead of the current used version?
Or maybe I have to make some adjustments to my application?
If everything is not possible, do you know an alternative to PF to easily create tables?
Using a third-party JSF provider with WebSphere is documented here (the doc is for 8.5.5, but it's the same procedure in 8.0): https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/tweb_jsf.html
Basically, the answer is to put your provider (along with the corresponding API) into a shared library, set that library to use an isolated class loader, and associate that shared library with your web app. That will tell the web module's class loader to search your shared library before it delegates to server class loaders, and it'll find your JSF provider first when your app attempts to use JSF.

Implementing ICAL calendars jsf

Im trying to implement ical calendars using java1.8/jsf2.2 in a way that makes embedding them into outlook possible:
It be good if i could store generated calendars and update them automatically. I intend to pass the needed parameters in the url. Something like
http://example.com/ical/calendars.ics?id=12&includeAll=1
I found primefaces FileDownload but Im not sure that is what I need. Maybe some FileServlet? I stumbled upon omnifaces' FileServlet and figured since I have the omnifaces jar anyway I could try to use that. Or the old version of BalusC found here: http://balusc.omnifaces.org/2007/07/fileservlet.html
Would any of those approaches even work?
What Im thinking is storing generated calendars in a temp folder and update them dayly. Or, using a FileServlet, I could generate them on request. Im not sure how to go at it. Which of the suggested ways is the best? Or are all of them wrong?
Since OmniFaces contains the mentioned FileServlet only from Version 2 onwards, which requires CDI, I wont be able to use it because I used Spring for DI. Otherwise that would have been the solution...
Using the BalusC's FileServlet I proposed in my question, I'm able to generate stuff on request.

What needs to be change when migrationg from jsf 1.x to jsf 2.x , richafaces 3.x to 4.x

I am new to jsf.
I am working on migration project.
In this I need to migrate from jsf1.2 to 2.1
and richfaces as well..
In general what I need to change?
I have one more requirement that navigation rules must be quoted explicitly in faces-config.xml?
How to write these rules in faces-config.xml?
Thanks in Advance
First you should understand that this is a painfull to migrate from JSF 1.x to jsf 2.x but it is even more painfull to migrate from Richfaces 3 to Richfaces 4.
JSF 1.x to 2.x upgrade can be done independently from Richface upgrade. So I would recommend you first update JSF and check that everything is working and only after that try updating Richfaces. Look at this question about JSF migration for more info. Or just google it. There is a lot of info about it.
Richfaces 3 to 4 migration is very very painfull because JSF 2 introduced it's own ajax and you will need to change a lot of attributes all overt the project. But the biggest pain is that Richfaces 3 work much more stable than Richfaces 4. Richfaces 4 is very buggy. I can list some bugs that I encountered and some solutions for them.
rich:autocomplete is very buggy. Not sure if it is fixed already
but when I tried using it it was not working with Spring in
composite views(<ui:include pages). After I sumbitted bug report
they seem to do something there but not sure if this works now. I
didn't check. https://issues.jboss.org/browse/RF-11469
I would advise you to replace this component with simple jQuery UI
autocomplete component with some spring mvc controller on backend.
rich:tabPanel is very buggy. Separate tabs do not have action
attribute any more. This was breaking functionality with initing tab
contents when the tab was opened with ajax. Immediate attribute also
not working for tabs. Here is the issue on jboss jira: https://issues.jboss.org/browse/RF-11417 workaround is really stupid.
I just went into source code of richfaces and made it working.
Exception handling is very buggy. Seems that exceptions are just
swallowed in many places in richfaces source on ajax requests so you
can not handle them the right way.
I went again into Richfaces code and removed exception swallowing by
throwing out exceptions.
rich:fileUpload component can work and can not work for you. You
can get request prolog can not be read exception in some
cases(This is what I was getting). And This is connected with new
app server feature of reading multipart request into
request.getParts(). And Richfaces do not handle such situation and
error out because inputstream of multipart request is already read
fully.
I again went to source code of Richfaces and added catch for
situation when request.getParts is not empty. I even created an
issue on Jboss but guys said this works on new Jboss server that's
why it is not an issue(I use tomcat). https://issues.jboss.org/browse/RF-13061 the issue is close still it is not working on tomcat.
A lot of issues on client side. By default multiple forms will not
work on your pages like they were working in jsf 1.2 and richfaces 3
because the viewstate id is not updated where and when it needs to
be.
To fix this you will need to add additional script. It is described
in the answer to this question
Also on the client side you should know that if in the response of
any ajax request you will have some js that will fail everything
stops working. You can not have js errors inside xhtml. The page
will freeze completelly. Also it is tricky to have CDATA tags on
the xhtml pages. They can also fail.
Richfaces messages work the way that sometimes they show up and
sometimes not. They are ajax rendered but seems that they can break
the page. Ajax reposnse can have an update that should update
messages that is not rendered on the page and when it will not find
this message in your html it will stop rendering everything that is
left to update. As a result your links and buttons will not rerender
anything in some cases.
Here evaluating limitRenderattribute helps a lot.
It is a short list. There probably a lot more to be aware of and that you will see after update =)) Richfaces 4 are still buggy.

How to upload file in RichFaces 4?

I need to make a file upload function in JSF 2 so I was searching about it and found it is possible to do with Tomahawk, which I think is not very stable with JSF 2.
I'm using RichFaces, so I look for it and found this which I think more simple, but I'm using richfaces 4.
So I wonder if there's a way to do this with richfaces 4 or do this with JSF 2 only.
Any idea, suggestion ?
You're looking at RichFaces 3.3.x demo site. You need to look at RichFaces 4.x demo site. The <rich:fileUpload> demo page contains a concrete example with source code.
To do it with pure JSF2, you'd need to create a custom component and parse the multipart/form-data requests yourself. There's a blog about this with complete and concrete examples: Uploading files with JSF 2.0 and Servlet 3.0.
Using Tomahawk is only more easy. I'm not sure why you think that it's not very stable.

Using reCaptcha

I want to use reCaptcha on my project with JSF. Corresponding primefaces component doesn't want to work properly inside wizard component. I decided to try to use the code from example for JSP http://code.google.com/intl/en-en/apis/recaptcha/docs/java.html I can not understand how best to remake it to JSF. The problem is in java code injection into JSP and result validation via FacesValidator.
Can someone have any ideas?
Take a look at tomahawk t:captcha on MyFaces SVN. The code only use the standard JSF API (it was updated to use JSF 2.0 ResourceHandler API), so it can help you to build your own using recaptcha.

Resources