c:if as part of composite:insertChildren - jsf

I am trying to migrate one app to new app server and JSF seems to start behaving differently due to different JSF implementation. It is MyFaces 2.0 now, that I am having problem with. This worked on older server:
there is composite component <abc:form> that includes <composite:insertChildren> tag.
when using this component in xhtml like this:
<abc:form>
<c:if test="true">
this text will not be visible. But it should be.
</c:if>
</abc:form>
this <c:if... part is children. However nothing is rendered. As if c:if resolved to false, or no testing occurs.
I am aware that this case can be resolved by utilizing <h:outputText> instead of <c:if>, but I have a lot of code where <c:if> is included in more complex children. This example is just a simplification that describes my pain.
So, is it legal to have jstl tags that are includeable as children to components? I assume JSP/JSF lifecycles are to blame here.
edit: As visible in comment below, this is a combination of JSF and portlet (WebSphere Portal 9 on WAS 8.5.5). I am still not sure whether portal (and portal bridge) or pure JSF is to be blamed here. Therefore I created demo project that manifests my problem. If there is any kind soul that can use this code to try deploying it to his/hers own portal, it would be much appreciated.
It was created in Rational Application Developer, by creating new portlet project with one JSF portlet inside. Then I added composite component to WebContent/resources, and modified default portlet view (xhtml).
Exported projects from RAD

I tested your code locally in a simple Tomcat webapp and c:if worked as expected as a child of your composite component. From your comments, you indicated that you are using the MyFaces Portlet Bridge for JSF 2.0. That version of the bridge is 3.0.0-alpha. Since things worked correctly in a webapp (even with MyFaces Core 2.0.0) and the portlet bridge version is still alpha, it seems extremely likely that there is a bug in the bridge (maybe PORTLETBRIDGE-179 ?). Since MyFaces bridge is no longer maintained, I'm doubtful that the bridge will ever be fixed.
I'd recommend that you work around this issue by replacing JSTL tags with JSF HTML tags that essentially render the same markup:
<c:if test="true">... -> <h:panelGroup rendered="true">...
<c:choose><c:when test="true">...<c:otherwise>...
->
<h:panelGroup rendered="true">...<h:panelGroup rendered="false">...
<c:set> -> <ui:param>
<c:forEach> -> <ui:repeat>
See also: JSTL in JSF2 Facelets... makes sense?
One other, more difficult solution would be to implement your composite component as a simple custom Java component or full custom Java component instead.
If there is any kind soul that can use this code to try deploying it to his/hers own portal, it would be much appreciated.
I could not reproduce this issue in Liferay 7.0 + JSF 2.2 + Liferay Faces Bridge 4.1.2. c:if worked fine as a child of your composite component. Full disclosure, I am a Liferay Faces Bridge developer. Unfortunately, I don't think Liferay Faces Bridge will solve your issue since we only support Mojarra (not MyFaces) and JSF 2.1+.

Related

Can Bootsfaces be used with Richfaces?

I have a web application with the following:
JSF 2.2.6
Java 1.7
Tomcat 8
Richfaces 4.5.7
Omnifaces 2.2
I would like to enhance the look and feel of the web app to use Bootsfaces. I have added Bootsfaces jar to my project (via .ivy) and rebuilt.
Before even updating the first web page to use Bootsfaces in the project I wanted to see if there were any conflicts after adding the Bootsfaces jar. It seems there is. I am getting the following errors shown in Firebug:
ReferenceError: jsf is not defined
TypeError: RichFaces.ui is undefined
Does anyone know whether Bootsfaces works with Richfaces and if so could they kindly provide a link with migration steps to follow?
Currently, we, the BootsFaces team, do not support RichFaces. We strive for compatibility with PrimeFaces, OmniFaces, AngularFaces and - if possible - ButterFaces. Neither RichFaces nor ICEFaces are on our list.
However, if someone were to join our team in order to support RichFaces, they'd certainly be welcome!

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.

Is p:media incompatible with view scope?

I am using jsf 2.1 in a web project with primefaces 3.5 and glassfish 3.2.
When I use p:media tag along with a view scoped managed bean, an error occurs indicating an xml parsing error.
I am not pretty shure if this leadds to the same problem like with using Richfaces and its a4j:mediaOutput. There you cannot use it in ViewScope but here is a link to a workaround. I hope it fits to your problem.

IceFaces and PrimeFaces portlets on the same Liferay page

I have portlets written on IceFaces 1.8.2.
Since I found PrimeFaces better I decided to write my new portlet with JSF2 and PrimeFaces 3.5.
Separately everything is working. But when I'm trying to put my PrimeFaces portlet and IceFaces portlet on one page PrimeFaces doesn't work.
UI is more or less alright, but there are a lot of mistakes in javascript.
Can I solve this problem somehow?
I'm using Liferay 6.0.6
Do not include Primefaces and Icefaces portlets on the same portal page!
Since they both rely on jQuery, they will both include (potentially different versions of) jQuery on the page which will cause javascript conflicts. There may be workarounds for this (although I don't know of any), but it is an extremely bad idea.

JSF 1.2 application migration to JSF 2.0

Currently, my web-application is based on the following libraries / frameworks / tools:
Java 1.6
JSF 1.2_07-b03-FCS
Facelets 1.1.14
Richfaces 3.3.2.GA
EL-Functors 1.0.2
Spring 2.5.2
Tomcat server v5.5
Some additional information:
Spring is in charge of managing all the beans used by JSF (org.springframework.web.jsf.DelegatingVariableResolver is defined as the variable-resolver in my faces-config.xml file).
EL-Functors is used as my el-resolver in order to extend the Expression Language.
I've created many custom components, some of them are just Facelets compositions, others are Java-based components (some of them are extending Richfaces components).
I want to try (essentially for curiosity, but if this works well, why not for real?) to migrate my application to JSF 2.0.
Question #1: what are the critical points that I must consider in order to make my application working correctly?
I am talking here about just having a working application, nothing less, nothing more.
I alread know that I will have to review all my custom components, because I will use the new version of Richfaces (4.0), and also see if they work correctly.
Question #2: what will be the first steps to achieve to take advantages of JSF 2.0?
Some ideas I already have are:
Remove EL-Functors and use the Expression Language 2.2;
Let JSF manage the beans, and use the #ManagedBean. Or maybe switch to a CDI library, such as Weld?
Use <f:ajax> instead of <a4j:support>?
Regarding JavaEE6
I know, a good idea would be to completely move to JavaEE6. I'd liked to do so, but for some reasons I just can't do that way. One (bad) reason is that I must stay on Tomcat servers.
However, I can add new third-party libraries in order to have some JavaEE6 features, such as EL 2.2...
So please consider this aspect in your answers.
Regards.
Since Richfaces 4 is still under development you may want to use Richfaces 3.3.3 with JSF 2.0.
Thus you have to use Facelets 1.1.15 as described here http://community.jboss.org/wiki/RichFaces333andJSF20
This implies that switching from a4j:support to f:ajax won't work with your Richfaces based components so I suggest to stick to a a4j:support. This will also keep the migration effort low if you decide to switch to Richfaces 4 as soon as it is available.
Since you already use Spring to manage your JSF-Beans there should be no need to use the DI-Features of JSF2. I'd stick to Spring but consider an update to Spring 3.
Besides this, Weld is definitley worth to take a look at.
HTH
If you plan to stay with Tomcat, then moving to Java EE 6 means you're going to be looking at Tomcat version 7.
But if you want a full-fledged Java EE 6 server then GlassFish 3 or JBoss 6 is a better alternative. Tomcat can be iffy when you try to do certain thing like CDI (Weld) or EJB 3.
Just my two cents worth. Hope it helps...

Resources