Examples of QueryString


Examples of org.apache.myfaces.portlet.faces.util.QueryString

  @Override
  public String encodeActionURL(String url)
  {
    String viewId = null, path = null;
    boolean nonFacesAction = false;
    QueryString queryStr = null;
    int queryStart = -1;
    boolean isPortletURL = false;
    Bridge.PortletPhase urlType = getPortletPhase();

    // First check to see if the special URI indicating we should encode
    // a Nonfaces target to just the current portlet (without an associated
    // path based resource).
    if (isPortletURL(url))
    {
      isPortletURL = true;
      nonFacesAction = true;
      //URL is of the form scheme:urlType?queryString
      // remove the scheme
      path = url.substring(url.indexOf(":")+ 1);
      queryStart = url.indexOf('?');

      if (queryStart != -1)
      {
        // Get the query string
        queryStr = new QueryString(path.substring(queryStart + 1), "UTF8");
        path = path.substring(0, queryStart);
      }
     
      if (path.equalsIgnoreCase("render"))
      {
        urlType = Bridge.PortletPhase.RENDER_PHASE;
      }
      else if (path.equalsIgnoreCase("action"))
      {
        urlType = Bridge.PortletPhase.ACTION_PHASE;
      }
      else
      {
        log("PortletExternalContextImpl.encodeActionURL:  malformed portlet url "
            + url);
        return url;
      }
    }
    else if (url.startsWith("#") || isExternalURL(url) || isDirectLink(url))
    {
      return url;
    }
    else
    {
      // Its a Path encoded URL
     
      // url might contain DirectLink=false parameter -- spec says remove if
      // it does.
      url = removeDirectLink(url);

      // Now determine the target viewId

      // First: split URL into path and query string
      // Hold onto QueryString for later processing
      queryStart = url.indexOf('?');

      if (queryStart != -1)
      {
        // Get the query string
        queryStr = new QueryString(url.substring(queryStart + 1), "UTF8");
        path = url.substring(0, queryStart);
      }
      else
      {
        path = url;
        // construct an empty queryString to hold the viewId
        queryStr = new QueryString("UTF8");
      }
   
      // Convert relative path to context path
      if (isRelativePath(path))
      {
        path = getPathFromRelativePath(path);
      }
   
      // Now se if this is a Faces URL
      viewId = getViewIdFromPath(path);

      if (viewId != null)
      {
        encodeFacesActionTarget(queryStr, viewId);
      }
      else
      {
        // URL points at non-Faces action
        nonFacesAction = true;
        encodeNonFacesActionTarget(queryStr, path);
      }
    }
   
    if (getPortletPhase() == Bridge.PortletPhase.RENDER_PHASE)
    { // render - write
      // the viewId into
      // the response
      // (interaction
      // state)
      RenderResponse renderResponse = (RenderResponse) getResponse();
      PortletURL actionURL = null;
      // Non-JSF actions are renderURLs as we merely dispatch to them
      if (nonFacesAction)
      {
        if (isPortletURL && urlType == Bridge.PortletPhase.ACTION_PHASE)
        {
          actionURL = renderResponse.createActionURL();
        }
        else
        {
          actionURL = renderResponse.createRenderURL();
        }
      }
      else
      {
        actionURL = renderResponse.createActionURL();
      }

      // Add parameters so they don't get lost
      Enumeration<String> list = queryStr.getParameterNames();
      while (list.hasMoreElements())
      {
        String param = list.nextElement().toString();
        if (param.equals(Bridge.PORTLET_MODE_PARAMETER))
        {
          try
          {
            actionURL.setPortletMode(new PortletMode(queryStr.getParameter(param)));
          }
          catch (Exception e)
          {
            ; // do nothing -- just ignore
          }
        }
        else if (param.equals(Bridge.PORTLET_WINDOWSTATE_PARAMETER))
        {
          try
          {
            actionURL.setWindowState(new WindowState(queryStr.getParameter(param)));
          }
          catch (Exception e)
          {
            ; // do nothing -- just ignore
          }
        }
        else if (param.equals(Bridge.PORTLET_SECURE_PARAMETER))
        {
          try
          {
            actionURL.setSecure(Boolean.getBoolean(queryStr.getParameter(param)));
          }
          catch (Exception e)
          {
            ; // do nothing -- just ignore
          }
        }
        else
        {
          actionURL.setParameter(param, queryStr.getParameter(param));
        }
      }

      // TODO hack to workaround double encoding problem
      url = actionURL.toString();
      url = url.replaceAll("\\&amp\\;", "&");
    }
    else
    { // action - write the viewId to navigational state
      ActionResponse actionResponse = (ActionResponse) getResponse();

      // set request params into navigational states
      Enumeration<String> list = queryStr.getParameterNames();
      while (list.hasMoreElements())
      {
        String param = list.nextElement();
        if (param.equals(Bridge.PORTLET_MODE_PARAMETER))
        {
          try
          {
            actionResponse.setPortletMode(new PortletMode(queryStr.getParameter(param)));
          }
          catch (Exception e)
          {
            //TODO: Ignoring is probably dangerous here as it means that we are
            //      EITHER using exceptions for flow control (which is extreemly
            //      inefficient) or we should log a message saying what the issue
            //      is.  According to the Javadocs an exception is thrown here if the
            //      portlet mode is not allowed or if sendRedirect has already been
            //      called.  In either case we should log an information type message
            //      here.
            ; // do nothing -- just ignore
          }
        }
        else if (param.equals(Bridge.PORTLET_WINDOWSTATE_PARAMETER))
        {
          try
          {
            actionResponse.setWindowState(new WindowState(queryStr.getParameter(param)));
          }
          catch (Exception e)
          {
            ; // do nothing -- just ignore
          }
        }
        else if (param.equals(Bridge.PORTLET_SECURE_PARAMETER))
        {
          ; // ignore -- do nothing as can't encode into an actionResponse
        }
        else
        {
          actionResponse.setRenderParameter(param, queryStr.getParameter(param));
        }
      }
    }
    // Because we want to support translating a redirect that occurs
    // during a render as an in place navigation AND we can't reverse
View Full Code Here

Examples of org.apache.myfaces.portlet.faces.util.QueryString

    // Redirects to a view are dealt (elsewhere) as navigations --
    // encode this information for later use by the bridge controller.
    // Other links are redirected.
   
    // First look to see if this is an already encoded
    QueryString params = (QueryString) getRequestMap().get(ENCODED_ACTION_URL_ATTRIBUTE_PREFIX.concat(url.replace(".", "*")));
    if (params != null)
    {
      // Because we want to support translating a redirect that occurs
      // during a render as an in place navigation AND we can't reverse
      // engineer the URL from the actionURL, we stash the original URL on
      // a request attribute, keyed with the generated URL.  If this generated
      // url is passed to redirect() we can get the original url back and
      // process based on it.
     
      // In Portlet 1.0 we can't redirect to nonFaces target during render
      // Check for this case and throw an exception
      // A NonFaces target is any that doesn't have a Faces ViewId
      // encoded in it.
      if (getPortletPhase() == Bridge.PortletPhase.RENDER_PHASE)
      {
        String target = params.getParameter(JSF_TARGET_VIEWID_RENDER_PARAMETER);
        if (target == null)
        {
          throw new IllegalStateException("Can't redirect during render to a NonFaces target: " + target);
        }
      }
View Full Code Here

Examples of org.apache.myfaces.portlet.faces.util.QueryString

    // Some viewId may have query string, so handle that here
    // (e.g., TaskFlow has the following viewId:
    // /adf.task-flow?_document=/WEB-INF/task-flow.xml&_id=task1

    int queryStart = viewId.indexOf('?');
    QueryString queryStr = null;

    if (queryStart != -1)
    {
      // parse the query string and add the parameters to internal maps
      // delay the creation of ParameterMap and ParameterValuesMap until
      // they are needed/called by the client
      queryStr = new QueryString(viewId.substring(queryStart + 1), "UTF8");

      // TODO: Constants
      mInternalRequestParameterMap = new HashMap<String, String>(5);
      mInternalRequestParameterValuesMap = new HashMap<String, String[]>(5);

      Enumeration<String> list = queryStr.getParameterNames();
      while (list.hasMoreElements())
      {
        String param = list.nextElement();
        mInternalRequestParameterMap.put(param, queryStr.getParameter(param));
        mInternalRequestParameterValuesMap.put(param, new String[]
            { queryStr.getParameter(param) });
      }

      viewId = viewId.substring(0, queryStart);
      log("PortletExternalContextImpl.getViewId: special viewId: " + viewId);
    }
View Full Code Here

Examples of org.apache.myfaces.portlet.faces.util.QueryString

    return viewId;
  }

  private void updateViewChainAttribute(String mode, String viewId, boolean modeChanged)
  {
    QueryString qs = new QueryString("UTF8");
   
    // always encode the mode in the viewId as this is used for mode transitions
    qs.setParameter(Bridge.PORTLET_MODE_PARAMETER, mode);
   
    if (!modeChanged)
    {
        // Build a QueryString from the request's render parameters so can preserve
      // with the viewId
      Map m = getRequestParameterValuesMap();
      if (!m.isEmpty())
      {
        Set <Map.Entry<String, String[]>> set = m.entrySet();
        Iterator <Map.Entry<String,String[]>> i = set.iterator();
        while (i.hasNext()) 
        {
          Map.Entry<String,String[]> e = i.next();
          // only add if not a viewId or viewState parameter
          if (!e.getKey().equals(JSF_TARGET_VIEWID_RENDER_PARAMETER)
          && !e.getKey().equals(ResponseStateManager.VIEW_STATE_PARAM))
          {
            for (String s : e.getValue())
            {
              qs.addParameter(e.getKey(), s);
            }
          }
        }
      }
    }
       
    String toAppend = qs.toString();
    StringBuffer sb = new StringBuffer(viewId.length() + toAppend.length() + 1);
    viewId = sb.append(viewId).append("?").append(toAppend).toString();
     
    // Now add to the appropriate session attribute based on Mode
    Map sessionMap = getSessionMap();
View Full Code Here

Examples of org.apache.myfaces.portlet.faces.util.QueryString

   */
  @Override
  public String encodeActionURL(String url)
  {
    String viewId = null, path = null;
    QueryString queryStr = null;
    int queryStart = -1;

    if (url.startsWith("#") || isExternalURL(url) || isDirectLink(url))
    {
      return url;
    }

    // url might contain DirectLink=false parameter -- spec says remove if
    // it does.
    url = removeDirectLink(url);

    // Now determine the target viewId

    // First: split URL into path and query string
    // Hold onto QueryString for later processing
    queryStart = url.indexOf('?');

    if (queryStart != -1)
    {
      // Get the query string
      queryStr = new QueryString(url.substring(queryStart + 1), "UTF8");
      path = url.substring(0, queryStart);
    }
    else
    {
      path = url;
    }

    // Determine the viewId by inspecting the URL
    if (!isRelativePath(path))
    {
      viewId = getViewIdFromPath(path);
    }
    else
    {
        viewId = getViewIdFromRelativePath(path);
    }

    if (viewId == null)
    {
      throw new FacesException("encodeActionURL:  unable to recognize viewId");
    }

    if (mPhase == Bridge.PortletPhase.RENDER_PHASE)
    { // render - write
      // the viewId into
      // the response
      // (interaction
      // state)
      RenderResponse renderResponse = (RenderResponse) getResponse();
      PortletURL actionURL = renderResponse.createActionURL();
      actionURL.setParameter(ACTION_ID_PARAMETER_NAME, viewId);
     
      // Add extra parameters so they don't get lost
      if (queryStr != null)
      {
        Enumeration<String> list = queryStr.getParameterNames();
        while (list.hasMoreElements())
        {
          String param = list.nextElement().toString();
          if (param.equals(Bridge.PORTLET_MODE_PARAMETER))
          {
            try
            {
              actionURL.setPortletMode(new PortletMode(queryStr.getParameter(param)));
            }
            catch (Exception e)
            {
              ; // do nothing -- just ignore
            }
          }
          else if (param.equals(Bridge.PORTLET_WINDOWSTATE_PARAMETER))
          {
            try
            {
              actionURL.setWindowState(new WindowState(queryStr.getParameter(param)));
            }
            catch (Exception e)
            {
              ; // do nothing -- just ignore
            }
          }
          else if (param.equals(Bridge.PORTLET_SECURE_PARAMETER))
          {
            try
            {
              actionURL.setSecure(Boolean.getBoolean(queryStr.getParameter(param)));
            }
            catch (Exception e)
            {
              ; // do nothing -- just ignore
            }
          }
          else
          {
            actionURL.setParameter(param, queryStr.getParameter(param));
          }
        }
      }

      // TODO hack to workaround double encoding problem
      String actionURLStr = actionURL.toString();
      actionURLStr = actionURLStr.replaceAll("\\&amp\\;", "&");

      return actionURLStr;
    }
    else
    { // action - write the viewId to navigational state
      ActionResponse actionResponse = (ActionResponse) getResponse();

      actionResponse.setRenderParameter(ACTION_ID_PARAMETER_NAME, viewId);

      // set other request params (if any) into navigational states
      if (queryStr != null)
      {
        Enumeration<String> list = queryStr.getParameterNames();
        while (list.hasMoreElements())
        {
          String param = list.nextElement();
          if (param.equals(Bridge.PORTLET_MODE_PARAMETER))
          {
            try
            {
              actionResponse.setPortletMode(new PortletMode(queryStr.getParameter(param)));
            }
            catch (Exception e)
            {
              //TODO: Ignoring is probably dangerous here as it means that we are
              //      EITHER using exceptions for flow control (which is extreemly
              //      inefficient) or we should log a message saying what the issue
              //      is.  According to the Javadocs an exception is thrown here if the
              //      portlet mode is not allowed or if sendRedirect has already been
              //      called.  In either case we should log an information type message
              //      here.
              ; // do nothing -- just ignore
            }
          }
          else if (param.equals(Bridge.PORTLET_WINDOWSTATE_PARAMETER))
          {
            try
            {
              actionResponse.setWindowState(new WindowState(queryStr.getParameter(param)));
            }
            catch (Exception e)
            {
              ; // do nothing -- just ignore
            }
          }
          else if (param.equals(Bridge.PORTLET_SECURE_PARAMETER))
          {
            ; // ignore -- do nothing as can't encode into an actionResponse
          }
          else
          {
            actionResponse.setRenderParameter(param, queryStr.getParameter(param));
          }
        }
      }

      return url;
View Full Code Here

Examples of org.apache.myfaces.portlet.faces.util.QueryString

    // Some viewId may have query string, so handle that here
    // (e.g., TaskFlow has the following viewId:
    // /adf.task-flow?_document=/WEB-INF/task-flow.xml&_id=task1

    int queryStart = viewId.indexOf('?');
    QueryString queryStr = null;

    if (queryStart != -1)
    {
      // parse the query string and add the parameters to internal maps
      // delay the creation of ParameterMap and ParameterValuesMap until
      // they are needed/called by the client
      queryStr = new QueryString(viewId.substring(queryStart + 1), "UTF8");

      // TODO: Constants
      mInternalRequestParameterMap = new HashMap<String, String>(5);
      mInternalRequestParameterValuesMap = new HashMap<String, String[]>(5);

      Enumeration<String> list = queryStr.getParameterNames();
      while (list.hasMoreElements())
      {
        String param = list.nextElement();
        mInternalRequestParameterMap.put(param, queryStr.getParameter(param));
        mInternalRequestParameterValuesMap.put(param, new String[]{queryStr.getParameter(param)});
      }

      viewId = viewId.substring(0, queryStart);
      log("PortletExternalContextImpl.getViewId: special viewId: " + viewId);
    }
View Full Code Here

Examples of org.apache.myfaces.portlet.faces.util.QueryString

  }

  private boolean isDirectLink(String url)
  {
    int queryStart = url.indexOf('?');
    QueryString queryStr = null;
    String directLink = null;

    if (queryStart != -1)
    {
      queryStr = new QueryString(url.substring(queryStart + 1), "UTF8");
      directLink = queryStr.getParameter(Bridge.DIRECT_LINK);
      return Boolean.parseBoolean(directLink);
    }

    return false;
  }
View Full Code Here

Examples of org.apache.myfaces.portlet.faces.util.QueryString

  }

  private String removeDirectLink(String url)
  {
    int queryStart = url.indexOf('?');
    QueryString queryStr = null;
    String directLink = null;

    if (queryStart != -1)
    {
      queryStr = new QueryString(url.substring(queryStart + 1), "UTF8");
      directLink = queryStr.getParameter(Bridge.DIRECT_LINK);
      if (!Boolean.parseBoolean(directLink))
      {
        queryStr.removeParameter(Bridge.DIRECT_LINK);
        String query = queryStr.toString();
        if (query != null && query.length() != 0)
        {
          url = url.substring(0, queryStart + 1) + query;
        }
      }
View Full Code Here

Examples of org.apache.myfaces.portlet.faces.util.QueryString

        (request.getAttribute(Bridge.VIEW_PATH) != null));

    // Now check to see if this is a Refresh (render) that follows a redirect
    // If it is use the redirect information cached in the session as the basis
    // for the request.
    QueryString redirectParams = (QueryString)
              request.getPortletSession(true).getAttribute(BridgeImpl.RENDER_REDIRECT_VIEWPARAMS);
   
    boolean modeChanged = hasModeChanged(request, redirectParams);

    if (redirectParams != null)
View Full Code Here

Examples of org.apache.myfaces.portlet.faces.util.QueryString

      lifecycle.removePhaseListener(this);
    }

    // check here to see if a redirect occurred -- if so rerun doFacesRequest
    // for this new view
    QueryString redirectParams = (QueryString) context.getExternalContext()
            .getRequestMap().get(BridgeImpl.REDIRECT_VIEWPARAMS);
   
    if (redirectParams == null)
    {
      // In resource case and/or redirect overriden responseComplete
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.