简体   繁体   English

如何将数据从网页传递到另一个项目中的另一个网页(JSF 1.1-ADF 10.1.3)

[英]How to pass data from a web page to another web page in a different project (JSF 1.1 - ADF 10.1.3)

I've got two pages in two different projects (it means in different ear files that are deployed singularly) and i need to pass data from a page to another. 我在两个不同的项目中有两个页面(这意味着在单个部署的不同的耳朵文件中),我需要将数据从一个页面传递到另一个页面。

in the action of a command link i do 在命令链接的动作中

public String onSalva() {
     ADFContext.getCurrent().getApplicationScope().put("comingFrom", md);

     return "goToPrint";
}

and in the constructor method of the backing bean of the other page i do: 在另一页的后备bean的构造方法中,我做了:

page = (String)ADFContext.getCurrent().getApplicationScope().get("comingFrom");

But page is always null. 但是页面始终为空。 I tried using process, session and request scop with no luck. 我尝试使用进程,会话和请求范围,但没有运气。 Is there a way i could redirect to the other page by specifying manually the parametrs? 有没有一种方法可以通过手动指定参数重定向到另一页? Something like 就像是

   return "goToPrint?pageFrom="+md;
}

When you say "different EAR", then that means the two applications are isolated from each other and there is no simple way to get data from one to the other via Java. 当您说“不同的EAR”时,这意味着两个应用程序是相互隔离的,没有简单的方法可以通过Java将数据从另一个应用程序获取到另一个应用程序。

Instead, you have to use the HTTP protocol. 相反,您必须使用HTTP协议。 If you just want to go to a URL, use HttpServletResponse.sendRedirect() 如果只想转到一个URL,请使用HttpServletResponse.sendRedirect()

This will open the new page in the browser as if the user had typed the URL into the location bar. 这将在浏览器中打开新页面,就像用户在位置栏中键入URL一样。 The browser will no longer talk to your first application 浏览器将不再与您的第一个应用程序对话

If you want to stay in your first application and just send some data to the other side, there are several ways: You could embed the other app with an iframe - That would not allow you to exchange data but the user could fill and submit a form, for example. 如果您想保留在第一个应用程序中并仅向另一端发送一些数据,可以采用以下几种方法:您可以将另一个应用程序嵌入到iframe -不允许您交换数据,但用户可以填写并提交形式,例如。

Or you could use a library like HttpClient to talk to the other application. 或者,您可以使用HttpClient之类的库与其他应用程序对话。 This would allow you send POST requests and do everything a web browser could do with the other app. 这将允许您发送POST请求,并执行Web浏览器可以与其他应用程序一起执行的所有操作。

Lastly, you could define a shared enterprise bean which both EARs consume. 最后,您可以定义两个EAR都使用的共享企业bean。 One approach would be to define a message service to which boths apps subscribe. 一种方法是定义两个应用程序都订阅的消息服务。 The first one creates the messages and puts them into the queue and the second one waits for the message and does something with it. 第一个创建消息并将其放入队列,第二个等待消息并对其进行处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM