Showing posts with label JSF. Show all posts
Showing posts with label JSF. Show all posts

Wednesday

Handling AJAX call error on client side

Just put the below code snippet to a JS file as below. (I used  immediately invoked functional expressions)

It is an error listener, it is called when JSF ajax request/response cyle gets an error.
(function jsfAjaxErrorHandler() {
 jsf.ajax.addOnError(function(data) {
   var log = "status:" +  data.status;
   log += " <br> message:" + data.message;
   log += " <br> description:" + data.description;
   log += " <br> serverErrorName:" + data.serverErrorName;
   log += " <br> serverErrorMessage:" + data.serverErrorMessage;
   log += " <br> source:" + data.source;
   log += " <br> responseCode:" + data.responseCode;
   log += " <br> responseText:" + data.responseText;
   log += " <br> responseXML:" + data.responseXML;
   
   alert(log);
 });
})();

Then load your js file but your js file must be loaded after JSF's own 'jsf.js' file.
<h:outputScript library="javax.faces" name="jsf.js"/>
<h:outputScript name="/yours.js" library="js"/> 

Tuesday

How to learn which vendor / version is using in jsf webapp? (MyFaces or Mojarra)

You can run the following code fragment in your application:
import javax.faces.context.FacesContext;

System.out.println("imp title: " + FacesContext.class.getPackage().getImplementationTitle());
System.out.println("impl vendor " + FacesContext.class.getPackage().getImplementationVendor());
System.out.println("imp version: " + FacesContext.class.getPackage().getImplementationVersion());
Sample output:

imp title: Apache MyFaces JSF-2.2 Core API
impl vendor The Apache Software Foundation
imp version: 2.2.11

Friday

Execute two methods in action

You can use f:actionListener to execute 2 methods in action:
<a4j:commandbutton action="{method1()}" value="deneme" >                              
   <f:actionlistener binding="#{method2()}"/>
<a4j:commandbutton>

Tuesday

Critical error during deployment: : com.sun.faces.config.ConfigurationException: Factory 'javax.faces.render.RenderKitFactory' was not configured properly

BUG:
I was trying to deploy a JSF (RichFaces) application in JBOSS 7.1.0 and I got following error:

Critical error during deployment: : com.sun.faces.config.ConfigurationException: Factory 'javax.faces.render.RenderKitFactory' was not configured properly


FIX:
Add following parameters to the web.xml:

<listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>