-
1. Re: Help!
claudia.icmc Oct 30, 2009 4:09 PM (in response to claudia.icmc)Hi!
The application works fine when I use jsf:
<h:commandLink id="enterLink" action="#{Bean.join}" rendered="#{Bean.canJoin}">
But if I replace with ajax4jsf:
<a4j:commandLink id="enterLink" action="#{Bean.join}" rendered="#{Bean.canJoin}">
The page printed the JNLP.
I think the tag is wrong. The code is right because the application works fine with jsf.
How to create a link using ajax4jsf that it will open my webStart application?!
Thanks! -
2. Re: Help!
nbelaevski Nov 1, 2009 9:23 AM (in response to claudia.icmc)Hi,
a4j:commandLink doesn't allow direct file downloads.
Either use h:commnadLink or do redirect to JNLP file in action. -
3. Re: Help!
claudia.icmc Nov 6, 2009 8:22 AM (in response to claudia.icmc)Hi!
The method called (when a user clicks in link) is a void of my bean. This method redirect to JNLP file :... ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); HttpServletRequest request = (HttpServletRequest) externalContext.getRequest(); HttpServletResponse response = (HttpServletResponse) externalContext.getResponse(); request.setAttribute(...); ... ExternalContext extContext = (ExternalContext) FacesContext.getCurrentInstance().getExternalContext(); ServletContext servletContext = (ServletContext) extContext.getContext(); ServletContext newcontext = (ServletContext) servletContext.getContext("/my-tool"); RequestDispatcher dispatcher = newcontext.getRequestDispatcher("/my-servlet-mapping"); dispatcher.forward(request, response); FacesContext.getCurrentInstance().responseComplete();
A class is called using servlet mapping.This class extends HttpServlet and is a servlet that dynamically generates the JNLP file for clients:... response.setContentType("application/x-java-jnlp-file"); String jnlp = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><jnlp spec=\"1.0+\""+ " codebase=\""+ host + ":" + port + "/"+ "my-tool"+ "\">" ... + "<argument>"+ request.getAttribute(" ... ")+ "</argument>" + ...; out.println(jnlp);
But, when a user clicks in link, the page prints the jnlp. My application doesn't open with Java WebStart.
Any idea? -
4. Re: Help!
nbelaevski Nov 6, 2009 11:47 AM (in response to claudia.icmc)... ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext() ; HttpServletRequest request = (HttpServletRequest) externalContext.getRequest(); HttpServletResponse response = (HttpServletResponse) externalContext.getResponse(); request.setAttribute(...); ... ExternalContext extContext = (ExternalContext) FacesContext.getCurrentInstance().getExte rnalContext(); ServletContext servletContext = (ServletContext) extContext.getContext(); ServletContext newcontext = (ServletContext) servletContext.getContext("/my-tool"); RequestDispatcher dispatcher = newcontext.getRequestDispatcher("/my-servlet-mapping"); dispatcher.forward(request, response); FacesContext.getCurrentInstance().responseComplete();
I see forward there, but no redirect. -
5. Re: Help!
claudia.icmc Nov 6, 2009 2:07 PM (in response to claudia.icmc)I can't redirect to adress that have o jnpl. The problem is that there isn't a "static address" for the jnlp. Because it is generated dynamically:
... response.setContentType("application/x-java-jnlp-file"); String jnlp = "<?xml version=\"1.0\" encoding=\"ISO-8859-\"?><jnlp spec=\"1.0+\""+ " codebase=\""+ host + ":" + port + "/"+"my-tool"+ "\">" ... + "<argument>"+ request.getAttribute(" ... ")+"</argument>" + ...; out.println(jnlp);
I need of a servlet, that's why I use a mapping. -