Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parameter passing from one app (EAR) to another EAR

 
dwarakanathan thiru
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic