Dynamically create response in JSF
Asked Answered
G

1

0

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.

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.

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?

Gribble answered 12/10, 2012 at 14:40 Comment(0)
E
3

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

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

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.

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> 
Elasticize answered 12/10, 2012 at 16:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.