JSF Managed bean methods not getting called - ajax

We are currently developing a JSF 2 application and we are using OpenFaces.
One "intermittent" issue that we have been noticing is that the managed bean method "sometimes" doesn't get called.
For example:
<o:commandLink onclick="wait();" action="#{createAccountContractManagedBean.executeSave}"
execute="panGrp_createAccountContractMainTabLocal"
render="panGrp_createAccountContractLocalErrorMessages label_contractNumber pnlGrp_editCustomerGroup"
styleClass="buttonOrange"
onajaxend="wait();setTabFocus('inpHdn_contractErr','tabPane_MainLocal',3);return false;">
<span>
<h:outputLabel value="#{message['application.common.button.saveandcontinue']}"/>
</span>
</o:commandLink>
wait() is a javascript function that show a modal dialog that the request is currently in process.
setTabFocus() is a javascript function that sets the focus onto a new tab if the current save request is successful.
public void executeSave() {
if (getLoggingService().isDebugLevelEnable()) {
getLoggingService().debug(this, "executeSave");
}
// ...
}
The issue is that sometimes the managed bean method executeSave() doesn't fire at all. No log message or error.
But at the same time the onajaxend() method always fires and since there is no error, it switches the focus to the next tab.
We have tried by removing the wait(); and the setTabFocus(); methods.
All the components are in the same <h:form> element and there are no multiple forms.
What might be the possible causes when a managed bean method doesn't execute with no error trace?
May mixing JSF <h:xxx> components and <o:xxx> components in the same form cause problems?
Does mixing <o:ajax> and <f:ajax> cause problems?
Is there a possibility that on a complex form with many OpenFaces popups, that the ajax functionality might misbehave?

What might be the possible causes when a managed bean method doesn't execute with no error trace?
You could try to turn ON logging like it described here. Also you could take a look with some browser debugger tool to the ajax response from server, it probably could contain some error information.
May mixing JSF components and components in the same form cause problems?
No, in common OF have full compatibility with JSF. In some really complicated cases you could get some problems, but I don't think that the situation you've described one of them.
does mixing and cause problems?
It's normal to mix them.
Is there a possibility that on a complex form with many OpenFaces popups, that the ajax functionality might misbehave?
Of course it possible that there are some bugs in OF or even JSF, but usually you will get at list some error information in such situation. Also you could try to update to latest nightly build. Or post you problem to OF support forum.

Related

executing portlet event phase without render phase

I need to cancel renderProcessing (doView method) from executing after processing Action or Event phase (As i don't want the whole page or any portlets to be refreshed). Something like ajax resource acquiring which is not leading to refresh all portlets (I mean serveResource method). Can we use "destroy()" method at the end of ProcessAction or ProcessEvent to prevent renderPhase from executing. I'm using MVCPortlet framework and events ipc extensively in my portlets. Thanks for your help.
As Georgy Gobozov stated in the comment: The answer to your question is "No".
If you are using the standard portlet request handling and rely on event handling, you're bound to a full page reload. There's nothing that keeps you from implementing custom event handling (e.g. with JS on the browser, through your business layer etc.) but unfortunately you'll have to do exactly this.
When you start the original request, e.g. through an action handler, the page has already started to reload (from the browser perspective). Any attempt to cancel the processing server side will result in the stream to break and the browser signalling an error on the page (e.g. "can't load": The result must come with an HTTP status - and it will most likely be an error code (e.g. 50x), or it must contain the whole page's HTML.

Kendo UI Grid/DataSource - Global Error Handling?

I've currently inherited an application which has numerous Kendo grids (and other controls) throughout, and I'm trying to fix an error which keeps cropping up now and again - specifically when the user is no longer authenticated.
I know what the solution is for a single instance of the control - return a flag to indicate authentication failed, and then detect this in the error handler and perform the authentication.
The problem is am I really going to have to handle this for every instance of a Kendo control I have? Is there not a global error handler I can hook into? Either for the data source itself (as I know this is used for all Kendo control data loading), or for the Grid specificially. I don't mind either way - just which one is a hook.
This would be a more straighforward short term solution than refactoring everything to specific error handlers, etc.
I assume you can attach a global error handler to $.ajax, which is used by the DataSource, you can check how to do it here:
http://api.jquery.com/category/ajax/global-ajax-event-handlers/
Or, you can take advanttage of that the configuration that is done in the DataSource is passed directly to the $.ajax:
http://docs.kendoui.com/api/framework/datasource#configuration-transport.read-ObjectStringFunction
For reference, someone from Telerik has provided a solution using just the DataSource. I haven't tested it, but I prefer the accepted answer above as it hooked into all Ajax on the site - not just ones that utilise the Kendo DataSource.
http://www.kendoui.com/forums/mvc/grid/global-error-handler-for-numerous-grids.aspx

How can I set the view timeout?

In our JSF2 project on JBoss 7.1.1, we define a session timeout in the web.xml and it works just fine.
However, sometimes we're getting view expiration, leading to errors like this one even if the session is still alive:
javax.faces.application.ViewExpiredException: viewId:/... - View /... could
not be restored.
Where can we set the view timeout, like we did for sessions? Or is the view expiration caused by something else?
Another cause of ViewExpiredException is that too many logical views are been created in the session. The default limit is JSF implementation specific and every synchronous GET request on a particular view basically creates a new view. So, for example, when you use Mojarra (which has a default limit of 15) and start a browser session and open the same view in 16 different tabs and then submit a form in the 1st one, then you may get this exception as well. The limit is configureable with a JSF implementation specific context parameter, which is com.sun.faces.numberOfLogicalViews for Mojarra and org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION in MyFaces (defaults to 20).
This is however a very rare real world problem. If your webapp is really designed to be used this way (e.g. a social/community site which invites to being opened in multiple tabs, such as discussion forum or Q&A), then you might consider using client side state saving instead.
See also:
javax.faces.application.ViewExpiredException: View could not be restored
com.sun.faces.numberOfViewsInSession vs com.sun.faces.numberOfLogicalViews

QueryString.AllKeys Lowercase?

I'm having some strange behaviour under ASP.NET MVC3. On certain requests, I'm seeing my AllKeys collection of the QueryString having all the keys in lowercase!
The code in question is similar to the following:-
helper.ViewContext.RequestContext.HttpContext.Request.QueryString.AllKeys
Where "helper" is a System.Web.Mvc.HtmlHelper of type T of my ViewModel. This behaviour appears to be sporadic, but is causing issues as some of the downstream code in my system is expecting a case-dependant QueryString.
To try and diagnose the issue, I threw together a quick HttpModule and can confirm that on the BeginRequest event, the QueryString is NOT lowercased. So, I think something is happening within the MVC pipeline, possibly...?
Any ideas?
Thanks,
Mark

JSF 1.1 and Ajax4jsf not working properly on Websphere 6.1

I am working with JSF 1.1, Ajax4JSF. What I find is, if I enable a4j:support for some of JSF's inputText items, it is not working as expected. I have something like this in the code
<h:inputText value="#{bean.desc}">
<a4j:support event="onkeyup" reRender="id"/>
</h:inputText>
And what I find is, sometimes it does not work, for example, I type TEST on the input text box and what transfers is only the "T" to the backing bean.
One more problem that I see is, when I submit the form, some of the values are not getting set in the backing bean. The setter methods are not called at all.
I do not think this is working properly in my env, is it this combination of JSF1.1,Ajax4JSF and websphere6.1 is not supported or is there anyway I can troubleshoot this ?
EDIT :
Sometimes when I am producing ajax messages by some event like onkeyup, I get the following error (this does not come always but at times) -
Request Error:status : 500 Internal Server Error Message: undefined.
I've no experience of deploying to Websphere, but i'd be surprised if your ajax problem was a result of the deployment environment...
There's one obvious potential problem that jumps out once reading the markup; you've setup your ajax callback to trigger onkeyup... so it makes sense that T is being passed to the backing bean, as releasing the T key will invoke the call. You might want to consider using a better javascript event, perhaps onblur.

Resources