JSF 2.0 Lifecycle listner - jsf-2

How will i write My custom lifecycle listner for jsf 2
For jsf 1.2 BalusC has provided good tutorial but in JSF2 we do not have faces-config.xml
can we use faces-config.xml.if yes can you please provide me sample..If no then how do we register listners in jsf 2.0
Thanks A Lot

You can still create the file faces-config.xml and put in WEB-INF folder. The header of your faces-config.xml should look like this:
<?xml version='1.0' encoding='UTF-8'?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
// Your configuration here
</faces-config>
Notice that the version is now 2.0.

Related

Error declaring <ehcache:annotation-driven cache-manager="ehCacheManager" /> bean

At work we use the Spring (or rather Google) ehcache manager. Oddly, I'm getting an error in Spring STS that my coworkers, also using Spring STS and using the exact same code, do not get. The following line in my pom.xml file is marked as an error (or a "problem" according to Spring STS).
<ehcache:annotation-driven cache-manager="ehCacheManager" />
The reason given is this:
The matching wildcard is strict, but no declaration can be found for element 'ehcache:annotation-driven'.
In case it might be helpful, here are the schema declarations at the top of my pom.xml file.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd">
Both Spring STS and my specific project/workspace are using Java 8 as a compiler and runtime environment. So I don't think that's an issue. I also did a project refresh, a Maven update, and a mvn clean install.
I did some research and looked at this question as well as this one. The conclusion seems to be that one of my schemas is no longer hosted and so it cannot figure out what <ehcache:annotation-driven cache-manager="ehCacheManager"/> means. It seems that the http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd schema is missing, which can be confirmed if you simply try to visit the URL.
The comments on this question suggest that I avoid the Google ehcache and use the Spring one instead. How should I go about this? Ideally I would like to avoid changing the schemas that we use, since after all it works for my co-workers. But maybe that's because they were able to pull from the Google ehcache schema while it was still being hosted. Is it really necessary to change from the Google schema to the Spring schema, and if so how should I implement this in my POM file?
Try this
<cache:annotation-driven cache-manager="ehCacheManager" />

vaadin 7 missing web.xml file change default page

im new to vaadin but noticed that you can in vaadin 6 set the default page in the web.xml file but in vaadin 7 this has been done away with.
how do i change the default page ?
Thanks
I am not quite sure what you mean by "default page", so I have to make some guesses.
As you say that you are missing the web.xml, you probably mean a project created by Vaadin Plugin for Eclipse or the Maven archetype. By default, the wizard (or Maven archetype) creates a project stub that uses Servlet API 3.0 deployment with #WebServlet annotation for the servlet class, which is a static class nested in the UI class. It can also be a regular (non-nested and non-static) class, but that's how it is in the application stub.
If you choose Servlet API 2.4 for the new Vaadin 7 Eclipse project, it will use web.xml to define the servlet and UI class, as well as their parameters.
You can mix #WebServlet and web.xml deployment, in which case settings done in web.xml override the ones given with #WebServlet annotation.
Default page to serve is not actually a need to be defined since the framwork handles everything, especially with 3.0 servlet implementation.
But sometimes one may need such file (like, for example, to add context listeners for Spring).
So you can either select the option to generate it during project creation or just make a blank web.xml file in WebContent/WEB-INF.
The autogenerated plugin file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>YOUR_APP_NAME</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>

Delete Quickbooks Journal Entries QBXML

Is there a way to programatically delete Journal Entries in Quickbooks desktop (Enterprise Ed 2013) using an API like QBXML? I understand that the usual practice would be a compensating entry, but this use case calls for deleting the JE. I see that JournalEntryModRq allows you to modify it, but not delete it. It can be deleted using the UI, so it must be possible, yes?
We are using the QB Web Connector, any other options if not via QBXML?
You can use TxnDel to delete an transaction-type object using qbXML.
Here's some example (from this QuickBooks wiki, specifically this page):
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="11.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<TxnDelRq>
<TxnDelType>JournalEntry</TxnDelType>
<TxnID>ABCD-1234</TxnID>
</TxnDelRq>
</QBXMLMsgsRq>
</QBXML>

Some questions about view duration/life time

In my web project, most of the pages are using View Scoped managed beans.
It's working great, but sometimes, i notice that if i get away from the page for a time, like, 10 minutes, when i return back to the page, everything in the page stops working, and no console errors are shown in the server.
I think this is due to the life of a view, but have found nothing about it.
Where can i find info about it?
Is there a way to configure the life time of a view?
I'm using apache tomcat 7.
Below is my web.xml configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>AtualyGestao</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>home</param-value>
</context-param>
You should see it if you have paid attention to the HTTP response of the ajax request in browser's developer toolset (press F12 in Chrome/Firebug/IE9):
Indeed, the session has expired. An elaborate explanation about why this is a problem for JSF can be found in this answer: javax.faces.application.ViewExpiredException: View could not be restored.
JSF ajax requests have by default no form of feedback in case of exceptions. How to fix this is already answered here: Session timeout and ViewExpiredException handling on JSF/PrimeFaces ajax request.

spring security 3: sick and tired. can anyone copy a simple project including JARS

I have wasted more than 5 hours in analyzing the error Configuration problem: You cannot use a spring-security-2.0.xsd schema with Spring Security 3.0. Please update your schema declarations to the 3.0 schema.
tried so many different versions of jars
nothing worked out
I am literally helpless..
PLS CAN ANYONE COPY A SAMPLE SPRING SECURITY 3 PROJECT including the jars??
i thank you
The error suggests that you have mess in your jars and xml configuration. I bet you have something like
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.3.xsd
">
<!-- stuff here -->
</beans:beans>
in your security-context.xml, and you are using older version of Spring Security (i.e. 3.0) while the above configuration requires version 3.0.3. Please be sure, that all spring-security-XXX-YYY.jars are in the same version (especially check the presense of spring-security-config), and update your schema to appropriate version, which you define in this line:
http://www.springframework.org/schema/security/spring-security-3.0.xsd
http://www.springframework.org/schema/security/spring-security-3.0.xsd solved same problem I was facing in my code. +1 #Xaerxess.

Resources