aspose file tools*
The moose likes JBoss/WildFly and the fly likes Parameter passing from one app (EAR) to another EAR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Parameter passing from one app (EAR) to another EAR" Watch "Parameter passing from one app (EAR) to another EAR" New topic
Author

Parameter passing from one app (EAR) to another EAR

dwarakanathan thiru
Ranch Hand

Joined: Oct 14, 2009
Posts: 49
Hi,

I have JBoss portal server and I have two applications (different EAR files) deployed in it.

I provide a link in my first application which takes the user to a page in the second application. Both implement JSF framework.
Now, how can I pass parameter from the first application to second application? Can i pass request parameters? I would like to avoid query strings too.

I tried to get the backing bean of the first application, in the second application but I guess it wont work.
Every FacesContext is unique for each application.

Thanks!!


Thanks,
Dwarak T
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

By design, enterprise applications (EARs) are independent of each other. The FacesContext is different, and so are the user sessions. However, if you're clicking a link in one application that sends you to the other application, you have a number of options. You can pass the information as part of the URL; you can put it into form data and post it; you can even store it in a cookie.

Beyond that, there are ways of making two independent processes communicate information. You could store the information in a shared resource, like a database, or on the file system, or you have some kind of inter-process communication: RMI, Corba, socket connections, JMS. The only thing you can't do is get one application to look into the data of the other. You should think of them as two separate applications running on different servers.
dwarakanathan thiru
Ranch Hand

Joined: Oct 14, 2009
Posts: 49
Okay!! Cool!!
I have been trying various ways. Even sending via the URL get / post method as you have mentioned.
But it does not seem to work. Please have a look at the following code snippet.

To set the attribute in portlet session
final FacesContext fcRequest = FacesContext.getCurrentInstance();
final PortletSession objPortletSess = (PortletSession) fcRequest.getExternalContext().getSession(false);
objPortletSess.setAttribute("fileId", getStrSelFileId(), PortletSession.APPLICATION_SCOPE);


To get the attribute from portlet session
PortletSession objPortletSess = (PortletSession) fcRequest.getExternalContext().getSession(false);
String strSelFileId = (String) objPortletSess.getAttribute("fileId", PortletSession.APPLICATION_SCOPE);
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2861
    
  11

Sorry, I didn't even notice you said you are running JBoss Portal. There are some mechanisms for portlet to portlet communication, beyond what I mentioned. It looks like that's what you're getting at. Unfortunately, I have very limited experience with portals, and none whatsoever with JBoss Portal, so I can't help you there.
dwarakanathan thiru
Ranch Hand

Joined: Oct 14, 2009
Posts: 49
Finally I got a way that works.
I tried passing request parameters from the 1st application to the 2nd application using a servlet in the 2nd app.
And from there I will set the parameter back to a session & use a redirect to my portal page, which will use up the parameter.

I shall post the code soon.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Parameter passing from one app (EAR) to another EAR