使用jsf1.2 + jboss seam更新数据

时间:2013-07-31 07:17:03

标签: hibernate jsf-1.2

我正在使用JSF1.2 + seam2.2.2.Final + hibernate + JPA为我的maven项目。

除了表中列表的更新操作外,一切顺利。点击img进行编辑时,会显示

请求处理期间出现异常:

Caused by javax.el.ELException with message: "javax.ejb.EJBTransactionRolledbackException: No entity found for query"
org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:339)
org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:280)
org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
org.jboss.seam.core.Expressions$2.invoke(Expressions.java:221)
org.jboss.seam.navigation.Pages.callAction(Pages.java:708)
org.jboss.seam.navigation.Pages.preRender(Pages.java:331)
org.jboss.seam.jsf.SeamPhaseListener.preRenderPage(SeamPhaseListener.java:560)
org.jboss.seam.jsf.SeamPhaseListener.beforeRenderResponse(SeamPhaseListener.java:471)
org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:147)
org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:117)
com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:214)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:96)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
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:230)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
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:446)
java.lang.Thread.run(Thread.java:619)

My UI page showing userList is,

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"                 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.prime.com.tr/ui">
        <ui:composition>

    <div id="data_table_container" class="panel-data-content"><h:form
    class="input-list">
    <!-- {RowsPerPageDropdown}-->
    <p:dataTable id="dataTable" color="red"
        value='#{userListAction.usersList}' var='user' dynamic="false"
        width="99.9%" loadingMessage="List of users being loaded">
        <p:column>
            <f:facet name="header">
                <h:outputText value="First Name" />
            </f:facet>
            <h:outputText value="#{user.firstName}" />
        </p:column>
        <p:column>
            <f:facet name="header">
                <h:outputText value="Last Name" />
            </f:facet>
            <h:outputText value="#{user.lastName}" />
        </p:column>
        <p:column>
            <f:facet name="header">
                <h:outputText value="Email Id" />
            </f:facet>
            <h:outputText value="#{user.emailAddress}" />
        </p:column>
        <p:column>
            <f:facet name="header">
                <h:outputText value="Home Phone" />
            </f:facet>
            <h:outputText value="#{user.homeNumber}" />
        </p:column>
        <p:column>
            <f:facet name="header">
                <h:outputText value="Cell Phone" />
            </f:facet>
            <h:outputText value="#{user.cellNumber}" />
        </p:column>
        <p:column styleClass="user-table-action">
            <f:facet name="header">
                <h:outputText value="Action" />
            </f:facet>

                <s:link id="editUser"
                    action="#        {userListAction.getUserById(user.getUserId)}"
                    view="/secure/admin/update.xhtml">
                    <img id="edit-user-img" src="#        {imagesPath}/edit-icon.png"
                        alt="Edit user" title="Edit User" />
                </s:link>   

                    &nbsp;

                    <a class="delete-user {userId: #{user.userId}}" href="#"> <img
                id="delete-user-img" src="#{imagesPath}/delete-icon.png"
                alt="Add User" title="Delete User" /> </a>  

                    &nbsp;

                    <a class="add-user"
                href="#{contextPath}/secure/admin/#        {user.customer?'createCustomer.clrp':'createEmployee.clrp'}">
            <img id="add-user-img" src="#{imagesPath}/add-icon.png"
                alt="Add #{user.customer?'Customer':'Employee'}"
                title="Add #{user.customer?'Customer':'Employee'}" />         </a>
                    &nbsp;
                </p:column>

    </p:dataTable>
        </h:form> <h:messages globalOnly="true" /></div>
    </ui:composition>
    </html>

用户列表中使用的js文件


    $(function() {
    $("#data_table_container").delegate('.delete-user', 'click',
        function(event) {
            var userId = $(this).metadata().userId;
            $('#deleteUserId').val(userId);
            $('#delete-error-msg').html('');
            $('#delete-user').jqmShow();
            event.preventDefault();
        });

    deleteUser = function(buttonElement) {
    var userId = $('#deleteUserId').val();
    var href = window.location.pathname;
    Seam.Component.getInstance("userListAction").deleteById(userId,
            function(message) {
                if (message == 'success') {
                    // Close and reload the
                    $('#delete-error-msg').html('');

                    // Close the modal
                    $('#delete-user').jqmHide();
                    window.location = href;
                    $('#deleteUserId').val('');
                } else {
                    // Show the error message in the modal
                    $('#delete-error-msg').html(message);
                }

            });
    event.preventDefault();
        };

        deleteUserCancel = function(buttonElement) {
    $('#delete-user').jqmHide();
    $('#deleteUserId').val('');
        };

    });

pages.xml是


<page view-id="/secure/admin/update.xhtml" action="#{homePage.getUpdate()}">
    <param name="conversationId" value="none" />
</page>

界面


    @Local
    public interface HomePage extends Serializable {
        public static final String LOGON_PAGE = "/login.xhtml";
        public static final String USER_HOME_PAGE = "/secure/user/home.xhtml";
        public static final String CUSTOMER_HOME_PAGE = "/secure/customer/home.xhtml";
        public static final String HOME_PAGE = "/secure/userhome.xhtml";
        public static final String HOME = "/woodlux/homePage.xhtml";
        public static final String UPDATE = "/secure/admin/user/updateUser.xhtml";

        public String getHomePage();
        public String getHome();
        public String getUpdate();
    }

updateUser文件是:


    <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:p="http://primefaces.prime.com.tr/ui"
    xmlns:clrp="http://panorosys.com/products/clrp/taglib"
    template="/WEB-INF/templates/clrp-template.xhtml">

    <ui:param name="currentArea" value="Customer List" />
    <ui:define name="head">
        <script src="#{scriptsPath}/clrpmenu/jquery.js" type="text/javascript" />
    </ui:define>

    <ui:define name="main-container">
    <div class="data-panel">
    <br></br>
    <br></br>

    <h:outputText rendered="#{currentUser.customer}">
        <h1 class="panel-header">Update Customer</h1>
    </h:outputText> <h:outputText rendered="#{!currentUser.customer}">
        <h1 class="panel-header">Update Employee</h1>
    </h:outputText><ui:include src="userupdate.xhtml" /></div>
    <script>
    Seam.Remoting.getContext().setConversationId("#{conversation.id}");
    </script>
    </ui:define>
    </ui:composition>`

请帮助任何人......

1 个答案:

答案 0 :(得分:0)

问题在于:

 action="#        {userListAction.getUserById(user.getUserId)}"

您应该省略方法名称的get部分。而是尝试user.userId