Bean to Bean Communication
Hello i'm really new in J2EE. I know basics java & JSP. Currently i am using JSF.
I have a employee table(name, department_name, sal, highest_qualification).
I have created a JSF Bean file named EmployeeBean.java which contains all getter and setter methods.
Similarly i also have User table(uname,pass) and UserBean.java.Relation between Employee and User table is 1:1.
Here both beans are in session scope. So after login i can access & print those data(e.g department) in any text field( in any other jsp page) any time.
Now for example i have another Bean file Bean123.java and i want my this bean file will do something with current user's name & location(i.e. i want one Bean file will handle data from another bean file).
Is it possible ?? How can i handle session in JSF to store user's details ?
Thanks
dev_123
Plz. try to give me a exact way to do that.
You can solve this in several ways. Injecting the one bean as property of the other bean. Accessing it by the sessionMap, add a static method to let it return current instance of self, etcetera.
You may find this article useful: http://balusc.blogspot.com/2006/06/communication-in-jsf.html
Similar Messages
-
JNDI lookup help please-Bean to Bean callout locally in same oc4j container
Hi - I'm fairly new to oc4j/ejb coding - I'm trying to get a simple application running to show that our code can be run in local mode - here is the scenario:
- Bean A (our application bean) within Application A
- Bean B (customer-developed bean) within Application B
- Bean B calls Bean A
- Bean A + Bean B are different application instances in the same oc4j container
- Jsp (residing in ApplicationB) within the same oc4j container calling Bean B, which invokes Bean A
====
I get the following exception (classes renamed to match scenario):
javax.naming.NameNotFoundException: oracle.apps.applicationa.common.BeanA not found in anothercompany.applicationb.common.BeanB
[java] at com.oracle.naming.J2EEContext.getSubContext(J2EEContext.java:93)
[java] at com.oracle.naming.J2EEContext.lookup(J2EEContext.java:76)
[java] at com.evermind.server.ApplicationContext.lookupJavaCompEnv(ApplicationContext.java:265)
[java] at com.evermind.server.ApplicationContext.lookupJavaComp(ApplicationContext.java:132)
[java] at com.evermind.server.ApplicationContext.lookup(ApplicationContext.java:306)
[java] at com.evermind.server.ApplicationContext.lookup(ApplicationContext.java:120)
[java] at javax.naming.InitialContext.lookup(InitialContext.java:347)
- BeanA is part of application named "AppA" in server.xml
- BeanB is part of application named "AppB" in server.xml
- AppB has attribute 'parent="AppA"' in server.xml
- If I change the Jsp file (residing in AppB) to call BeanA directly in the jsp code it works with no JNDI error, but changing the jsp code back to calling BeanB (which then calls BeanA) will throw the NameNotFoundException
My Stateless Session Bean is very simple and I have tried not setting the context and setting the context. I'm thinking this is a very simple configuration issue, but have not been able to find the solution yet... I've tried playing with the setSessionContext method in the session bean but have had no luck and am not sure what to set the variables to or even if I'm in the correct method...
public void setSessionContext(SessionContext ctx) {
if (verbose)
System.out.println("setSessionContext called");
Properties env = new Properties();
// tried all three context factories...
//env.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.ApplicationInitalContextFactory");
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.ApplicationClientInitialContextFactory");
//env.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory");
// not sure what url to put, if any
//env.put(Context.PROVIDER_URL, "ormi://localhost:23791/AppB");
env.put(Context.PROVIDER_URL, "ormi://localhost/AppB");
// tried with and without security principals... also tried sysadmin/sysadmin
env.put(Context.SECURITY_PRINCIPAL, "guest");
env.put(Context.SECURITY_CREDENTIALS, "welcome");
// mProps is a local transient member var of type Properties
mProps = env;
// mCtx is a local transient member var of type SessionContext
mCtx = ctx;
(edit) additional info:
- all beans/classes are in the same classes directory; there are no jar files, so in application.xml the specified classpath is "classes" which includes both appA and appB classes
- I verified that if I point (appB) jsp directly to BeanA it works with the "parent" attribute set on appB in server.xml, and when I remove the "parent" attribute on appB in server.xml the jsp throws a NameNotFoundException
edit #2:
another interesting note is that the exception message says "oracle.apps.applicationa.common.BeanA not found in anothercompany.applicationb.common.BeanB"
and usually the naming error I see is:
"oracle.apps.applicationa.common.BeanA not found in appB"
(as with the case when I use a jsp to access appA beans without setting the parent application of appB to appA)
- also my j2ee/home/applications/appB/WEB-INF/web.xml includes the oracle.apps.applicationa.common.BeanA ejb-ref tag
any help is appreciated - thanks!
Message was edited by:
oleonHi Steve
thanks for the reply - I currently have the parent attribute set in server.xml which is why the jsp connection works, but for some strange reason the bean cannot connect to other bean...
my server.xml has something like...
<application name="appA" location="appA" auto-start="true"/>
<application name="appB" location="appB" parent="appA" auto-start="true"/>
(ok, the tags might be off because I'm not in front of my workstation looking at the xml file...)
on another interesting note, in the session bean for AppB I've tried searching for the ejb bean for app B (itself basically) with the default initial context and it cannot find its own bean within the same application... the message would be something like "NameNotFoundException: anothercompany.applicationb.common.BeanB not found in anothercompany.applicationb.common.BeanB" -
JSF - Managed Beans instantiate Beans?
Hi, I�m new in JSF. I�d like to know if there is any way to configure in faces-config.xml a way to make a bean to be instantiate within do it explicity in the managed bean class.
Let me explain better, I have a form with two fields, login and password. I have a Bean called "User", with this two attributes and others. When I click on the commandButton, a method in the managed ben is called. What a wanna know is: do I have to declare the same bean�s attributes in the managed bean, generating gets and setters methods or there is a way to do this in the faces-config.xml?
Thanks.I guess what you want to do is something like as follows:
(jsp file)<h:inputText value="#{managedBean.user.login}"/>(faces-config.xml) <managed-bean>
<managed-bean-name>managedBean</managed-bean-name>
<managed-bean-class>ManagedBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>user</property-name>
<value>#{userBean}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>userBean</managed-bean-name>
<managed-bean-class>User</managed-bean-class>
<managed-bean-scope>none</managed-bean-scope>
</managed-bean> -
JDev doesn't recognise my EJB3 beans as beans
It thinks they're PoJos. The beans are developed from its own CMP Bean producing wizard. I've about 15 other beans in this package generated in the same way and it recognises those as EJB Persistent Entity beans...
The problem is that now when I try to generate Facade beans to actually use these entities, the Facade bean wizard won't show me these 2 new beans in its list. So I can't create Facades. I don't feel like manually writing all that code to do 'findByAll' calls and such like.
Does anyone know why JDev has suddenly stopped seeing these 2 classes as beans? They've got the same annotations and imports, and implements as all the others.
(Also, I'd like to raise a feature request. What's the point of JDev showing ALL the entity beans in my project AND having them all ticked when creating a new Session Facade bean? I only want to use the one that has the same spelling as the facade I'm creating!! Please default this wizard to only check the Core Facade methods and let me tick the one other bean that I actually want methods created for)
SteveHi mirzaair,
Try testing your audio in the HP Diagnostics: http://h10025.www1.hp.com/ewfrf/wc/document?lc=en&dlc=en&cc=us&docname=c00849402
Let us know what you find out.
...an HP employee just trying to help where I can, but not speaking on behalf of HP. -
Load balancing and bean-to-bean method calls
Hello!
Let's assume the following scenario: a clustered environment, and a
stateless session bean A accessible by clients. The session bean A then
makes further calls to other session/entity bean B. Does WebLogic 5.10 do
load balancing in here? Can we assume that B is always running in the same
cluster member as A? If not, I assume, that there is quite a bit of
performance penalty for making the RMI call from B to A?
Cheers,
petteri
Petteri Laamanen wrote:
> Hello!
>
> Let's assume the following scenario: a clustered environment, and a
> stateless session bean A accessible by clients. The session bean A then
> makes further calls to other session/entity bean B. Does WebLogic 5.10 do
> load balancing in here? Can we assume that B is always running in the same
> cluster member as A?
You mean same server. Yes.
> If not, I assume, that there is quite a bit of
> performance penalty for making the RMI call from B to A?
>
> Cheers,
>
> petteri
-
JNDI Lookup for EJB3 (Bean to Bean)
Hi Forum,
i've search the whole internet and two books but I could not find an answer that pleased me.
I want to get a reference to an EJB3 by JNDI Lookup. With container managed dependency injection everything works fine but I have to do a little more generic way, thats why I want to work with JNDI Lookup.
I have the following situation:
At first I have a stateless bean
@Local
public interface Job {
* run the job
* @return true if the job executed without errors
public boolean run(SchedulerConfig schedulerConfig ,JobContext context);
@Local
public interface AConcreteJobLocal extends Job {
//no more declarations
@Stateless
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class AConcreteJobBean implements AConcreteJobLocal {
//implemented methods goes here | removed for better overview in the post
} This is a typical declaration for a bunch of jobs I have. Every concrete job has it's own bean if it necessary in some way for you to know.
So now I wanted to write a bean which returns me an bean instance via a JNDI lookup
@Stateless
public class JobJNDILookupBean implements JobJNDILookupLocal {
Logger logger = Logger.getLogger(JobJNDILookupBean.class.getName());
public Job getJobBeanFromJNDIName(String jndiName) {
Job job = null;
try {
Context c = new InitialContext();
job = (Job) c.lookup("jndiName");
} catch (NamingException ex) {
Logger.getLogger(JobJNDILookupBean.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
logger.log(Level.SEVERE, "Bean not found", ex);
return job;
}When I call this method I always get a NameNotFoundException
javax.naming.NameNotFoundException: JNDI_NAME_GOES_HERE not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:216)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:188)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:74)
at com.sun.enterprise.naming.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:111)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:398)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.vw.ais.dcl.timer.engine.JobJNDILookup.getJobBeanFromJNDIName(JobJNDILookup.java:46)
at com.vw.ais.dcl.timer.engine.EngineBean.init(EngineBean.java:221)
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 com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3986)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:197)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:83)
at $Proxy713.init(Unknown Source)
at com.vw.ais.dcl.timer.SchedulerBean.runEngine(SchedulerBean.java:192)
at com.vw.ais.dcl.timer.SchedulerBean.handleIncomingByTimer(SchedulerBean.java:171)
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 com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1067)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:176)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2895)
at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:2824)
at com.sun.ejb.containers.EJBTimerService.deliverTimeout(EJBTimerService.java:1401)
at com.sun.ejb.containers.EJBTimerService.access$100(EJBTimerService.java:99)
at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.run(EJBTimerService.java:1952)
at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.service(EJBTimerService.java:1948)
at com.sun.ejb.containers.util.WorkAdapter.doWork(WorkAdapter.java:75)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)I've tried I guess all combinations for the JNDI_NAME
java:/comp/env/ejb/AConcreteJob
java:/comp/env/ejb/AConcreteJobLocal
java:/comp/env/ejb/AConcreteJobBean
java:/comp/env/AConcreteJob
java:/comp/env/full.package.and.Class.name
this all without java:/comp/env
etc.
The only way it worked was when I added a annotation to the JobJNDILookupBean in this way
@Stateless
*@EJB(name="ejb/AConcreteJob",beanInterface=A.Interface.location)*
public class JobJNDILookupBean implements JobJNDILookupLocal {
}But this is not what I want to do. Thats why my question. How can I lookup a bean without annotate it in the bean which want to look it up???
In other words whats wrong here
@Stateless
public class JobJNDILookupBean implements JobJNDILookupLocal {
Logger logger = Logger.getLogger(JobJNDILookupBean.class.getName());
public Job getJobBeanFromJNDIName(String someJndiName) {
Job job = null;
try {
Context c = new InitialContext();
job = (Job) c.lookup("someJndiName");
} catch (NamingException ex) {
Logger.getLogger(JobJNDILookupBean.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
logger.log(Level.SEVERE, "Bean not found", ex);
return job;
}I hope you understand my question and more than this I hope some has the answer.Hi Zsom,
Zsom wrote:
One thing you need to keep in mind is that beans aren't instantiated every time you make a call to your EJB. You're right! But because the fact the beans are all stateless it doesn't matter. I don't want to get a new EJB at a lookup. If I get a reference to a bean which was used a million times before it is absolutely ok
Zsom wrote:
You might be gaining some time because the container can create new beans more quickly, but you are also looking up the beans before each call, which in the long run will be even more expensive.Mhm, I don't know if I understand you. Maybe I explain my process a little bit. I have a lot of different jobs in my application (JobDoThis, JobDoThat, JobFoo, JobBar). Every job has a own bean which keeps the business logic. Furthermore I have an job engine which is able to execute jobs which are configured to run and this engine can solve some dependencies (If JobFoo fails don't execute JobBar , and so on). When I build my engine I want to get a reference to a jobBean by jndi lookup which keeps the business logic and then call some method on it. This means that the lookup will only be called when I build a new engine. And because this doesn't happen so often performance is not so important. Furthermore if all jobs all configured to run the application needs sometimes more than 12 hours (depended from the amount of data) for one run (Start to End -> the application has a little script character), that's why performance as I said already is not so important.
Zsom wrote:
But it would be worth making some test, because to me it seems a bit like bad design.Yes it could be, but this was my first thought to instantiate a bean (or get a reference to an existing one) dynamically. I don't like this hard coded dependency injection. I mean it's great If you know at compiletime which beans you need. But because we don't know which beans we need it's a big overhead to inject them all by container and then use only 40 percent of the injected bean because for example only 40 of 100 jobs shall run.
If there is another approach to get a reference dynamically which is better than this then I will try, no problem, but unfortunally I don't see another. -
Jsp:include fails when referencing a struts bean:define bean
When I request the jsp listed at the bottom, I get the following error:
cannot resolve symbol
symbol : variable pageTemplate
The jsp works as is in both Tomcat and Resin.
I know the pageTemplate bean gets defined by struts, because if I remove
(1), I get the correct output of (2).
Does WL precompile the pages differently than Tomcat/Resin?
We know tiles can provide similar functionality, but for various reasons,
this is the method that seems preferred.
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import = "com.stabilia.site.*" %>
<%@ page errorPage="/error.jsp" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<bean:define id="siteConfig" name="siteConfig" scope="session"
type="com.stabilia.site.SiteConfiguration"/>
<bean:define id="pageTemplate" name="siteConfig"
property="currentPageTemplate"
type="com.stabilia.site.PageTemplate" scope="session"/>
(1)<jsp:include page="<%=pageTemplate.getTemplate()%>" />
(2)template:<bean:write name="pageTemplate" property="template"/>
I know that in certain versions of WLS the Tag AT_END variables were not getting
defined properly. Please contact support and ask for a patch referencing this
with your current version.
Sam
Daren Desjardins wrote:
> To be more specific, I found that I cannot use runtime expressions that
> involve a bean defined by Struts. If the bean were declared in the
> following way, it works.
>
> <%
> SiteConfiguration siteconfig = (SiteConfiguration)
> session.getAttribute(SiteConfiguration.SESSION_KEY);
> PageTemplate pagetemplate = siteconfig.getCurrentPageTemplate();
> %>
> <jsp:include page="<%=pagetemplate.getTemplate()%>" flush="true"/>
-
Lookup (Bean 2 Bean)
Hi
Programs: J-Developer902, Oracle9i AS.
The Problem : I have one Workspace with 2 projects (Project1 and Probject1). I have one Bean on each project.
I'm trying to do a lookup from Bean1 (on Project1) to Bean2 (on Project2) but it doesn't work!!!
I deployed the first Bean (on Project1) and gott
ejb1.deploy ejb1.jar and ejb1.ear
I deployed the second Bean (on Project2) and gott
ejb2.deploy ejb2.jar and ejb2.ear
I build up an .EAR file and encluded both (ejb1.jar and ejb2.jar). I have my .EAR outside both projects,
and deployed it on Oracle9i AS too.
How should my lookup look like? (Remember I have 2 beans in 2 DIFFERENT Projects (One on each) but they are both in the same J2EE application (.EAR) OBS!! I have my EAR file outside both projects (on project3) )
Shall I use the "com.evermind.server.rmi.RMIInitialContextFactory" Factory or the "com.evermind.server.ApplicationClientInitialContextFactory" with (application-client.xml)
Here is how my lookup looks right now.
_________________ Client ________________(My client finds the first bean without any problem)
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "admin");
env.put(Context.PROVIDER_URL, "ormi://IS002/ejb1");
Context ctx = new InitialContext(env);
MyFirstEJBHome myFirstEJBHome = (MyFirstEJBHome)ctx.lookup("MyFirstEJB");
MyFirstEJB myFirstEJB;
// Use one of the create() methods below to create a new instance
myFirstEJB = myFirstEJBHome.create( );
As for the lookup from Bean1 to Bean2 I tried 2 ways( with and without PortableRemoteObject.narrow), but I got an error on each way:
___________________ BEAN 1 (Way 1 with PortableRemoteObject.narrow)_____________________
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.ApplicationClientInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "admin");
env.put(Context.PROVIDER_URL, "ormi://IS002/ejb2");
Context ctx = new InitialContext(env);
Object homeObject= ctx.lookup("java:comp/env/MySecondEJBBean");
MySecondEJBHome mySecondEJBHome = (MySecondEJBHome) PortableRemoteObject.narrow(homeObject, MySecondEJBHome.class);
MySecondEJB mySecondEJB;
// Use one of the create() methods below to create a new instance
mySecondEJB = mySecondEJBHome.create( );
______ ERROR ________
java.lang.ClassCastException
at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at javax.rmi.PortableRemoteObject.narrow(Unknown Source)
at mypackage1.MyFirstEJBBean.callSecond(MyFirstEJBBean.java:49)
at MyFirstEJB_StatelessSessionBeanWrapper2.callSecond(MyFirstEJB_StatelessSessionBeanWrapper2.java:79)
at java.lang.reflect.Method.invoke(Native Method)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:118)
at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)
_________________ BEAN 1 (Way 2 without PortableRemoteObject.narrow) ________________
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.ApplicationClientInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "admin");
env.put(Context.PROVIDER_URL, "ormi://IS002/ejb2");
Context ctx = new InitialContext(env);
MySecondEJBHome mySecondEJBHome = (MySecondEJBHome)ctx.lookup("java:comp/env/MySecondEJBBean");
MySecondEJB mySecondEJB;
// Use one of the create() methods below to create a new instance
mySecondEJB = mySecondEJBHome.create( );
_______ ERROR _________
java.lang.ClassCastException: MySecondEJBHome_StatelessSessionHomeWrapper9
at mypackage1.MyFirstEJBBean.callSecond(MyFirstEJBBean.java:48)
at MyFirstEJB_StatelessSessionBeanWrapper2.callSecond(MyFirstEJB_StatelessSessionBeanWrapper2.java:79)
at java.lang.reflect.Method.invoke(Native Method)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:118)
at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)
What am I doing wrong ???? I'll be very grateful and thankful if you can help me. How should my lookup code look like?
/Azam
Integration Strategies & SolutionsYou have to make ejb1.ear as parent of ejb2.ear in the server.xml as follows:
<application name=ejb1 path=a.ear />
<application name=ejb2 path=b.ear parent=ejb1 />
You have to use default Initialcontext (donot populate en. properties) to lookup your EJB as if both are in the same application.
regards
Debu -
Bean as Bean Property???
Hi,
I read in the JAX-RPC Specification, Bean properties must be JAX-RPC types. Does this include that a Bean property can also be another Bean?
Thanx,
MischaYes, a Bean can be a Bean Property.
-
Referencing beans as bean attributes in struts tags
Do struts tags allow you access bean attributes when the bean itself is an attribute of another bean?
If so, what would be the syntax?
For instance, I have bean A that contains as an attribute another bean B. I want to test for the value of
an attribute within B. Let's say I have bean A where A has get/set methods for B and B has get/set methods for an attribute called 'amount'. Then can I say something like:
<logic:equal name="A" property="B.amount" value="1">
I tried this syntax and also "B.getAmount()", but neither seems to work.
I have also tried <logic:equal name="A.B" property="amount" value="1">
but this doesn't work either.I've used that x.y syntax before in some tags, but I don't know if logic tags support it... you should be able to do this:
<bean:define id="B" name="A" property="B" />
<logic:equal name="B" property="amount" value="1"> -
O/R tool generates invalid ejb-jar.xml for 1-n cmp bean-to-bean relations
TopLink generates:
<ejb-relation>
<ejb-relation-name>Parent-Child</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>Parent-has-childs</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>Parent</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>childs</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>child-owned-by-Parent</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<cascade-delete></cascade-delete>
<relationship-role-source>
<ejb-name>Child</ejb-name>
</relationship-role-source>
</ejb-relationship-role>
</ejb-relation>
what's wrong?
it's missing the following tag:
'<cmr-field-type>java.util.Collection</cmr-field-type>'
which should be in the <cmr-field> element after the <cmr-field-name>.
I cannot get the UI tool to add this tag, whenever I manually add it to the ejb-jar.xml it gets removed the next time I generate the ejb-jar.xml. Additionally, if I try to update the project from the ejb-jar.xml, the O/R tool loses ALL my mappings for entity beans.
Expected questions:
TopLink 9.0.3
WebLogic 7.0.1
CMP 2.0
JDK 1.3.1_03
Yes the getter/setter are defined (on the local interface and bean)
FYI,
AndrewThis should take care of it
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>IDMaster</ejb-name>
<home>maxateev.mondial.brg.idmaster.IDMasterHome</home>
<remote>maxateev.mondial.brg.idmaster.IDMaster</remote>
<local-home>maxateev.mondial.brg.idmaster.IDMasterLocalHome</local-home>
<local>maxateev.mondial.brg.idmaster.IDMasterLocal</local>
<ejb-class>maxateev.mondial.brg.idmaster.IDMasterEJB</ejb-class>
<persistence-type>Container</persistence-type>
<ejb-local-ref>
<ejb-ref-name>ejb/IDMasterLocalHome</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>maxateev.mondial.brg.idmaster.IDMasterLocalHome</local-home>
<local>maxateev.mondial.brg.idmaster.IDMasterLocal</local>
</ejb-local-ref>
<prim-key-class>java.lang.String</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>IDMaster</abstract-schema-name>
<cmp-field>
<field-name>idPrefix</field-name>
</cmp-field>
<cmp-field>
<field-name>idValue</field-name>
</cmp-field>
<primkey-field>idPrefix</primkey-field>
<ejb-local-ref>
<ejb-ref-name>ejb/IDMasterLocalHome</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>maxateev.mondial.brg.idmaster.IDMasterLocalHome</local-home>
<local>maxateev.mondial.brg.idmaster.IDMasterLocal</local>
</ejb-local-ref>
<query>
<query-method>
<method-name>findAllIDMasters</method-name>
<method-params/>
</query-method>
<ejb-ql><![CDATA[SELECT OBJECT (f) FROM IDMaster as f]]></ejb-ql>
</query>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>IDMaster</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar> -
Object instance from bean to bean
Hi.
I have backing bean with next structure:
import mypackage.ClassA;
public class BeanName1{
private ClassA instanceClassA;
public ClassA getInstanceClassA();
public void setInstanceClassA(ClassA a);
public class BeanName2{
How can I get instance fro object instanceClassA in other bean class BeanName2?
Thx.Sinnerman,
Exactly what are you trying to do? What are the scopes of your two beans? Depending upon what you are trying to do, there are different answers as to the best way...
For example, if you're trying to pass parameters from one page to another, you could look at using af:setActionListener.
Another method would be to inject the value into the second bean as a managed property (assuming the bean scopes would support it).
In short - more information is needed about what exactly you are trying to do in order to suggest the best approach.
Regards,
John -
How can I communicate between bean to bean.....
Hi All,
I have few EJBs in my application. I want to interact Second EJB from First EJB. Do I need to lookup the second EJB from First EJB or Is there any way (Just like in servletContext in Servlets) to interact with the second bean. Please help me out to solve this problem, thanking you in advance.
bye
RameshHi, if you are trying to use a bean from another bean you have to do a lookup like you always did but in the deployment descriptor you have to make a refference to the second bean also.
If you are using JBoss there's an application ejx.jar for making the deployment descriptor.
I hope this link can help you a bit more:
http://e-docs.bea.com/wle/dd/ddref.htm
Bye Albinegro -
Access session values in Managed Bean
I want to acces session attribute values in my Managed Bean class.
This is my code in SecurityPhaseListener.java class,
HttpSession session = (HttpSession)facesContext.getCurrentInstance().getExternalContext().getSession(true);
String isAuthorized = "false";
session.setAttribute(isAuthorized, isAuthorized);
This is my configuration for My managed bean in faces-config.xml class
<managed-bean>
<managed-bean-name>setNewDayBean</managed-bean-name>
<managed-bean-class>com.hli.vipstar.uswm.setnewday.managedbean.SetNewDayBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
Now i want to access the attribute "isAuthorized" in my managed bean SetNewDayBean.java.
How to do this?
Any one help me...........The same way, but then using getAttribute() instead of setAttribute().
Another -more clean- way is to use the ExternalContext#getSessionMap(). It will make your code independent from the session implementation used. You may find this article useful as well: http://balusc.blogspot.com/2006/06/communication-in-jsf.html -
Cannot get reference to a managed bean from another
After reading one of BlausC article:
http://balusc.blogspot.com/2006/06/communication-in-jsf.html#AccessingAnotherManagedBean
I always get null when I try to get a reference to a session scoped managed bean from a current bean:
Here is part of the faces context config file:
<faces-config>
<managed-bean>
<managed-bean-name>approvalManagementBean</managed-bean-name>
<managed-bean-class>com.waseel.waseele.presentation.approval.management.ApprovalManagementBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>configService</property-name>
<property-class>com.waseel.waseele.business.config.ConfigService</property-class>
<value>#{configService}</value>
</managed-property>
<managed-property>
<property-name>approvalService</property-name>
<property-class>com.waseel.waseele.business.approval.ApprovalService</property-class>
<value>#{approvalService}</value>
</managed-property>
<managed-property>
<property-name>claimManagementService</property-name>
<property-class>com.waseel.waseele.business.claim.management.ClaimManagementService</property-class>
<value>#{claimManagementService}</value>
</managed-property>
<managed-property>
<property-name>codedValuesLoaderServices</property-name>
<property-class>com.waseel.waseele.business.claim.extraction.loader.codedValuesLoader.CodedValuesLoaderServices</property-class>
<value>#{codedValue}</value>
</managed-property>
<managed-property>
<property-name>approvalSubmission</property-name>
<property-class>com.waseel.waseele.business.approval.submission.ApprovalSubmission</property-class>
<value>#{approvalSubmission}</value>
</managed-property>
<managed-property>
<property-name>payerTpaRelationService</property-name>
<property-class>com.waseel.waseele.business.payerTpaRelation.PayerTpaRelationService</property-class>
<value>#{payerTpaRelationService}</value>
</managed-property>
<managed-property>
<property-name>payerTpaFiller</property-name>
<property-class>com.waseel.waseele.business.payerTpaRelation.PayerTpaFiller</property-class>
<value>#{payerTpaFiller}</value>
</managed-property>
</managed-bean>and part of my code:
public String displayApprovalInEditMode()throws Exception{
//This is cross-managed been access; I need to get the current Approval in the approval management been
ApprovalManagementBean appMangBean=(ApprovalManagementBean) FacesContext.getCurrentInstance()
.getExternalContext().getSessionMap().get("approvalManagementBean");What possible problems may be?
Can any one tell when these session managed beans object get created? is it at start up? or when loading a JSF page that use a bean ?
becasue this code work in places while not in anotherYou must be doing something wrong. I cannot reproduce this problem with the following SSCCE on JSF 1.2_13 at Tomcat 6.0.20.
Bean1package mypackage;
public class Bean1 {
private Bean2 bean2;
public boolean isBean2Present() {
return bean2 != null;
public Bean2 getBean2() {
return bean2;
public void setBean2(Bean2 bean2) {
this.bean2 = bean2;
}Bean2package mypackage;
public class Bean2 {
}JSF<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<f:view>
<html>
<head>
<title>Test</title>
</head>
<body>
<h:outputText value="Is bean2 present? #{bean1.bean2Present ? 'yes' : 'no'}" />
</body>
</html>
</f:view>faces-config<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
<managed-bean>
<managed-bean-name>bean1</managed-bean-name>
<managed-bean-class>mypackage.Bean1</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>bean2</property-name>
<value>#{bean2}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>bean2</managed-bean-name>
<managed-bean-class>mypackage.Bean2</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>It prints 'yes'.
Maybe you are looking for
-
Transfer VOIP Calls Between Cisco Desk Phone and Cisco Jabber For IPhone 9.5
Does anyone know how to transfer an active voip call from a Cisco IP Desk Phone to Cisco Jabber for IPhone? I can transfer a call from Cisco Jabber for IPhone to my Cisco IP Desk Phone no problem. I put the call on hold and then click "Resume" on m
-
I printed a 'preview' document and now it continues to print a never ending set of copies. I have re-installed the printer software, but it still continues to print more copies. What do I need to do to stop the document printing?
-
Hello All, I'll be moving with my MacPro and Cinema Display to Munich, Germany on November 30. I need to get European Power Cords for my machine. Any ideas as to where I can buy Apple-branded power cords for European style outlets? There's currently
-
Recently erased my entire mac HD do to mavericks update going wrong. I do not have a back up for my music. But my itunes match account has all my music. If i add this computer with my itunes match will it put all the music i had back in my itunes li
-
hi all, Whenever i watch any flash video it almost unwatchable until i let the entire video load, even then it is still very choppy. I already down graded to flash 9, which helped a little but not much. it was fine until i installed leoapard, and i u