JSF Duplicate Id issue in Alfresco webclient - jsf

I am using myfaces 1.1.8 and Alfresco 3.3.5
Even after giving id for all the JSF component in browse.jsp page i am facing duplicate id exception.
"java.lang.IllegalStateException: duplicate Id for a component browse:browse-col9"
This id is not repeated anywhere still it gives duplicate exception. Exception comes randomly.
Please let me know how can i resolve this issue.

This can happen if you've bound the component to a session or application scoped bean using binding and the view where the component is located is subject to dynamic changes (when components are dynamically added/removed).
You would then need to bind it to a request scoped bean instead, or to look for an alternative way for the binding or the dynamic nature of the view.

Related

How to listen on a stateless POST request and set JSF managed bean properties

I have a Java-EE application that works with JSF (ManagedBean, ManagedProperty, ect ...) and Spring framework. I need to be able to retrieve data via a javascript form sent from an external website. I have opened the rights to authorize the CORS (Cross Origin or Cross Domain).
I would like to know what is the best way to grab an external form with JSF so that it is processed by my ManagedBean.
To make my question more explicit I made a diagram
==============
EDIT
The application works with JSF, I'm looking for a way to retrieve data (from a Javascript form on an external site) in a ManagedBean under JSF. I tried to retrieve this data by creating a Java-EE standard servlet and using the doPost ... methods of HttpServlet. But this solution does not work (this was the subject of my previous question on S.O). Several people told me that in a web application do not mix Java-EE standard and JSF, it is either Servlet or JSF. I made a diagram (above) explaining quickly what I am trying to do.
To recap: I would like to retrieve data from an external website (via a Javascript form) in the ManagedBean of my application.
==============
I've already tried with a standard Java-EE servlet but it's not the right way. Indeed, with a standard servlet I can recover the data from the form but I can not access the ManagedBean. I must therefore have abandoned this hypothesis.
I did not find a similar question about Stackoverflow, If necessary I can give more indications.
Thank you for your help.

JSF throwing exception in cluster environment - Component ID j_idt311 has already been found in the view.

I'm running GlassFish 3.1.2.2 in fail-over cluster. Session replication is configured and works perfectly. Project is in JSF and PrimeFaces using extensive AJAX. The problem is when server fails-over to another node on AJAX call I'm getting the exception:
java.lang.IllegalStateException: Component ID j_idt311 has already been found in the view.
at com.sun.faces.util.Util.checkIdUniqueness(Util.java:846)
at .....
Manually assigning IDs to every component on every page is impractical. Is there way to resolve the problem in more practical way?
Thank you.

How to use CDI Conversation Filter in JSF2.2 Application

In my JSF 2.2 bases application I created a wizard which is based on #ConversationScope. To deal with errors I added CDI Conversation Filter to my web.xml.
My first question is about the right url-pattern for the filter-mapping. My Wizard runs behind the url /report/*. If I use this as pattern, all other pages throw the following exception:
javax.servlet.ServletException: A request must be associated with the context in order to load the known conversations
So, i had to use "/*" as pattern, which worked fine so far.
But now, I want to integrate container-managed security. When requesting the restricted resource, the mentioned error is thrown, when redirecting to login-page.
Does anybody know, how to solve that?
Thanks in advance.

Injecting blueprint OSGi service into JSF/PrimeFaces bean

I have a project built on top OSGi and Karaf server. For dependency injection we are using Aries Blueprint.
The main part of the project is a Apache Camel routes and integration things, but now I need to create some maintenance web interface.
So I give a try to JSF - PrimeFaces implementation. I was able to create some demo, which works in OSGi under Karaf, that's ok.
Now I'd like to know if it's possible to use Blueprint here, to reference some already existing OSGi services we have and inject the service into JSF Bean, so we can benefit from already written code.
Can you help me, please?
We solved this in the following way:
We created a listener that:
Creates a ServiceTracker that tracks the BlueprintContainer service attached to the same bundle
Puts the servicetracker into the ServletContext attributes
We created an ELResolver that uses this ServiceTracker and if there is a BlueprintContainer available it uses the getComponentInstance of that to get the value
The listener opens the servicetracer during application initialization and closes it during application destroy
Our listener class: https://source.everit.biz/svn/everit-util/trunk/core/src/main/java/org/everit/util/core/servlet/ServiceLoaderListener.java
Our EL resolver class: https://source.everit.biz/svn/everit-util/trunk/core/src/main/java/org/everit/util/core/el/OsgiELResolver.java
User/pass: guest/guest
After you registered your custom el-resolver all el-expressions will be evaluated in the way that id-s of component instances will be searched inside the blueprint container. In case you say that you have a bean-property in your faces-config.xml with the value #{myComponent} it will be searched inside the BlueprintContainer.

Managed bean Constructor is not getting fired in page navigation

I am using MyFaces 1.1.14. I have two JSPX pages with JSF components and my managed bean is in request scope. At first page, bean constructor is getting fired and when I submit a form it is fired again. But after my app navigates to the new page, it is not getting fired. The constructor is supposed to be called, right?
The thing is that page is accessing some properties of the bean — those setters get called — no problem with that, but why is the constructor not called? When the page get loaded I need to get data from previous process (i.e from different framework). What is the problem with my understandings?
The navigation does by default not fire a new HTTP request. Instead, a different view is been used as content of the current HTTP response. Only when you navigate with a redirect by appending the <redirect/> entry to the <navigation-case>, then a new HTTP request would be created.
You should totally understand it if you're familiar with RequestDispatcher#forward() concept of the basic Servlet API which JSF is sitting on top of.
See also:
What is the difference between redirect and navigation/forward and when to use what? - Note that the code examples are targeted at JSF 2.x, but the principles apply as good on JSF 1.x.

Resources