Hello,
I was wondering after I have submitted my data via a trigger how can I automatically relocate to another url? Regards, John. |
John,
If my hunch is correct, you should be able to use the xforms:load statement to load another URL into the same browser window. Alex posts about it in this thread: http://www.nabble.com/XForms-load-td1115057.html In your case, you'll want your 'show' attribute to have a value of "replace," in order for the browser to load the URL in the current window. Hope this helps, Philip
|
You would use <xforms:load/> if you want the new
page to be loaded immediately the user clicks on the trigger. However,
in your case you want to send a submission when the user clicks the
trigger, and go to a new location when the submission completes. In
this case what you want to do is something like
[ in the model ] <xforms:submission id="my-submission" action="..." ...> <xforms:load resource="http://www.example.com/page" ev:event="xforms-submit-done"/> </xforms:submission> ... [ in the body ] <xforms:trigger> <xforms:label>Submit</xforms:label> <xforms:send ev:event="DOMActivate" submission="my-submission"/> </xforms:trigger> By making the load depend on the xforms-submit-done event like this, the page load will only happen if the submission succeeds. HTH, Dave Philip.Cantin wrote: John, If my hunch is correct, you should be able to use the xforms:load statement to load another URL into the same browser window. Alex posts about it in this thread: http://www.nabble.com/XForms-load-td1115057.html In your case, you'll want your 'show' attribute to have a value of "replace," in order for the browser to load the URL in the current window. Hope this helps, Philip JohnBampton wrote:Hello, I was wondering after I have submitted my data via a trigger how can I automatically relocate to another url? Regards, John. --
This
e-mail and any attachments are intended only for the person to whom it
is addressed
and may contain privileged, proprietary, or other data protected from
disclosure
under applicable law. If you are not the addressee or the person
responsible
for delivering this to the addressee you are hereby notified that
reading, copying
or distributing this transmission is prohibited. If you have received
this e-mail
in error, please telephone us immediately and remove all copies of it
from your
system. Thank you for your co-operation.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4431 (20090916) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
here's an example of what you need
<xforms:group> <xforms:trigger> <xforms:label>Save</xforms:label> </xforms:trigger> <xforms:send submission="save-submission" ev:event="DOMActivate"/> <xforms:load resource="/someurl" show="replace" ev:event="DOMActivate"/> </xforms:group> On Wed, Sep 16, 2009 at 6:10 PM, Dave McIntyre <[hidden email]> wrote:
-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
While this would work when everything goes without
problems, it's not an ideal solution because you do the page load
regardless of whether or not the submission succeeded. But of course
it depends on your requirements.
Jeremiah Jahn wrote:
--
This
e-mail and any attachments are intended only for the person to whom it
is addressed
and may contain privileged, proprietary, or other data protected from
disclosure
under applicable law. If you are not the addressee or the person
responsible
for delivering this to the addressee you are hereby notified that
reading, copying
or distributing this transmission is prohibited. If you have received
this e-mail
in error, please telephone us immediately and remove all copies of it
from your
system. Thank you for your co-operation.
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4431 (20090916) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
doh! I'm 0 for 2 tonight. But good to know, I hadn't gotten that far into what 'm doing yet, so I appreciate the correction. As this would have been a problem for me in just a little while. On Sep 16, 2009, at 8:22 PM, Dave McIntyre wrote:
-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Hello,
I can't find any actual hints or comments for running Orbeon XForms in the portlet container Pluto (irunning in JBoss 4.2.2). Are there any experiences with the configuration? Thanks for sharing your experiences, Karolin -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
Karolin,
I am not sure if anybody else on the list has tried this, but at Orbeon we haven't tried it. -Erik On Thu, Sep 17, 2009 at 12:51 AM, Karolin Krieg <[hidden email]> wrote: > Hello, > > I can't find any actual hints or comments for running Orbeon XForms in > the portlet container Pluto (irunning in JBoss 4.2.2). > Are there any experiences with the configuration? > > > Thanks for sharing your experiences, > > Karolin > > > > -- > You receive this message as a subscriber of the [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > > -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Hallo
I recently asked if anybody has experiences including Orbeon XForms in a Pluto Portal. I got it running, but quick and dirty. If somebody has a nice solution i would love to know it. I want so share my experiences: web.xml I used the filter: http://www.orbeon.com/ops/doc/reference-xforms-java The filter didnt work by default. I had to add <dispatcher>INCLUDE</dispatcher>. XFormsPortlet.java I tried two ways to include XForms: 1. context.getRequestDispatcher(VIEW_PAGE).include(request, response); OrbeonXFormsFilter.java Because the pluto framework already called the PrintWriter the ServletOutputStream cant be used. I put the content of the OutputStream in the PrintWriter to get it running. // write rendered XForm String content = responseWrapper.getServletOutputContent(); content = content.replace("/pluto/orbeon", "/orbeon"); // todo: hack -> find better way servletResponse.getWriter().write(content); 2. request.setAttribute("oxf.xforms.renderer.document", xform); OrbeonXFormsFilter.java The attribute "oxf.xforms.renderer.document" set in doView() gets encoded by Pluto. In OrbeonXFormsFilter.java i cant read the attribute out by default. The attribute looks like Pluto_testsuite.XFormsPortlet!-577071127|1_oxf.xforms.renderer.document. I made a hack in OrbeonXFormsFilter.java to get it running: // Set document if not present AND output was intercepted if (!requestWrapper.hasXFormsRendererDocument()) { final String content = responseWrapper.getContent(); if (content != null) { httpRequest.setAttribute(OPS_XFORMS_RENDERER_DOCUMENT_ATTRIBUTE_NAME, content); } } else { String contentFromAtr = requestWrapper.getXFormRenderDocument(); if (contentFromAttr != null) { if (contentFromAttr != null) { responseWrapper.getWriter().write(contentFromAttr); httpRequest.setAttribute(OPS_XFORMS_RENDERER_DOCUMENT_ATTRIBUTE_NAME, contentFromAtr); } } } Karolin web.xml ------------------------------------------------------------------------------------------------------------------------------ <!-- Declare and configure the Orbeon Forms XForms filter --> <filter> <filter-name>orbeon-xforms-filter</filter-name> <filter-class>ch.abacus.flow.web.servlet.OrbeonXFormsFilter</filter-class> <init-param> <param-name>oxf.xforms.renderer.context</param-name> <param-value>/orbeon</param-value> </init-param> </filter> <!-- Any web content from servlet "XFormsPortlet" will get processed by the XForms engine --> <filter-mapping> <filter-name>orbeon-xforms-filter</filter-name> <servlet-name>XFormsPortlet</servlet-name> <dispatcher>REQUEST</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> <!--This is necessary so that XForms engine resources can be served appropriately--> <filter-mapping> <filter-name>orbeon-xforms-filter</filter-name> <url-pattern>/orbeon/*</url-pattern> <dispatcher>REQUEST</dispatcher> <dispatcher>INCLUDE</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping> XFormsPortlet.java --------------------------------------------------------------------------------------------------------------- public class XFormsPortlet extends GenericPortlet { private static final String VIEW_PAGE = "/jsp/testxforms.jsp"; public XFormsPortlet() { } public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { PortletContext context = getPortletContext(); boolean test = false; if (test) { String xform = readFileAsString("C:\\test\\testxforms.jsp"); request.setAttribute("oxf.xforms.renderer.document", xform); //((RenderRequestImpl)request).getRequestContext().getServletRequest().setAttribute("oxf.xforms.renderer.document", xform) } else { context.getRequestDispatcher(VIEW_PAGE).include(request, response); } } OrbeonXFormsFilter.java ------------------------------------------------------------------------------------------------------ package ch.abacus.flow.web.servlet; /** * Copyright (C) 2009 Orbeon, Inc. * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU Lesser General Public License as published by the Free Software Foundation; either version * 2.1 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * The full text of the license is available at http://www.gnu.org/copyleft/lesser.html */ import javax.servlet.*; import javax.servlet.http.*; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.util.*; /** * This filter allows forwarding requests from your web app to an separate Orbeon Forms context. * * This filter must remain very simple and have as little dependencies as possible, because it must be easily deployable * into any web application. */ public class OrbeonXFormsFilter implements Filter { public static final String OPS_XFORMS_RENDERER_DEPLOYMENT = "oxf.xforms.renderer.deployment"; public static final String OPS_XFORMS_RENDERER_REQUEST_CONTEXT_PATH = "oxf.xforms.renderer.request.context-path"; public static final String OPS_XFORMS_RENDERER_DOCUMENT_ATTRIBUTE_NAME = "oxf.xforms.renderer.document"; public static final String OPS_XFORMS_RENDERER_BASE_URI_ATTRIBUTE_NAME = "oxf.xforms.renderer.base-uri"; public static final String OPS_XFORMS_RENDERER_CONTENT_TYPE_ATTRIBUTE_NAME = "oxf.xforms.renderer.content-type"; public static final String OPS_XFORMS_RENDERER_HAS_SESSION_ATTRIBUTE_NAME = "oxf.xforms.renderer.has-session"; public static final String OPS_SERVLET_CONTEXT_ATTRIBUTE_NAME = "oxf.servlet.context"; public static final String OPS_RENDERER_PATH = "/xforms-renderer"; private static final String OPS_XFORMS_RENDERER_CONTEXT_PARAMETER_NAME = "oxf.xforms.renderer.context"; private static final String DEFAULT_ENCODING = "ISO-8859-1"; // must be this per Servlet spec private ServletContext servletContext; private String opsContextPath; public void init(FilterConfig filterConfig) throws ServletException { servletContext = filterConfig.getServletContext(); opsContextPath = filterConfig.getInitParameter(OPS_XFORMS_RENDERER_CONTEXT_PARAMETER_NAME); // TODO: check opsContextPath format: starts with /, doesn't end with one, etc. } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { final HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; final HttpServletResponse httpResponse = (HttpServletResponse) servletResponse; final String requestPath = getRequestPathInfo(httpRequest); if (isOPSResourceRequest(requestPath)) { // Directly forward all requests meant for Orbeon Forms resources final String subRequestPath = requestPath.substring(opsContextPath.length()); getOPSDispatcher(subRequestPath).forward(httpRequest, httpResponse); } else { // Forward the request to the Orbeon Forms renderer final MyHttpServletResponseWrapper responseWrapper = new MyHttpServletResponseWrapper(httpResponse); MyHttpServletRequestWrapper requestWrapper = new MyHttpServletRequestWrapper(httpRequest); // Execute filter filterChain.doFilter(requestWrapper, responseWrapper); // Set document if not present AND output was intercepted // if (httpRequest.getAttribute(OPS_XFORMS_RENDERER_DOCUMENT_ATTRIBUTE_NAME) == null) { if (!requestWrapper.hasXFormsRendererDocument()) { final String content = responseWrapper.getContent(); if (content != null) { httpRequest.setAttribute(OPS_XFORMS_RENDERER_DOCUMENT_ATTRIBUTE_NAME, content); } } else { String contentFromAtr = requestWrapper.getXFormRenderDocument(); if (contentFromAtr != null) { if (contentFromAtr != null) { responseWrapper.getWriter().write(contentFromAtr); httpRequest.setAttribute(OPS_XFORMS_RENDERER_DOCUMENT_ATTRIBUTE_NAME, contentFromAtr); } } } // Set whether deployment is integrated or separate httpRequest.setAttribute(OPS_XFORMS_RENDERER_DEPLOYMENT, (getOPSContext() == servletContext) ? "integrated" : "separate"); // Set servlet context for renderer httpRequest.setAttribute(OPS_XFORMS_RENDERER_REQUEST_CONTEXT_PATH, httpRequest.getContextPath()); // Override Orbeon Forms context so that rewriting works correctly if (opsContextPath != null) httpRequest.setAttribute(OPS_SERVLET_CONTEXT_ATTRIBUTE_NAME, httpRequest.getContextPath() + opsContextPath); // Tell whether there is a session httpRequest.setAttribute(OPS_XFORMS_RENDERER_HAS_SESSION_ATTRIBUTE_NAME, Boolean.toString(httpRequest.getSession(false) != null)); // Provide media type if available if (responseWrapper.getMediaType() != null) httpRequest.setAttribute(OPS_XFORMS_RENDERER_CONTENT_TYPE_ATTRIBUTE_NAME, responseWrapper.getMediaType()); // Set base URI httpRequest.setAttribute(OPS_XFORMS_RENDERER_BASE_URI_ATTRIBUTE_NAME, requestPath); // Forward to Orbeon Forms for rendering only of there is content to be rendered, otherwise just return and // let the filterChain finish its life naturally, assuming that when sendRedirect is used, no content is // available in the response object if (!isBlank(responseWrapper.getContent())) getOPSDispatcher(OPS_RENDERER_PATH).forward(httpRequest, responseWrapper); // write rendered XForm String content = responseWrapper.getServletOutputContent(); content = content.replace("/pluto/orbeon", "/orbeon"); // todo: hack -> find better way servletResponse.getWriter().write(content); } } // NOTE: this method copied from Apache StringUtils 2.3 as we don't want a dependency on the JAR // http://www.apache.org/licenses/LICENSE-2.0 public static boolean isBlank(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if ((!Character.isWhitespace(str.charAt(i)))) { return false; } } return true; } public void destroy() { } private ServletContext getOPSContext() throws ServletException { final ServletContext opsContext = (opsContextPath != null) ? servletContext.getContext(opsContextPath) : servletContext; if (opsContext == null) throw new ServletException("Can't find Orbeon Forms context called '" + opsContextPath + "'. Check the '" + OPS_XFORMS_RENDERER_CONTEXT_PARAMETER_NAME + "' filter initialization parameter and the <Context crossContext=\"true\"/> attribute."); return opsContext; } private RequestDispatcher getOPSDispatcher(String path) throws ServletException { final RequestDispatcher dispatcher = getOPSContext().getRequestDispatcher(path); if (dispatcher == null) throw new ServletException("Can't find Orbeon Forms request dispatcher."); return dispatcher; } private boolean isOPSResourceRequest(String requestPath) { return opsContextPath != null && requestPath != null && requestPath.startsWith(opsContextPath + "/"); } // NOTE: This is borrowed from NetUtils but we don't want the dependency private static String getRequestPathInfo(HttpServletRequest request) { // Get servlet path and path info String servletPath = request.getServletPath(); if (servletPath == null) servletPath = ""; String pathInfo = request.getPathInfo(); if (pathInfo == null) pathInfo = ""; // Concatenate servlet path and path info, avoiding a double slash String requestPath = servletPath.endsWith("/") && pathInfo.startsWith("/") ? servletPath + pathInfo.substring(1) : servletPath + pathInfo; // Add starting slash if missing if (!requestPath.startsWith("/")) requestPath = "/" + requestPath; return requestPath; } // NOTE: This is borrowed from NetUtils but we don't want the dependency public static String getContentTypeCharset(String contentType) { if (contentType == null) return null; int semicolumnIndex = contentType.indexOf(";"); if (semicolumnIndex == -1) return null; int charsetIndex = contentType.indexOf("charset=", semicolumnIndex); if (charsetIndex == -1) return null; // FIXME: There may be other attributes after charset, right? String afterCharset = contentType.substring(charsetIndex + 8); afterCharset = afterCharset.replace('"', ' '); return afterCharset.trim(); } // NOTE: This is borrowed from NetUtils but we don't want the dependency public static String getContentTypeMediaType(String contentType) { if (contentType == null || contentType.equalsIgnoreCase("content/unknown")) return null; int semicolumnIndex = contentType.indexOf(";"); if (semicolumnIndex == -1) return contentType; return contentType.substring(0, semicolumnIndex).trim(); } private static class MyHttpServletRequestWrapper extends HttpServletRequestWrapper { private Enumeration<String> headerNames; public MyHttpServletRequestWrapper(HttpServletRequest httpServletRequest) { super(httpServletRequest); } public String getHeader(String s) { // Filter conditional get headers so that we always get content if (s.toLowerCase().startsWith("if-") ) return null; else return super.getHeader(s); } public Enumeration getHeaders(String s) { // Filter conditional get headers so that we always get content if (s.toLowerCase().startsWith("if-")) return null; else return super.getHeaders(s); } public Enumeration getHeaderNames() { if (headerNames == null) { // Filter conditional get headers so that we always get content final List<String> newHeaderNames = new ArrayList<String>(); for (Enumeration e = super.getHeaderNames(); e.hasMoreElements();) { final String currentName = (String) e.nextElement(); if (!currentName.toLowerCase().startsWith("if-")) newHeaderNames.add(currentName); } headerNames = Collections.enumeration(newHeaderNames); } return headerNames; } public long getDateHeader(String s) { // Filter conditional get headers so that we always get content if (s.toLowerCase().startsWith("if-")) return -1; else return super.getDateHeader(s); } public String getXFormRenderDocument(){ Enumeration attrs = getAttributeNames(); while(attrs.hasMoreElements()){ Object o = attrs.nextElement(); System.out.println(o.toString()); } return (String) getAttribute("Pluto" +"_"+getAttribute("portlet") +"_"+OPS_XFORMS_RENDERER_DOCUMENT_ATTRIBUTE_NAME ); } public boolean hasXFormsRendererDocument(){ return getAttribute("Pluto" +"_"+getAttribute("portlet") +"_"+OPS_XFORMS_RENDERER_DOCUMENT_ATTRIBUTE_NAME ) != null; } } private static class MyHttpServletResponseWrapper extends HttpServletResponseWrapper { public MyHttpServletResponseWrapper(HttpServletResponse response) { super(response); } private ByteArrayOutputStream byteArrayOutputStream; private ServletOutputStream servletOutputStream; private StringWriter stringWriter; private PrintWriter printWriter; private String encoding; private String mediatype; public void addCookie(Cookie cookie) { super.addCookie(cookie); } public boolean containsHeader(String string) { return super.containsHeader(string); } public String encodeURL(String string) { return super.encodeURL(string); } public String encodeRedirectURL(String string) { return super.encodeRedirectURL(string); } public String encodeUrl(String string) { return super.encodeUrl(string); } public String encodeRedirectUrl(String string) { return super.encodeRedirectUrl(string); } public void sendError(int i, String string) throws IOException { // TODO } public void sendError(int i) throws IOException { // TODO } public void sendRedirect(String string) throws IOException { super.sendRedirect(string); } public void setDateHeader(String string, long l) { // TODO } public void addDateHeader(String string, long l) { // TODO } public void setHeader(String string, String string1) { // TODO } public void addHeader(String string, String string1) { // TODO } public void setIntHeader(String string, int i) { // TODO } public void addIntHeader(String string, int i) { // TODO } public void setStatus(int i) { // TODO } public void setStatus(int i, String string) { // TODO } public ServletResponse getResponse() { return super.getResponse(); } public void setResponse(ServletResponse servletResponse) { super.setResponse(servletResponse); } public String getCharacterEncoding() { // TODO: we don't support setLocale() return (encoding == null) ? DEFAULT_ENCODING : encoding; } public String getMediaType() { return mediatype; } public ServletOutputStream getOutputStream() throws IOException { if (byteArrayOutputStream == null) { byteArrayOutputStream = new ByteArrayOutputStream(); servletOutputStream = new ServletOutputStream() { public void write(int i) throws IOException { byteArrayOutputStream.write(i); } }; } return servletOutputStream; } public PrintWriter getWriter() throws IOException { if (printWriter == null) { stringWriter = new StringWriter(); printWriter = new PrintWriter(stringWriter); } return printWriter; } public void setContentLength(int i) { // NOP } public void setContentType(String contentType) { this.encoding = getContentTypeCharset(contentType); this.mediatype = getContentTypeMediaType(contentType); } public void setBufferSize(int i) { // NOP } public int getBufferSize() { // We have a buffer, but it is infinite return Integer.MAX_VALUE; } public void flushBuffer() throws IOException { // NOPE } public boolean isCommitted() { // We buffer everything so return false all the time return false; } public void reset() { resetBuffer(); } public void resetBuffer() { if (byteArrayOutputStream != null) { try { servletOutputStream.flush(); } catch (IOException e) { // ignore? } byteArrayOutputStream.reset(); } else if (stringWriter != null) { printWriter.flush(); final StringBuffer sb = stringWriter.getBuffer(); sb.delete(0, sb.length()); } } public void setLocale(Locale locale) { // TODO } public Locale getLocale() { return super.getLocale(); } public String getContent() throws IOException { if (stringWriter != null) { // getWriter() was used printWriter.flush(); return stringWriter.toString(); } else if (servletOutputStream != null) { // getOutputStream() was used servletOutputStream.flush(); return new String(byteArrayOutputStream.toByteArray(), getCharacterEncoding()); } else { return null; } } public String getServletOutputContent() throws IOException { if (servletOutputStream != null) { // getOutputStream() was used servletOutputStream.flush(); return new String(byteArrayOutputStream.toByteArray(), getCharacterEncoding()); } else { return null; } } } } >>> Erik Bruchez <[hidden email]> 9/17/2009 11:39 >>> Karolin, I am not sure if anybody else on the list has tried this, but at Orbeon we haven't tried it. -Erik On Thu, Sep 17, 2009 at 12:51 AM, Karolin Krieg <[hidden email]> wrote: > Hello, > > I can't find any actual hints or comments for running Orbeon XForms in > the portlet container Pluto (irunning in JBoss 4.2.2). > Are there any experiences with the configuration? > > > Thanks for sharing your experiences, > > Karolin > > > > -- > You receive this message as a subscriber of the [hidden email] > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > OW2 mailing lists service home page: http://www.ow2.org/wws > > -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws |
Free forum by Nabble | Edit this page |