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

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.

Related

Omnifaces cache in JSF

I want create simple cache in my JSF project. I view a few method of cache in web app (Guava, Redis etc.) and I choose Omnifaces cache. I found example here, but in this example Omnifaces is used for chart with tag in XHTML. In my project I created charts dynamically in Java code so maybe someone know how use it in my case. I dont't have <p:chart>tag in my project. Maybe is something better for JSF cache than Omnifaces.
Quoting from http://showcase.omnifaces.org/components/cache
The component allows to cache a fragment of rendered markup.
So this is usefull if you want to cache already rendered code which is expensive to rerender.
In your case you need a Java cache. One of the easiest solutions is to use the life cycle model of CDI beans to cache the results. Using #Inject inject a reference to your cached results. You may want to choose different strategies depending on your use-case.

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.

Primefaces 2.2.1 with FileUpload from Primefaces 3.0

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

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.

Can I Turn Off Implicit Navigation in Jsf 2.0?

I'm migrating old projects from JSF 1.2 to JSF 2.0.
The projects are JSP based.
I'm having trouble with implicit navigation after the migration.
The action methods that return values (Let's say, for internal use) cause JSF to try to navigate to non existing pages.
For example, a method that return "Error" will make the browser try to access /Error.jsp which will result in a 404.
I would like, for these projects, to turn off implicit navigation.
Is that possible?
Thanks!
No, that's not possible. It's however planned for JSF 2.2, see also JSF spec issue 937.
What is it, the internal use for which you're trying to (ab?)use navigation outcomes? Exception handling? You might want to throw a normal exception instead and handle it the usual way.

Resources