kohuke 0 Newbie Poster

Hi again (I'm annoying i know, but i just get stuck with things).
I'm using this tutorial: http://www.netbeans.org/kb/61/web/jsf-jpa-crud-wizard.html
I'm using it in combination with mysql+tomcat not java database+classfish.
I have imported the following libraries (after googling what is needed for persistance in tomcat and mysql):
JSF 1.1
JSF 1.2
JTA
JSF 1.1/1.2 Support
MySql JDBC Driver
TopLink Essentials
WebUIComponenets
WebUi Default theme an the usual libraries which is added automatically in netbeans.

I use the automatic generation of the java class files. and my problem is that the main page
where it displays the links is just fine.
Welcome.JSF:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%--
    This file is an entry point for JavaServer Faces application.
--%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <f:view>
            <h:form>
<h1><h:outputText value="JavaServer Faces" /></h1>
    <br/>
<h:commandLink action="#{propertyType.listSetup}" value="Show All PropertyType Items"/>

    <br/>
<h:commandLink action="#{propertyClass.listSetup}" value="Show All PropertyClass Items"/>

    <br/>
<h:commandLink action="#{property.listSetup}" value="Show All Property Items"/>

    <br/>
<h:commandLink action="#{employee.listSetup}" value="Show All Employee Items"/>
</h:form>

        </f:view>
    </body>
</html>

But as soon as i click on any of the links i get:

HTTP Status 500 - 

--------------------------------------------------------------------------------

type Status report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.16

this error.

Also i see some errors in catalin.log files:

7.08.2008 9:13:29 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0_06\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\Program Files\ZipGenius 6\;C:\Program Files\Rational\common;C:\Program Files\WinSCP\;C:\Program Files\Intel\DMIX;C:\Program Files\MySQL\MySQL Server 5.0\bin
7.08.2008 9:13:29 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8084
7.08.2008 9:13:29 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 415 ms
7.08.2008 9:13:29 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
7.08.2008 9:13:29 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.16
7.08.2008 9:13:30 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8084
7.08.2008 9:13:30 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
7.08.2008 9:13:30 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16  config=null
7.08.2008 9:13:30 org.apache.catalina.startup.Catalina start
INFO: Server startup in 496 ms
7.08.2008 9:13:30 com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Sun's JavaServer Faces implementation (1.2_04-b20-p03) for context '/Varad2'
7.08.2008 9:13:32 org.apache.catalina.core.StandardContext start
INFO: Container org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/Varad2] has already been started
7.08.2008 9:13:35 com.sun.faces.application.ApplicationAssociate createAndMaybeStoreManagedBeans
SEVERE: JSF1001: Managedbean propertyClass could not be created.
7.08.2008 9:13:35 com.sun.faces.lifecycle.LifecycleImpl phase
WARNING: executePhase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@b2fb1e) threw exception
com.sun.rave.web.ui.appbase.ApplicationException: javax.faces.FacesException: javax.naming.NameNotFoundException: Name entities.PropertyClassController is not bound in this Context
	at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.cleanup(ViewHandlerImpl.java:594)
	at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:311)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:619)
Caused by: javax.faces.FacesException: javax.faces.FacesException: javax.naming.NameNotFoundException: Name entities.PropertyClassController is not bound in this Context
	at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:537)
	at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
	at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
	at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61)
	at org.apache.el.parser.AstValue.getTarget(AstValue.java:59)
	at org.apache.el.parser.AstValue.invoke(AstValue.java:148)
	at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
	at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
	at com.sun.rave.web.ui.appbase.faces.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
	at javax.faces.component.UICommand.broadcast(UICommand.java:383)
	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
	... 15 more
Caused by: javax.faces.FacesException: javax.naming.NameNotFoundException: Name entities.PropertyClassController is not bound in this Context
	at com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:340)
	at com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:527)
	... 33 more
Caused by: javax.naming.NameNotFoundException: Name entities.PropertyClassController is not bound in this Context
	at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
	at org.apache.catalina.util.DefaultAnnotationProcessor.lookupFieldResource(DefaultAnnotationProcessor.java:203)
	at org.apache.catalina.util.DefaultAnnotationProcessor.processAnnotations(DefaultAnnotationProcessor.java:135)
	at com.sun.faces.vendor.Tomcat6InjectionProvider.inject(Tomcat6InjectionProvider.java:46)
	at com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:298)
	... 34 more
7.08.2008 9:13:35 com.sun.faces.lifecycle.LifecycleImpl phase
WARNING: phase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@b2fb1e) threw exception: com.sun.rave.web.ui.appbase.ApplicationException: javax.faces.FacesException: javax.naming.NameNotFoundException: Name entities.PropertyClassController is not bound in this Context javax.faces.FacesException: javax.naming.NameNotFoundException: Name entities.PropertyClassController is not bound in this Context
com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.cleanup(ViewHandlerImpl.java:594)
com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.afterPhase(ViewHandlerImpl.java:470)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Thread.java:619)

Can some please explain what there error mean. I think those are the problems which cause the page not to show stuff.

The source code itself (atleast for one object - property) is as follows:
Detail.jsp:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Property Detail</title>
    </head>
    <body>
        <f:view>
            <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            <h1>Property Detail</h1>
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputText value="Property:"/>
                    <h:outputText value="#{property.property.property}" title="Property" />
                    <h:outputText value="Name:"/>
                    <h:outputText value="#{property.property.name}" title="Name" />
                    <h:outputText value="Created:"/>
                    <h:outputText value="#{property.property.created}" title="Created" >
                        <f:convertDateTime type="TIMESTAMP" pattern="MM/dd/yyyy HH:mm:ss" />
                    </h:outputText>
                    <h:outputText value="Updated:"/>
                    <h:outputText value="#{property.property.updated}" title="Updated" >
                        <f:convertDateTime type="TIMESTAMP" pattern="MM/dd/yyyy HH:mm:ss" />
                    </h:outputText>
                    <h:outputText value="CreatedBy:"/>
                    <h:panelGroup>
                        <h:outputText value=" #{property.property.createdBy}"/>
                        <h:panelGroup rendered="#{property.property.createdBy != null}">
                            <h:outputText value=" ("/>
                            <h:commandLink value="Show" action="#{employee.detailSetup}">
                                <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}"/>
                                <f:param name="jsfcrud.currentEmployee" value="#{employee.asString[property.property.createdBy]}"/>
                                <f:param name="jsfcrud.relatedController" value="property"/>
                                <f:param name="jsfcrud.relatedControllerType" value="entities.PropertyController"/>
                            </h:commandLink>
                            <h:outputText value=" "/>
                            <h:commandLink value="Edit" action="#{employee.editSetup}">
                                <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}"/>
                                <f:param name="jsfcrud.currentEmployee" value="#{employee.asString[property.property.createdBy]}"/>
                                <f:param name="jsfcrud.relatedController" value="property"/>
                                <f:param name="jsfcrud.relatedControllerType" value="entities.PropertyController"/>
                            </h:commandLink>
                            <h:outputText value=" "/>
                            <h:commandLink value="Destroy" action="#{employee.destroy}">
                                <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}"/>
                                <f:param name="jsfcrud.currentEmployee" value="#{employee.asString[property.property.createdBy]}"/>
                                <f:param name="jsfcrud.relatedController" value="property"/>
                                <f:param name="jsfcrud.relatedControllerType" value="entities.PropertyController"/>
                            </h:commandLink>
                            <h:outputText value=" )"/>
                        </h:panelGroup>
                    </h:panelGroup>
                    <h:outputText value="PropertyType:"/>
                    <h:panelGroup>
                        <h:outputText value=" #{property.property.propertyType}"/>
                        <h:panelGroup rendered="#{property.property.propertyType != null}">
                            <h:outputText value=" ("/>
                            <h:commandLink value="Show" action="#{propertyType.detailSetup}">
                                <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}"/>
                                <f:param name="jsfcrud.currentPropertyType" value="#{propertyType.asString[property.property.propertyType]}"/>
                                <f:param name="jsfcrud.relatedController" value="property"/>
                                <f:param name="jsfcrud.relatedControllerType" value="entities.PropertyController"/>
                            </h:commandLink>
                            <h:outputText value=" "/>
                            <h:commandLink value="Edit" action="#{propertyType.editSetup}">
                                <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}"/>
                                <f:param name="jsfcrud.currentPropertyType" value="#{propertyType.asString[property.property.propertyType]}"/>
                                <f:param name="jsfcrud.relatedController" value="property"/>
                                <f:param name="jsfcrud.relatedControllerType" value="entities.PropertyController"/>
                            </h:commandLink>
                            <h:outputText value=" "/>
                            <h:commandLink value="Destroy" action="#{propertyType.destroy}">
                                <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}"/>
                                <f:param name="jsfcrud.currentPropertyType" value="#{propertyType.asString[property.property.propertyType]}"/>
                                <f:param name="jsfcrud.relatedController" value="property"/>
                                <f:param name="jsfcrud.relatedControllerType" value="entities.PropertyController"/>
                            </h:commandLink>
                            <h:outputText value=" )"/>
                        </h:panelGroup>
                    </h:panelGroup>
                    <h:outputText value="UpdatedBy:"/>
                    <h:panelGroup>
                        <h:outputText value=" #{property.property.updatedBy}"/>
                        <h:panelGroup rendered="#{property.property.updatedBy != null}">
                            <h:outputText value=" ("/>
                            <h:commandLink value="Show" action="#{employee.detailSetup}">
                                <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}"/>
                                <f:param name="jsfcrud.currentEmployee" value="#{employee.asString[property.property.updatedBy]}"/>
                                <f:param name="jsfcrud.relatedController" value="property"/>
                                <f:param name="jsfcrud.relatedControllerType" value="entities.PropertyController"/>
                            </h:commandLink>
                            <h:outputText value=" "/>
                            <h:commandLink value="Edit" action="#{employee.editSetup}">
                                <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}"/>
                                <f:param name="jsfcrud.currentEmployee" value="#{employee.asString[property.property.updatedBy]}"/>
                                <f:param name="jsfcrud.relatedController" value="property"/>
                                <f:param name="jsfcrud.relatedControllerType" value="entities.PropertyController"/>
                            </h:commandLink>
                            <h:outputText value=" "/>
                            <h:commandLink value="Destroy" action="#{employee.destroy}">
                                <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}"/>
                                <f:param name="jsfcrud.currentEmployee" value="#{employee.asString[property.property.updatedBy]}"/>
                                <f:param name="jsfcrud.relatedController" value="property"/>
                                <f:param name="jsfcrud.relatedControllerType" value="entities.PropertyController"/>
                            </h:commandLink>
                            <h:outputText value=" )"/>
                        </h:panelGroup>
                    </h:panelGroup>
                </h:panelGrid>
                <br />
                <h:commandLink action="#{property.destroy}" value="Destroy">
                    <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}" />
                </h:commandLink>
                <br />
                <br />
                <h:commandLink action="#{property.editSetup}" value="Edit">
                    <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}" />
                </h:commandLink>
                <br />
                <h:commandLink action="#{property.createSetup}" value="New Property" />
                <br />
                <h:commandLink action="#{property.listSetup}" value="Show All Property Items"/>
                <br />
                <a href="/Varad2/faces/welcomeJSF.jsp">Index</a>
            </h:form>
        </f:view>
    </body>
</html>

Edit.jsp:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Editing Property</title>
    </head>
    <body>
        <f:view>
            <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            <h1>Editing Property</h1>
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputText value="Property:"/>
                    <h:outputText value="#{property.property.property}" title="Property" />
                    <h:outputText value="Name:"/>
                    <h:inputText id="name" value="#{property.property.name}" title="Name" />
                    <h:outputText value="Created (MM/dd/yyyy HH:mm:ss):"/>
                    <h:inputText id="created" value="#{property.property.created}" title="Created" required="true" requiredMessage="The created field is required." >
                        <f:convertDateTime type="TIMESTAMP" pattern="MM/dd/yyyy HH:mm:ss" />
                    </h:inputText>
                    <h:outputText value="Updated (MM/dd/yyyy HH:mm:ss):"/>
                    <h:inputText id="updated" value="#{property.property.updated}" title="Updated" required="true" requiredMessage="The updated field is required." >
                        <f:convertDateTime type="TIMESTAMP" pattern="MM/dd/yyyy HH:mm:ss" />
                    </h:inputText>
                    <h:outputText value="CreatedBy:"/>
                    <h:selectOneMenu id="createdBy" value="#{property.property.createdBy}" title="CreatedBy" required="true" requiredMessage="The createdBy field is required." >
                        <f:selectItems value="#{employee.employeesAvailableSelectOne}"/>
                    </h:selectOneMenu>
                    <h:outputText value="PropertyType:"/>
                    <h:selectOneMenu id="propertyType" value="#{property.property.propertyType}" title="PropertyType" required="true" requiredMessage="The propertyType field is required." >
                        <f:selectItems value="#{propertyType.propertyTypesAvailableSelectOne}"/>
                    </h:selectOneMenu>
                    <h:outputText value="UpdatedBy:"/>
                    <h:selectOneMenu id="updatedBy" value="#{property.property.updatedBy}" title="UpdatedBy" >
                        <f:selectItems value="#{employee.employeesAvailableSelectOne}"/>
                    </h:selectOneMenu>
                </h:panelGrid>
                <br />
                <h:commandLink action="#{property.edit}" value="Save">
                    <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}"/>
                </h:commandLink>
                <br />
                <br />
                <h:commandLink action="#{property.detailSetup}" value="Show" immediate="true">
                    <f:param name="jsfcrud.currentProperty" value="#{property.asString[property.property]}"/>
                </h:commandLink>
                <br />
                <h:commandLink action="#{property.listSetup}" value="Show All Property Items" immediate="true"/>
                <br />
                <a href="/Varad2/faces/welcomeJSF.jsp">Index</a>
            </h:form>
        </f:view>
    </body>
</html>

List.jsp:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Listing Property Items</title>
    </head>
    <body>
        <f:view>
            <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            <h1>Listing Property Items</h1>
            <h:form>
                <h:outputText escape="false" value="(No Property Items Found)<br />" rendered="#{property.itemCount == 0}" />
                <h:panelGroup rendered="#{property.itemCount > 0}">
                    <h:outputText value="Item #{property.firstItem + 1}..#{property.lastItem} of #{property.itemCount}"/>&nbsp;
                    <h:commandLink action="#{property.prev}" value="Previous #{property.batchSize}" rendered="#{property.firstItem >= property.batchSize}"/>&nbsp;
                    <h:commandLink action="#{property.next}" value="Next #{property.batchSize}" rendered="#{property.lastItem + property.batchSize <= property.itemCount}"/>&nbsp;
                    <h:commandLink action="#{property.next}" value="Remaining #{property.itemCount - property.lastItem}"
                                   rendered="#{property.lastItem < property.itemCount && property.lastItem + property.batchSize > property.itemCount}"/>
                    <h:dataTable value='#{property.propertys}' var='item' border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_oddrow,jsfcrud_evenrow" rules="all" style="border:solid 1px">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Property"/>
                            </f:facet>
                            <h:outputText value=" #{item.property}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Name"/>
                            </f:facet>
                            <h:outputText value=" #{item.name}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Created"/>
                            </f:facet>
                            <h:outputText value="#{item.created}">
                                <f:convertDateTime type="TIMESTAMP" pattern="MM/dd/yyyy HH:mm:ss" />
                            </h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Updated"/>
                            </f:facet>
                            <h:outputText value="#{item.updated}">
                                <f:convertDateTime type="TIMESTAMP" pattern="MM/dd/yyyy HH:mm:ss" />
                            </h:outputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="CreatedBy"/>
                            </f:facet>
                            <h:outputText value=" #{item.createdBy}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="PropertyType"/>
                            </f:facet>
                            <h:outputText value=" #{item.propertyType}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="UpdatedBy"/>
                            </f:facet>
                            <h:outputText value=" #{item.updatedBy}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText escape="false" value="&nbsp;"/>
                            </f:facet>
                            <h:commandLink value="Show" action="#{property.detailSetup}">
                                <f:param name="jsfcrud.currentProperty" value="#{property.asString[item]}"/>
                            </h:commandLink>
                            <h:outputText value=" "/>
                            <h:commandLink value="Edit" action="#{property.editSetup}">
                                <f:param name="jsfcrud.currentProperty" value="#{property.asString[item]}"/>
                            </h:commandLink>
                            <h:outputText value=" "/>
                            <h:commandLink value="Destroy" action="#{property.destroy}">
                                <f:param name="jsfcrud.currentProperty" value="#{property.asString[item]}"/>
                            </h:commandLink>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
                <br />
                <h:commandLink action="#{property.createSetup}" value="New Property"/>
                <br />
                <a href="/Varad2/faces/welcomeJSF.jsp">Index</a>
                
            </h:form>
        </f:view>
    </body>
</html>

new.jsp:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>New Property</title>
    </head>
    <body>
        <f:view>
            <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            <h1>New Property</h1>
            <h:form>
                <h:inputHidden id="validateCreateField" validator="#{property.validateCreate}" value="value"/>
                <h:panelGrid columns="2">
                    <h:outputText value="Name:"/>
                    <h:inputText id="name" value="#{property.property.name}" title="Name" />
                    <h:outputText value="Created (MM/dd/yyyy HH:mm:ss):"/>
                    <h:inputText id="created" value="#{property.property.created}" title="Created" required="true" requiredMessage="The created field is required." >
                        <f:convertDateTime type="TIMESTAMP" pattern="MM/dd/yyyy HH:mm:ss" />
                    </h:inputText>
                    <h:outputText value="Updated (MM/dd/yyyy HH:mm:ss):"/>
                    <h:inputText id="updated" value="#{property.property.updated}" title="Updated" required="true" requiredMessage="The updated field is required." >
                        <f:convertDateTime type="TIMESTAMP" pattern="MM/dd/yyyy HH:mm:ss" />
                    </h:inputText>
                    <h:outputText value="CreatedBy:"/>
                    <h:selectOneMenu id="createdBy" value="#{property.property.createdBy}" title="CreatedBy" required="true" requiredMessage="The createdBy field is required." >
                        <f:selectItems value="#{employee.employeesAvailableSelectOne}"/>
                    </h:selectOneMenu>
                    <h:outputText value="PropertyType:"/>
                    <h:selectOneMenu id="propertyType" value="#{property.property.propertyType}" title="PropertyType" required="true" requiredMessage="The propertyType field is required." >
                        <f:selectItems value="#{propertyType.propertyTypesAvailableSelectOne}"/>
                    </h:selectOneMenu>
                    <h:outputText value="UpdatedBy:"/>
                    <h:selectOneMenu id="updatedBy" value="#{property.property.updatedBy}" title="UpdatedBy" >
                        <f:selectItems value="#{employee.employeesAvailableSelectOne}"/>
                    </h:selectOneMenu>
                </h:panelGrid>
                <br />
                <h:commandLink action="#{property.create}" value="Create"/>
                <br />
                <br />
                <h:commandLink action="#{property.listSetup}" value="Show All Property Items" immediate="true"/>
                <br />
                <a href="/Varad2/faces/welcomeJSF.jsp">Index</a>
            </h:form>
        </f:view>
    </body>
</html>

Property.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author kohuke
 */
@Entity
@Table(name = "property")
@NamedQueries({@NamedQuery(name = "Property.findByProperty", query = "SELECT p FROM Property p WHERE p.property = :property"), @NamedQuery(name = "Property.findByName", query = "SELECT p FROM Property p WHERE p.name = :name"), @NamedQuery(name = "Property.findByCreated", query = "SELECT p FROM Property p WHERE p.created = :created"), @NamedQuery(name = "Property.findByUpdated", query = "SELECT p FROM Property p WHERE p.updated = :updated")})
public class Property implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "property", nullable = false)
    private Integer property;
    @Column(name = "name")
    private String name;
    @Column(name = "created", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date created;
    @Column(name = "updated", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date updated;
    @JoinColumn(name = "created_by", referencedColumnName = "employee")
    @ManyToOne(optional = false)
    private Employee createdBy;
    @JoinColumn(name = "property_type", referencedColumnName = "property_type")
    @ManyToOne(optional = false)
    private PropertyType propertyType;
    @JoinColumn(name = "updated_by", referencedColumnName = "employee")
    @ManyToOne
    private Employee updatedBy;

    public Property() {
    }

    public Property(Integer property) {
        this.property = property;
    }

    public Property(Integer property, Date created, Date updated) {
        this.property = property;
        this.created = created;
        this.updated = updated;
    }

    public Integer getProperty() {
        return property;
    }

    public void setProperty(Integer property) {
        this.property = property;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public Employee getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(Employee createdBy) {
        this.createdBy = createdBy;
    }

    public PropertyType getPropertyType() {
        return propertyType;
    }

    public void setPropertyType(PropertyType propertyType) {
        this.propertyType = propertyType;
    }

    public Employee getUpdatedBy() {
        return updatedBy;
    }

    public void setUpdatedBy(Employee updatedBy) {
        this.updatedBy = updatedBy;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (property != null ? property.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Property)) {
            return false;
        }
        Property other = (Property) object;
        if ((this.property == null && other.property != null) || (this.property != null && !this.property.equals(other.property))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return  property + ","+name+","+created+","+updated+","+createdBy+","+propertyType+","+updatedBy;
    }

}

PropertyClass.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author kohuke
 */
@Entity
@Table(name = "property_class")
@NamedQueries({@NamedQuery(name = "PropertyClass.findByPropertyClass", query = "SELECT p FROM PropertyClass p WHERE p.propertyClass = :propertyClass"), @NamedQuery(name = "PropertyClass.findByName", query = "SELECT p FROM PropertyClass p WHERE p.name = :name"), @NamedQuery(name = "PropertyClass.findByDescription", query = "SELECT p FROM PropertyClass p WHERE p.description = :description")})
public class PropertyClass implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "property_class", nullable = false)
    private Integer propertyClass;
    @Column(name = "name")
    private String name;
    @Column(name = "description")
    private String description;
    @OneToMany(mappedBy = "propertyClass")
    private Collection<PropertyType> propertyTypeCollection;

    public PropertyClass() {
    }

    public PropertyClass(Integer propertyClass) {
        this.propertyClass = propertyClass;
    }

    public Integer getPropertyClass() {
        return propertyClass;
    }

    public void setPropertyClass(Integer propertyClass) {
        this.propertyClass = propertyClass;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Collection<PropertyType> getPropertyTypeCollection() {
        return propertyTypeCollection;
    }

    public void setPropertyTypeCollection(Collection<PropertyType> propertyTypeCollection) {
        this.propertyTypeCollection = propertyTypeCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (propertyClass != null ? propertyClass.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PropertyClass)) {
            return false;
        }
        PropertyClass other = (PropertyClass) object;
        if ((this.propertyClass == null && other.propertyClass != null) || (this.propertyClass != null && !this.propertyClass.equals(other.propertyClass))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.PropertyClass[propertyClass=" + propertyClass + "]";
    }

}

PropertyClassController.java:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import javax.persistence.Query;
import javax.faces.application.FacesMessage;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.faces.FacesException;
import java.util.HashMap;
import javax.faces.validator.ValidatorException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import javax.transaction.UserTransaction;

/**
 *
 * @author kohuke
 */
public class PropertyClassController {
    private PropertyClass propertyClass = null;
    private List<PropertyClass> propertyClasss = null;
    @Resource
    private UserTransaction utx = null;
    @PersistenceUnit(unitName = "Varad2PU")
    private EntityManagerFactory emf = null;

    public EntityManager getEntityManager() {
        return emf.createEntityManager();
    }
    public int batchSize = 5;
    private int firstItem = 0;
    private int itemCount = -1;

    public void setPropertyTypeCollectionOfPropertyClass(PropertyType[] propertyTypeCollection) {
        List<PropertyType> propertyTypeCollectionList = Arrays.asList(propertyTypeCollection);
        propertyClass.setPropertyTypeCollection(propertyTypeCollectionList);
    }

    public PropertyType[] getPropertyTypeCollectionOfPropertyClass() {
        Collection<PropertyType> propertyTypeCollection = propertyClass.getPropertyTypeCollection();
        if (propertyTypeCollection == null) {
            return new PropertyType[0];
        }
        return propertyTypeCollection.toArray(new PropertyType[0]);
    }

    public SelectItem[] getPropertyClasssAvailableSelectMany() {
        return getPropertyClasssAvailable(false);
    }

    public SelectItem[] getPropertyClasssAvailableSelectOne() {
        return getPropertyClasssAvailable(true);
    }

    private SelectItem[] getPropertyClasssAvailable(boolean one) {
        List<PropertyClass> allPropertyClasss = getPropertyClasss(true);
        int size = one ? allPropertyClasss.size() + 1 : allPropertyClasss.size();
        SelectItem[] items = new SelectItem[size];
        int i = 0;
        if (one) {
            items[0] = new SelectItem("", "---");
            i++;
        }
        for (PropertyClass x : allPropertyClasss) {
            items[i++] = new SelectItem(x, x.toString());
        }
        return items;
    }

    public PropertyClass getPropertyClass() {
        if (propertyClass == null) {
            propertyClass = getPropertyClassFromRequest();
        }
        if (propertyClass == null) {
            propertyClass = new PropertyClass();
        }
        return propertyClass;
    }

    public String listSetup() {
        reset(true);
        return "propertyClass_list";
    }

    public String createSetup() {
        reset(false);
        propertyClass = new PropertyClass();
        return "propertyClass_create";
    }

    public String create() {
        if (propertyClass.getPropertyTypeCollection() == null) {
            propertyClass.setPropertyTypeCollection(new ArrayList<PropertyType>());
        }
        EntityManager em = getEntityManager();
        try {
            utx.begin();
            List<PropertyType> attachedPropertyTypeCollection = new ArrayList<PropertyType>();
            for (PropertyType propertyTypeCollectionPropertyTypeToAttach : propertyClass.getPropertyTypeCollection()) {
                propertyTypeCollectionPropertyTypeToAttach = em.getReference(propertyTypeCollectionPropertyTypeToAttach.getClass(), propertyTypeCollectionPropertyTypeToAttach.getPropertyType());
                attachedPropertyTypeCollection.add(propertyTypeCollectionPropertyTypeToAttach);
            }
            propertyClass.setPropertyTypeCollection(attachedPropertyTypeCollection);
            em.persist(propertyClass);
            for (PropertyType propertyTypeCollectionPropertyType : propertyClass.getPropertyTypeCollection()) {
                PropertyClass oldPropertyClassOfPropertyTypeCollectionPropertyType = propertyTypeCollectionPropertyType.getPropertyClass();
                propertyTypeCollectionPropertyType.setPropertyClass(propertyClass);
                propertyTypeCollectionPropertyType = em.merge(propertyTypeCollectionPropertyType);
                if (oldPropertyClassOfPropertyTypeCollectionPropertyType != null) {
                    oldPropertyClassOfPropertyTypeCollectionPropertyType.getPropertyTypeCollection().remove(propertyTypeCollectionPropertyType);
                    oldPropertyClassOfPropertyTypeCollectionPropertyType = em.merge(oldPropertyClassOfPropertyTypeCollectionPropertyType);
                }
            }
            utx.commit();
            addSuccessMessage("PropertyClass was successfully created.");
        } catch (Exception ex) {
            try {
                if (findPropertyClass(propertyClass.getPropertyClass()) != null) {
                    addErrorMessage("PropertyClass " + propertyClass + " already exists.");
                } else {
                    ensureAddErrorMessage(ex, "A persistence error occurred.");
                }
                utx.rollback();
            } catch (Exception e) {
                ensureAddErrorMessage(e, "An error occurred attempting to roll back the transaction.");
            }
            return null;
        } finally {
            em.close();
        }
        return listSetup();
    }

    public String detailSetup() {
        return scalarSetup("propertyClass_detail");
    }

    public String editSetup() {
        return scalarSetup("propertyClass_edit");
    }

    private String scalarSetup(String destination) {
        reset(false);
        propertyClass = getPropertyClassFromRequest();
        if (propertyClass == null) {
            String requestPropertyClassString = getRequestParameter("jsfcrud.currentPropertyClass");
            addErrorMessage("The propertyClass with id " + requestPropertyClassString + " no longer exists.");
            String relatedControllerOutcome = relatedControllerOutcome();
            if (relatedControllerOutcome != null) {
                return relatedControllerOutcome;
            }
            return listSetup();
        }
        return destination;
    }

    public String edit() {
        PropertyClassConverter converter = new PropertyClassConverter();
        String propertyClassString = converter.getAsString(FacesContext.getCurrentInstance(), null, propertyClass);
        String currentPropertyClassString = getRequestParameter("jsfcrud.currentPropertyClass");
        if (propertyClassString == null || propertyClassString.length() == 0 || !propertyClassString.equals(currentPropertyClassString)) {
            String outcome = editSetup();
            if ("propertyClass_edit".equals(outcome)) {
                addErrorMessage("Could not edit propertyClass. Try again.");
            }
            return outcome;
        }
        EntityManager em = getEntityManager();
        try {
            utx.begin();
            PropertyClass persistentPropertyClass = em.find(PropertyClass.class, propertyClass.getPropertyClass());
            Collection<PropertyType> propertyTypeCollectionOld = persistentPropertyClass.getPropertyTypeCollection();
            Collection<PropertyType> propertyTypeCollectionNew = propertyClass.getPropertyTypeCollection();
            List<PropertyType> attachedPropertyTypeCollectionNew = new ArrayList<PropertyType>();
            for (PropertyType propertyTypeCollectionNewPropertyTypeToAttach : propertyTypeCollectionNew) {
                propertyTypeCollectionNewPropertyTypeToAttach = em.getReference(propertyTypeCollectionNewPropertyTypeToAttach.getClass(), propertyTypeCollectionNewPropertyTypeToAttach.getPropertyType());
                attachedPropertyTypeCollectionNew.add(propertyTypeCollectionNewPropertyTypeToAttach);
            }
            propertyTypeCollectionNew = attachedPropertyTypeCollectionNew;
            propertyClass.setPropertyTypeCollection(propertyTypeCollectionNew);
            propertyClass = em.merge(propertyClass);
            for (PropertyType propertyTypeCollectionOldPropertyType : propertyTypeCollectionOld) {
                if (!propertyTypeCollectionNew.contains(propertyTypeCollectionOldPropertyType)) {
                    propertyTypeCollectionOldPropertyType.setPropertyClass(null);
                    propertyTypeCollectionOldPropertyType = em.merge(propertyTypeCollectionOldPropertyType);
                }
            }
            for (PropertyType propertyTypeCollectionNewPropertyType : propertyTypeCollectionNew) {
                if (!propertyTypeCollectionOld.contains(propertyTypeCollectionNewPropertyType)) {
                    PropertyClass oldPropertyClassOfPropertyTypeCollectionNewPropertyType = propertyTypeCollectionNewPropertyType.getPropertyClass();
                    propertyTypeCollectionNewPropertyType.setPropertyClass(propertyClass);
                    propertyTypeCollectionNewPropertyType = em.merge(propertyTypeCollectionNewPropertyType);
                    if (oldPropertyClassOfPropertyTypeCollectionNewPropertyType != null && !oldPropertyClassOfPropertyTypeCollectionNewPropertyType.equals(propertyClass)) {
                        oldPropertyClassOfPropertyTypeCollectionNewPropertyType.getPropertyTypeCollection().remove(propertyTypeCollectionNewPropertyType);
                        oldPropertyClassOfPropertyTypeCollectionNewPropertyType = em.merge(oldPropertyClassOfPropertyTypeCollectionNewPropertyType);
                    }
                }
            }
            utx.commit();
            addSuccessMessage("PropertyClass was successfully updated.");
        } catch (Exception ex) {
            try {
                String msg = ex.getLocalizedMessage();
                if (msg != null && msg.length() > 0) {
                    addErrorMessage(msg);
                } else if (getPropertyClassFromRequest() == null) {
                    addErrorMessage("The propertyClass with id " + currentPropertyClassString + " no longer exists.");
                    utx.rollback();
                    return listSetup();
                } else {
                    addErrorMessage("A persistence error occurred.");
                }
                utx.rollback();
            } catch (Exception e) {
                ensureAddErrorMessage(e, "An error occurred attempting to roll back the transaction.");
            }
            return null;
        } finally {
            em.close();
        }
        return detailSetup();
    }

    public String destroy() {
        propertyClass = getPropertyClassFromRequest();
        if (propertyClass == null) {
            String currentPropertyClassString = getRequestParameter("jsfcrud.currentPropertyClass");
            addErrorMessage("The propertyClass with id " + currentPropertyClassString + " no longer exists.");
            String relatedControllerOutcome = relatedControllerOutcome();
            if (relatedControllerOutcome != null) {
                return relatedControllerOutcome;
            }
            return listSetup();
        }
        EntityManager em = getEntityManager();
        try {
            utx.begin();
            propertyClass = em.getReference(propertyClass.getClass(), propertyClass.getPropertyClass());
            Collection<PropertyType> propertyTypeCollection = propertyClass.getPropertyTypeCollection();
            for (PropertyType propertyTypeCollectionPropertyType : propertyTypeCollection) {
                propertyTypeCollectionPropertyType.setPropertyClass(null);
                propertyTypeCollectionPropertyType = em.merge(propertyTypeCollectionPropertyType);
            }
            em.remove(propertyClass);
            utx.commit();
            addSuccessMessage("PropertyClass was successfully deleted.");
        } catch (Exception ex) {
            try {
                ensureAddErrorMessage(ex, "A persistence error occurred.");
                utx.rollback();
            } catch (Exception e) {
                ensureAddErrorMessage(e, "An error occurred attempting to roll back the transaction.");
            }
            return null;
        } finally {
            em.close();
        }
        String relatedControllerOutcome = relatedControllerOutcome();
        if (relatedControllerOutcome != null) {
            return relatedControllerOutcome;
        }
        return listSetup();
    }

    private PropertyClass getPropertyClassFromRequest() {
        String theId = getRequestParameter("jsfcrud.currentPropertyClass");
        return (PropertyClass) new PropertyClassConverter().getAsObject(FacesContext.getCurrentInstance(), null, theId);
    }

    private String getRequestParameter(String key) {
        return FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(key);
    }

    public List<PropertyClass> getPropertyClasss() {
        if (propertyClasss == null) {
            propertyClasss = getPropertyClasss(false);
        }
        return propertyClasss;
    }

    public List<PropertyClass> getPropertyClasss(boolean all) {
        EntityManager em = getEntityManager();
        try {
            Query q = em.createQuery("select object(o) from PropertyClass as o");
            if (!all) {
                q.setMaxResults(batchSize);
                q.setFirstResult(getFirstItem());
            }
            return q.getResultList();
        } finally {
            em.close();
        }
    }

    private void ensureAddErrorMessage(Exception ex, String defaultMsg) {
        String msg = ex.getLocalizedMessage();
        if (msg != null && msg.length() > 0) {
            addErrorMessage(msg);
        } else {
            addErrorMessage(defaultMsg);
        }
    }

    public static void addErrorMessage(String msg) {
        FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
        FacesContext.getCurrentInstance().addMessage(null, facesMsg);
    }

    public static void addSuccessMessage(String msg) {
        FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
        FacesContext.getCurrentInstance().addMessage("successInfo", facesMsg);
    }

    public PropertyClass findPropertyClass(Integer id) {
        EntityManager em = getEntityManager();
        try {
            PropertyClass o = (PropertyClass) em.find(PropertyClass.class, id);
            return o;
        } finally {
            em.close();
        }
    }

    public int getItemCount() {
        if (itemCount == -1) {
            EntityManager em = getEntityManager();
            try {
                itemCount = ((Long) em.createQuery("select count(o) from PropertyClass as o").getSingleResult()).intValue();
            } finally {
                em.close();
            }
        }
        return itemCount;
    }

    public int getFirstItem() {
        getItemCount();
        if (firstItem >= itemCount) {
            if (itemCount == 0) {
                firstItem = 0;
            } else {
                int zeroBasedItemCount = itemCount - 1;
                double pageDouble = zeroBasedItemCount / batchSize;
                int page = (int) Math.floor(pageDouble);
                firstItem = page * batchSize;
            }
        }
        return firstItem;
    }

    public int getLastItem() {
        getFirstItem();
        return firstItem + batchSize > itemCount ? itemCount : firstItem + batchSize;
    }

    public int getBatchSize() {
        return batchSize;
    }

    public String next() {
        reset(false);
        getFirstItem();
        if (firstItem + batchSize < itemCount) {
            firstItem += batchSize;
        }
        return "propertyClass_list";
    }

    public String prev() {
        reset(false);
        getFirstItem();
        firstItem -= batchSize;
        if (firstItem < 0) {
            firstItem = 0;
        }
        return "propertyClass_list";
    }

    private String relatedControllerOutcome() {
        String relatedControllerString = getRequestParameter("jsfcrud.relatedController");
        String relatedControllerTypeString = getRequestParameter("jsfcrud.relatedControllerType");
        if (relatedControllerString != null && relatedControllerTypeString != null) {
            FacesContext context = FacesContext.getCurrentInstance();
            Object relatedController = context.getApplication().getELResolver().getValue(context.getELContext(), null, relatedControllerString);
            try {
                Class<?> relatedControllerType = Class.forName(relatedControllerTypeString);
                Method detailSetupMethod = relatedControllerType.getMethod("detailSetup");
                return (String) detailSetupMethod.invoke(relatedController);
            } catch (ClassNotFoundException e) {
                throw new FacesException(e);
            } catch (NoSuchMethodException e) {
                throw new FacesException(e);
            } catch (IllegalAccessException e) {
                throw new FacesException(e);
            } catch (InvocationTargetException e) {
                throw new FacesException(e);
            }
        }
        return null;
    }

    private void reset(boolean resetFirstItem) {
        propertyClass = null;
        propertyClasss = null;
        itemCount = -1;
        if (resetFirstItem) {
            firstItem = 0;
        }
    }
    private Map<Object, String> asString = null;

    public Map<Object, String> getAsString() {
        if (asString == null) {
            asString = new HashMap<Object, String>() {

                @Override
                public String get(Object key) {
                    if (key instanceof Object[]) {
                        Object[] keyAsArray = (Object[]) key;
                        if (keyAsArray.length == 0) {
                            return "(No Items)";
                        }
                        StringBuffer sb = new StringBuffer();
                        for (int i = 0; i < keyAsArray.length; i++) {
                            if (i > 0) {
                                sb.append("<br />");
                            }
                            sb.append(keyAsArray[i]);
                        }
                        return sb.toString();
                    }
                    return new PropertyClassConverter().getAsString(FacesContext.getCurrentInstance(), null, (PropertyClass) key);
                }
            };
        }
        return asString;
    }

    public void validateCreate(FacesContext facesContext, UIComponent component, Object value) {
        PropertyClassConverter converter = new PropertyClassConverter();
        String newPropertyClassString = converter.getAsString(FacesContext.getCurrentInstance(), null, new PropertyClass());
        String propertyClassString = converter.getAsString(FacesContext.getCurrentInstance(), null, propertyClass);
        if (!newPropertyClassString.equals(propertyClassString)) {
            createSetup();
        }
    }

}

PropertyClassConverter.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

/**
 *
 * @author kohuke
 */
public class PropertyClassConverter implements Converter {

    public Object getAsObject(FacesContext facesContext, UIComponent component, String string) {
        if (string == null || string.length() == 0) {
            return null;
        }
        Integer id = new Integer(string);
        PropertyClassController controller = (PropertyClassController) facesContext.getApplication().getELResolver().getValue(facesContext.getELContext(), null, "propertyClass");

        return controller.findPropertyClass(id);
    }

    public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
        if (object == null) {
            return null;
        }
        if (object instanceof PropertyClass) {
            PropertyClass o = (PropertyClass) object;
            return o.getPropertyClass() == null ? "" : o.getPropertyClass().toString();
        } else {
            throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: entities.PropertyClass");
        }
    }

}

PropertyController.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import javax.persistence.Query;
import javax.faces.application.FacesMessage;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.faces.FacesException;
import java.util.HashMap;
import javax.faces.validator.ValidatorException;
import javax.transaction.UserTransaction;

/**
 *
 * @author kohuke
 */
public class PropertyController {
    private Property property = null;
    private List<Property> propertys = null;
    @Resource
    private UserTransaction utx = null;
    @PersistenceUnit(unitName = "Varad2PU")
    private EntityManagerFactory emf = null;

    public EntityManager getEntityManager() {
        return emf.createEntityManager();
    }
    public int batchSize = 5;
    private