Faces messages not shown until the page is refreshed - jsf

I'm using JSF1.2, Tomcat 6.0, RichFaces 3.3.3, and Java 6u31.
I do an action in the managed bean, and show a message to the user. That's OK.
After that, I do another action in managed, and then the messages doesn't work anymore until I refresh the page.
I can assure you that the problem isn't in the managed bean, because I just removed all the method impl, leaving it empty, and the bug still happens.
So, the problem is something in the xhtml pages. I tried to put an a4j:status, but it doenst show any error.
So, I see myself without hope. I will not post all the code here, because it's too big and complex.
I wonder if one of you ever seen something like this, or if you have one guess of whats happening. I can edit the question adding any info you want.

I solve this problem.
I has a onupload in the rich:fileupload.
I just remove it, and add a a4j:support, like this:
<a4j:support event="onupload" oncomplete="foo()" />
That's it. I just don't understand why it works that way, and doesnt in the old way.
BTW, thanks.

Related

multiple forms in jsf primefaces

I am developing a primefaces 5.2 application and using tomcat. I have a file upload component. For the file upload component to work, I changed the enctype. Later I decided to split the form into two. That's where my problems started. When I have two forms such as this
<h:form id="mainForm">
</h:form>
<h:form id="uploadForm" enctype="multipart/form-data">
</h:form>
does not work. Even the first form requests are not submitted anymore. If I take out the enctype from the second form, everything works.
I have looked at the data going across the network for the second form with and without the form-data. It looks like data is the same using Firebug.
Since it does not give me any error messages, I am kind of stuck. Where should I look? Thanks.
What's interesting is I add the enctype of form-data to the first form and remove from the second, things still work.
The problem is the fact that I have not added the primefaces filter. Now that I have added the filter to web.xml. My problem becomes why does it not work in IE 10 consistently. It works the first time, but does not work on subsequent refreshes.
I have not been able to figure it out yet. It seems if I change compatibility mode, the app starts working but after every page refresh (non-ajax), it goes back to a weird behaviour where first click does not work but second one does...Almost as if some javascript problem...
That's related to an IE problem/single sign on filter. Read more about it another question.

requestContext update/execute... doesn't work when <h:head> is present

I have a portlet deployed in liferay 6.2 (Tomcat 7.0.42).
I use Primefaces 4 and liferay bridge 3.2.4-ga5.
I am aware of this post:
RequestContext won't work
But I have a strange problem here:
Primefaces doesn't work without the h:head tags, but when I add them the site won't update when I send the data to the bean. According to the server log the fields get updated, the p:log will say that the DOM has been updated, but nothing happens on the site, unless I remove the h:head tags. In that case the site will update with the new data, but primefaces won't work/display properly.
I even tried this demo example 1:1:
http://www.primefaces.org/showcase/ui/misc/requestContext.xhtml
But the outcome is the same.
I'm not sure what might be causing this.
Any ideas?
Thanks&BR
Edit:
Ok, I just found out, that I need to add the namespace to the update method.
So in the case of portlets it's not enough to use update("form:obj"), but update("namespace:form:obj) ... that head tag thing is still kinda strange.
try
context.update(":formId:panelId");
or
context.update(":panelId");

Using binding attribute causes javax.faces.FacesException: Cannot find component with identifier

I have a problem I can't quite get a handle on.
First the context: I am developing a web application using Primefaces 3.5 (yes, unfortunately I am stuck with this old version for now), running on JBoss 7.
There is a form with id "form" encompassing all following xhtml code.
I have a component in my view which is provided by usage of the binding attribute:
<p:dashboard id="dashboard" binding="#{myBackingBean.dashboard}" />
Then sometimes I would like to perform an ajax update on this component, this is done by using the RemoteCommand component of primefaces:
<p:remoteCommand
actionListener="#{myBackingBean.someActionListener()}"
process="#this" id="myRmtCmd" oncomplete="myJsFunction();"
update=":form:dashboard" name="myRemoteCommand" />
The RemoteCommand is triggered by a clicking on a Link:
Some Text
This works pretty well so far. However after deploying this code to production I sometimes get a FacesException:
javax.faces.FacesException: Cannot find component with identifier ":form:dashboard"
referenced from "form:myRmtCmd".
This is where my problem lies because I cannot reliably reproduce this exception. My question is this: What could lead to this exception being thrown? It seems to work 95 % of the time but being the perfectionist I am (and many of you reading this are as well, I'm sure ;) ) I would like this code to work 100 % of the time. What am I missing?
Before answering please consider these constraints:
yes, i have to use the binding attribute for providing the dashboard as I need a great deal of control over what gets added to the component
to avoid using IDs I also tried updating the dashboard by its css class via one of primefaces' advanced selectors: #(.ui-dashboard) - this also does not work!
yes, it would be possible to use a commandbutton/link instead of wiring up the remotecommand component to a simple html link but in this case the link is rendered by a JSF renderer component and I made some bad experiences with dynamically adding buttons etc (due to JSF Spec Issue 790)
Cheers,
p.s.
I also had this weird behavior.
There are probably more than one component bindded to #{myBackingBean.dashboard}, so the first one sets the id and there will be no one called "dashboard".

Postback via <h:commandLink> to same page causes duplicate entries in browser history

With plain Jsf postback to same page (with return null in method) from commandLink, I am ending up with two duplicate entries in browser history. One entry with url with ending # and one with url without ending #. Please help if you have any idea why this could happen and advice avoiding it.
I am assuming this is not a standard behavior with JSF postback request. Please help confirming it.
Also please suggest where I could be going wrong. I am using Myfaces 2.1
Also any pointer to debug this scenario is very much appreciated.
Thanks very much for your help.
I have found out my issue. As I had expected, it is not the issue with JSF as such. I have commandLinks with onclick method, for disabling all the hyperLink controls to prevent repeated submits. That method is also setting location.href = "#" before returning true, and this was the cause of double entries in browser back history. Posting the answer, hoping it will help others with same scenarios. Thanks all for viewing this question.

IceFaces: inputRichText - session timeout while typing

I'm using the inputRichText component for composing HTML-formatted messages in a system I'm working on.
I've encountered a problem, however. It seems the session times out, even when the user is working in the editor.
I tried setting the session timeout parameter in web.xml to 1 minute and started typing in the editor. After 1 minute the "User session expired" dialog box appeared. Is there any way to make the rich text editor component keep the session alive? It's pretty annoying to work on something for a while only to loose it to a session time out, event though you haven't been inactive.
This is the code I use to display the component in the page:
<ice:inputRichText height="250" toolbar="MyToolbar" customConfigPath="/FCKconfig.js" id="messageBody" value="#{bean.messageBody}" language="sv" saveOnSubmit="true" />
Thanks!
Edit:
I solved it using a periodic JavaScript calling into a servlet implementing the stuff outlined in this IceFaces JIRA report
If there's a better way, please let me know :)
I solved it using a periodic JavaScript calling into a servlet implementing the stuff outlined in this IceFaces JIRA report.
It basically allows a servlet to "touch" the session and hence keep it alive.
If there's a better way, please let me know :)

Resources