[JBoss Seam] - Re: Stateless Injection
by ovidiucn
Thank you for being so quick.
/***********************************/
/* local interface */
@Local
public interface UserManagementLocal {
public Collection getUsers ();
}
/***********************************/
/* business logic */
@Name("userManagement")
@Stateless
public class UserManagement implements UserManagementLocal {
/* The login context created when a user previously logged-in. */
@In(value="loginContext", create=false, required=true)
private LoginContext loginContext;
@In (value="user", create=true, required=true)
private User user;
@In
Context sessionContext;
public Collection getUsers() {
Collection users = new ArrayList ();
/* user bean is null !!! */
/* sessionContext is null !!! */
/* the loginContext is null !!! */
System.out.println("user: " + user);
System.out.println("sessionContext: " + sessionContext);
System.out.println("loginContext: " + loginContext);
try {
SecurityDataService sds = SecurityDataServiceFactory.getService(loginContext.getSubject());
Set attributeNames = new HashSet();
users.addAll(sds.getAllUsers(attributeNames));
} catch (SSDataManagementException e) {
e.printStackTrace();
users.clear();
}
return users;
}
}
/***********************************/
/* JBoss Seam configuration(s) */
<!-- web.xml snippet -->
<listener-class>
org.jboss.seam.servlet.SeamListener
</listener-class>
<!-- faces-config.xml snippet -->
<!-- using myfaces-1.1.3 -->
<phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>
<!-- WEB-INF/components.xml -->
true
<!-- using myfaces-1.1.3 -->
false
emp/#{ejbName}/local
<!-- WEB-INF/classes/seam.properties exists & is empty -->
<!-- service-security.jar#!seam.properties exists & is empty -->
Environment:
JRE 1.5.0_06
JBOSS Release ID: JBoss [Zion] 4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000) - installed with JEMS & ejb3 configuration enabled
JBoss Seam 1.0.1.GA
MyFaces 1.1.3
Thanks!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960603#3960603
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960603
19 years, 9 months
[EJB 3.0] - Simple injection of SessionContext not working
by jaikiran
I have just started with EJB3. Certainly, i am doing something wrong, because a simple injection is not working for me. I have StatelessSessionBean in which i am trying to inject the SessionContext. When i am trying to deploy the bean, server throws exceptions indicating a NullPointerException and subsequently the application is not deployed.
Here's the code:
| package org.myapp.ejb;
|
| import java.util.Random;
|
| import javax.annotation.Resource;
| import javax.annotation.security.PermitAll;
| import javax.annotation.security.RolesAllowed;
| import javax.ejb.SessionContext;
| import javax.ejb.Stateless;
| import javax.jms.Queue;
|
| import org.jboss.annotation.security.SecurityDomain;
|
| @Stateless
| @SecurityDomain("other")
| public class TestEJB3 implements TestEJB3Interface {
|
| @Resource
| SessionContext sessionContext;
|
| @PermitAll
| public void print() {
| System.out.println("Print Default: Hi");
| }
|
| @RolesAllowed({"Admin"})
| public String getDisplayValue() {
| return "Hi, user: " + new Random().nextInt();
| }
|
| @RolesAllowed({"AnyUser"})
| public void print(String text) {
| System.out.println("Print: " + text);
| }
|
|
|
| }
Here's the exception stacktrace when the application is being deployed:
anonymous wrote : 12:52:11,816 INFO [EARDeployer] Init J2EE application: file:/D:/JBoss4.0.4GCA/jboss-4.0.4.GA/server/default/deploy/MyEJB3.ear/
| 12:52:12,160 INFO [Ejb3Deployment] EJB3 deployment time took: 188
| 12:52:12,270 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=MyEJB3.ear,jar=myapp_ejb.jar,name=TestEJB3,service=EJB3 with dependencies:
| 12:52:12,691 WARN [ServiceController] Problem starting service jboss.j2ee:ear=MyEJB3.ear,jar=myapp_ejb.jar,name=TestEJB3,service=EJB3
| java.lang.NullPointerException
| at org.jboss.ejb3.injection.ResourceHandler.loadFieldInjectors(ResourceHandler.java:283) at org.jboss.ejb3.injection.ResourceHandler.loadInjectors(ResourceHandler.java:401)
| at org.jboss.ejb3.injection.ResourceHandler.loadInjectors(ResourceHandler.java:381)
| at org.jboss.ejb3.EJBContainer.resolveInjectors(EJBContainer.java:640)
| at org.jboss.ejb3.EJBContainer.initializePool(EJBContainer.java:576)
| at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:507)
| at org.jboss.ejb3.SessionContainer.start(SessionContainer.java:82)
| at org.jboss.ejb3.stateless.StatelessContainer.start(StatelessContainer.java:80)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:99)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
| at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
| at $Proxy0.start(Unknown Source)
| at org.jboss.system.ServiceController.start(ServiceController.java:417)
| at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy56.start(Unknown Source)
| at org.jboss.ejb3.JmxKernelAbstraction.install(JmxKernelAbstraction.java:82)
| at org.jboss.ejb3.Ejb3Deployment.registerEJBContainer(Ejb3Deployment.java:439)
| at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:486)
| at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:139)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
| at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
| at $Proxy0.start(Unknown Source)
| at org.jboss.system.ServiceController.start(ServiceController.java:417)
| at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy29.start(Unknown Source)
| at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:449)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy30.start(Unknown Source)
| at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007)
| at org.jboss.deployment.MainDeployer.start(MainDeployer.java:997)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
| at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy8.deploy(Unknown Source)
| at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
| at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
| at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
| at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
| at $Proxy0.start(Unknown Source)
| at org.jboss.system.ServiceController.start(ServiceController.java:417)
| at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy4.start(Unknown Source)
| at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
| at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
| at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:755)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
| at $Proxy5.deploy(Unknown Source)
| at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
| at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
| at org.jboss.Main.boot(Main.java:200)
| at org.jboss.Main$1.run(Main.java:464)
| at java.lang.Thread.run(Thread.java:595)
| 12:52:13,457 INFO [EJB3Deployer] Deployed: file:/D:/JBoss4.0.4GCA/jboss-4.0.4.GA/server/default/deploy/MyEJB3.ear/myapp_ejb.jar/
| 12:52:13,473 INFO [TomcatDeployer] deploy, ctxPath=/myapp, warUrl=.../deploy/MyEJB3.ear/myapp_web.war/
| 12:52:13,770 INFO [EARDeployer] Started J2EE application: file:/D:/JBoss4.0.4GCA/jboss-4.0.4.GA/server/default/deploy/MyEJB3.ear/
| 12:52:13,785 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
|
| --- MBeans waiting for other MBeans ---
| ObjectName: jboss.j2ee:ear=MyEJB3.ear,jar=myapp_ejb.jar,name=TestEJB3,service=EJB3
| State: FAILED
| Reason: java.lang.NullPointerException
|
| --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
| ObjectName: jboss.j2ee:ear=MyEJB3.ear,jar=myapp_ejb.jar,name=TestEJB3,service=EJB3
| State: FAILED
| Reason: java.lang.NullPointerException
I am using JBoss - 4.0.4 GCA. I followed the following steps after installing the server:
1) I downloaded jboss-EJB-3.0_RC8-FD
2) Copied ejb3-persistence.jar in server/default/lib
3) Copied ejb3-interceptors-aop.xml in server/default/deploy
4) ejb3.deployer in server/default/deploy
Is there something else, i need to do to get injection working? Note that with the injection part commented out, everything works fine, the EJB gets deployed and i am able to invoke methods on the EJB.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960601#3960601
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960601
19 years, 9 months
[JBoss Seam] - Re: Hibernate Validation / Page Scope --> allways new entity
by mrwhite
Ok bfo81 lets see:
My Entity Class:
package org.jboss.seam.example.client;
|
| import javax.persistence.Entity;
|
| import org.hibernate.validator.Length;
| import org.hibernate.validator.NotNull;
|
| @Entity
| public class ClientPerson extends Client {
|
| private static final long serialVersionUID = 7829975195914473729L;
| private String firstname;
| private String lastname;
|
| @NotNull
| @Length(min=2, max=5)
| public String getFirstname() {
| return firstname;
| }
|
| public void setFirstname(String firstname) {
| this.firstname = firstname;
| }
|
| @NotNull
| public String getLastname() {
| return lastname;
| }
|
| public void setLastname(String lastname) {
| this.lastname = lastname;
| }
|
|
|
|
|
| }
|
My Edit Action:
package org.jboss.seam.example.client;
|
| import javax.ejb.Remove;
| import javax.ejb.Stateful;
| import javax.ejb.Stateless;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| import org.hibernate.validator.Valid;
| import org.jboss.seam.ScopeType;
| import org.jboss.seam.annotations.Begin;
| import org.jboss.seam.annotations.Destroy;
| import org.jboss.seam.annotations.End;
| import org.jboss.seam.annotations.Factory;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Out;
| import org.jboss.seam.annotations.RequestParameter;
| import org.jboss.seam.annotations.Scope;
|
| @Stateful
| @Name("clientPersonAction")
| public class ClientPersonEditAction implements ClientPersonEdit{
|
| @PersistenceContext
| private EntityManager em;
|
| @RequestParameter()
| private Long clientPersonId;
|
| @In(required=false)
| @Out(scope=ScopeType.PAGE,required=false)
| private ClientPerson newClientPerson;
|
| @Begin(join=true)
| @Factory("newClientPerson")
| public void createNewClientPerson()
| {
| if(clientPersonId != null)
| {
| ClientPersonDAO clientPersonDAO = new ClientPersonDAO(em);
| newClientPerson = clientPersonDAO.getClientPersonById(clientPersonId);
| System.out.println("createNewClientPerson:" + newClientPerson.getId());
| }
| else
| {
| newClientPerson = new ClientPerson();
| }
| }
|
| @End
| public String saveClientPerson() {
| ClientPersonDAO clientPersonDAO = new ClientPersonDAO(em);
| System.out.println("newClientPerson.getId():" + newClientPerson.getId());
| clientPersonDAO.merge(newClientPerson);
| return "home";
| }
|
| @Destroy @Remove
| public void detroy()
| {
| }
|
| @End
| public String removeClientPerson() {
| ClientPersonDAO clientPersonDAO = new ClientPersonDAO(em);
| clientPersonDAO.remove(newClientPerson);
| return "home";
| }
|
| }
|
My DAO Class for the Entity:
package org.jboss.seam.example.client;
|
| import java.util.List;
|
| import javax.persistence.EntityManager;
| import javax.persistence.Query;
|
| public class ClientPersonDAO {
|
| private EntityManager entityManager;
|
| public ClientPersonDAO()
| {
|
| }
|
| public ClientPersonDAO(EntityManager entityManager)
| {
| this.entityManager = entityManager;
| }
|
| public EntityManager getEntityManager() {
| return entityManager;
| }
|
| public void setEntityManager(EntityManager entityManager) {
| this.entityManager = entityManager;
| }
|
| public void persist(Object obj)
| {
| getEntityManager().persist(obj);
| }
|
| public void merge(Object obj)
| {
| getEntityManager().merge(obj);
| }
|
| public List<ClientPerson> getAllClientPerson() {
| return getEntityManager().createQuery("select c from ClientPerson c").getResultList();
| }
|
| public ClientPerson getClientPersonById(long id) {
| Query q = getEntityManager().createQuery("select c from ClientPerson c where c.id = :id");
| q.setParameter("id", id);
| return (ClientPerson) q.getSingleResult();
| }
|
| public void remove(ClientPerson clientPerson) {
| getEntityManager().remove(clientPerson);
| }
|
| }
My Facelet page:
<!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:s="http://jboss.com/products/seam/taglib"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:f="http://java.sun.com/jsf"
| xmlns:h="http://java.sun.com/jsf/html">
| <body>
| <ui:composition template="/WEB-INF/layout/template.xhtml">
|
| <ui:define name="header">
| <ui:include src="/WEB-INF/layout/header.xhtml" />
| </ui:define>
|
| <ui:define name="body">
| <h1>Kundenverwaltung</h1>
| <h:form>
| <s:validateAll>
| <div>
| <h:outputLabel for="firstname">Vorname: </h:outputLabel>
| </div>
| <div>
| <h:inputText id="firstname" value="#{newClientPerson.firstname}" size="70" maxlength="70" required="true"/>
| <span class="errors"><h:message for="firstname"/></span>
| </div>
| <div>
| <h:outputLabel for="lastname">Nachname: </h:outputLabel>
| </div>
| <div>
| <h:inputText id="lastname" value="#{newClientPerson.lastname}" size="70" maxlength="70" required="true"/>
| <span class="errors"><h:message for="lastname"/></span>
| </div>
| <span>
| <h:commandButton value="Speichern" action="#{clientPersonAction.saveClientPerson}"/>
|
|
| </span>
| </s:validateAll>
| </h:form>
|
| <span>
| <h:form>
| <h:commandButton value="Entfernen" action="#{clientPersonAction.removeClientPerson}"/>
| </h:form>
| </span>
|
| </ui:define>
|
| <ui:define name="footer">
| <ui:include src="/WEB-INF/layout/footer.xhtml" />
| </ui:define>
|
| </ui:composition>
| </body>
| </html>
|
The ClientPerson service that provides the list:
package org.jboss.seam.example.client;
|
| import java.util.List;
|
| import javax.ejb.Stateful;
| import javax.ejb.Stateless;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| import org.hibernate.validator.Valid;
| import org.jboss.seam.ScopeType;
| import org.jboss.seam.annotations.Factory;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Out;
| import org.jboss.seam.annotations.RequestParameter;
|
| @Stateless
| @Name("clientPersonService")
| public class ClientPersonServiceImpl implements ClientPersonService {
|
| @PersistenceContext
| private EntityManager em;
|
| public List <ClientPerson> getAllClientPerson()
| {
| ClientPersonDAO clientPersonDAO = new ClientPersonDAO(em);
| return clientPersonDAO.getAllClientPerson();
| }
| }
|
The List facelet page/component:
| <div xmlns="http://www.w3.org/1999/xhtml"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:h="http://java.sun.com/jsf/html">
|
| <h1>Kundenverwaltung</h1>
| <h:dataTable value="#{clientPersonService.allClientPerson}" var="clientPerson" rows="3">
| <h:column>
| <h:outputLink value="addClientPerson.seam">
| #{clientPerson.firstname} #{clientPerson.lastname} - ID: #{clientPerson.id}
| <f:param name="clientPersonId" value="#{clientPerson.id}"/>
|
| </h:outputLink>
| </h:column>
| </h:dataTable>
|
| </div>
And thanks bfo81 for your time. ;-)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960600#3960600
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960600
19 years, 9 months
[JBoss Seam] - Re: ACL in Seam
by js8523
Hi Gavin,
I think that you missed yaun point, which is object level permission, like one user can edit one customer, but only view another customer.
I was thinking a Entity Users_Role which you could then inherit (therefore extend the data model), and add custom properties (i.e. customer foreign key, or any other type of datamodel object). You could do the equiverlent of this to the Role Entity allowing people to custom design the priveledges a Role can have.
You could then add a equiverlent to isUserInRole called hasPriveledge that checks the current principal has the priveledge.
In answer to the original question, people have tried to use acegi with Seam with some success, please search this forum for previous posts.
If you come up with any firm information you could post it on the Wiki.
HTH,
James
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960598#3960598
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960598
19 years, 9 months