在JSF中动态创建响应 [英] Dynamically create response in JSF

查看:45
本文介绍了在JSF中动态创建响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的JSF页面上有一个链接.当您单击此链接时,将启动Java Web Start应用程序.该应用程序根本不影响当前页面.该应用程序仅自行启动.

I want to have a link on my JSF page. When you click this link, a Java Web Start application starts. The application doesnt affect the current page at all. The application just starts on its own.

问题是,我需要即时生成启动Java Web Start应用程序的JNLP文件.基本上,我将根据应用程序的状态来决定哪个应用程序以及JNLP文件的参数.

The problem is, I the JNLP file that starts the Java Web Start application needs to be generated on the fly. Basically I will decide which application and what paramaters for the JNLP file depending on the state of the application.

有人知道我可以做到这一点的方法吗?是否可以通过单击链接而不影响当前页面来简单地执行动态创建的JNLP文件?

Does anyone know of a way that I can accomplish this. Is it possible to execute a dynamically created JNLP file simple by clicking a link and not affecting the current page?

推荐答案

您可以拥有一个Servlet,以捕获对(某些)文件类型(jnlp)的请求.

you can have a servlet that captures the requests for (certain) filetypes (jnlp).

我一直在扩展JnlpDownloadServlet并结合一个jsp文件,该文件用作对单击链接的响应.

I've been extending JnlpDownloadServlet in combination with a jsp file that is served as response to the clicked link.

http://docs.oracle. com/javase/1.5.0/docs/guide/javaws/developersguide/downloadservletguide.html

必须通过使用http get参数和codebase属性来保留状态,因为在应用程序启动期间jnlp文件可能会多次下载.因此,保持状态的唯一方法就是通过afaik来做到这一点.

The state has to be preserved by using http get parameters together with the codebase attribute as jnlp file might be downloaded more than once during launch of application. So only way to preserve state is to do it this way afaik.

此示例中的状态为用户名和客户端令牌. 这是我一直在使用的jsp文件的一部分:

The state in this example is username and clienttoken. this is parts of the jsp file i've been using:

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase=<%=request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ request.getContextPath() + "/" %> href="jnlpfile.jnlp&#063;username=<%=request.getParameter("username")%>&clienttoken=<%=request.getParameter("clienttoken")%>">
  <information>
            <title>title</title>
            <vendor>vendor</vendor>
            <description kind="short">short desc</description>
            <icon href="resources/images/icon.jpg" kind="default"/>
  </information>
  <security>
      <all-permissions/>
  </security>
  <resources>
            <java version="1.7+" java-vm-args="-ea" initial-heap-size="128m" max-heap-size="512m" />
            <jar download="eager" href="test.jar"/>
  </resources>
  <application-desc main-class="test.MainClass">
       <argument><%=request.getServerName()%></argument>  
       <argument><%=request.getParameter("username")%></argument>
       <argument><%=request.getParameter("clienttoken")%></argument>
  </application-desc>
  <update check="background"/>
</jnlp> 

这篇关于在JSF中动态创建响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆