Package javax.portlet

Examples of javax.portlet.ResourceURL


   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            ResourceURL resourceURL = response.createResourceURL();
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals("GET", request.getMethod());
            ResourceURL resourceURL = response.createResourceURL();
            InvokePostResponse post = new InvokePostResponse(resourceURL.toString());
            post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
            post.setBody(new Body.Form());
            return post;
         }
      });
View Full Code Here


   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            ResourceURL resourceURL = response.createResourceURL();
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertNull(request.getResourceID());
            ResourceURL resourceURL = response.createResourceURL();
            resourceURL.setResourceID("foo_resource_id");
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
View Full Code Here

   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            ResourceURL url = response.createResourceURL();

            //
            url.setParameter("resource", new String[]{"resource_value"});

            //
            return new InvokeGetResponse(url.toString());
         }
      });
      seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String[]> expectedParameters = Collections.singletonMap("resource", new String[]{"resource_value"});
            assertParameterMap(expectedParameters, request);
            assertParameterMap(expectedParameters, request.getPrivateParameterMap());
            assertParameterMap(new HashMap<String, String[]>(), request.getPrivateRenderParameterMap());
            assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());

            //
            ResourceURL url = response.createResourceURL();

            //
            url.setParameter("resource", new String[]{"resource_value"});
            url.setParameter("resource_form", new String[]{"resource_form_value1"});

            //
            InvokePostResponse post = new InvokePostResponse(url.toString());
            post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
            Body.Form form = new Body.Form();
            form.addParameter("form", new String[]{"form_value"});
            form.addParameter("resource_form", new String[]{"resource_form_value2"});
            post.setBody(form);

            //
            return post;
         }
      });
      seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
            expectedParameters.put("resource", new String[]{"resource_value"});
            expectedParameters.put("resource_form", new String[]{"resource_form_value1", "resource_form_value2"});
            expectedParameters.put("form", new String[]{"form_value"});
            assertParameterMap(expectedParameters, request);
            assertParameterMap(expectedParameters, request.getPrivateParameterMap());
            assertParameterMap(new HashMap<String, String[]>(), request.getPrivateRenderParameterMap());
            assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());

            //
            PortletURL renderURL = response.createRenderURL();
            renderURL.setParameter("render", "render_value");
            renderURL.setParameter("resource_render", "resource_render_value2");
            renderURL.setParameter("form_render", "form_render_value2");
            renderURL.setParameter("resource_form_render", "resource_form_render_value3");

            //
            return new InvokeGetResponse(renderURL.toString());
         }
      });
      seq.bindAction(3, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            ResourceURL url = response.createResourceURL();

            //
            url.setParameter("resource", new String[]{"resource_value"});
            url.setParameter("resource_render", new String[]{"resource_render_value1"});

            //
            return new InvokeGetResponse(url.toString());
         }
      });
      seq.bindAction(4, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
            expectedParameters.put("resource", new String[]{"resource_value"});
            expectedParameters.put("resource_render", new String[]{"resource_render_value1","resource_render_value2"});
            expectedParameters.put("render", new String[]{"render_value"});
            expectedParameters.put("form_render", new String[]{"form_render_value2"});
            expectedParameters.put("resource_form_render", new String[]{"resource_form_render_value3"});
            Map<String, String[]> expectedPrivateRenderParameters = new HashMap<String, String[]>();
            expectedPrivateRenderParameters.put("render", new String[]{"render_value"});
            expectedPrivateRenderParameters.put("resource_render", new String[]{"resource_render_value2"});
            expectedPrivateRenderParameters.put("form_render", new String[]{"form_render_value2"});
            expectedPrivateRenderParameters.put("resource_form_render", new String[]{"resource_form_render_value3"});
            assertParameterMap(expectedParameters, request);
            assertParameterMap(expectedParameters, request.getPrivateParameterMap());
            assertParameterMap(expectedPrivateRenderParameters, request.getPrivateRenderParameterMap());
            assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());

            //
            ResourceURL url = response.createResourceURL();

            //
            url.setParameter("resource", new String[]{"resource_value"});
            url.setParameter("resource_form", new String[]{"resource_form_value1"});
            url.setParameter("resource_render", new String[]{"resource_render_value1"});
            url.setParameter("resource_form_render", new String[]{"resource_form_render_value1"});

            //
            InvokePostResponse post = new InvokePostResponse(url.toString());
            post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
            Body.Form form = new Body.Form();
            form.addParameter("form", new String[]{"form_value"});
            form.addParameter("resource_form", new String[]{"resource_form_value2"});
            form.addParameter("form_render", new String[]{"form_render_value1"});
            form.addParameter("resource_form_render", new String[]{"resource_form_render_value2"});
            post.setBody(form);

            //
            return post;
         }
      });
      seq.bindAction(5, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String[]> expectedParameters = new HashMap<String, String[]>();
            expectedParameters.put("resource", new String[]{"resource_value"});
            expectedParameters.put("resource_form", new String[]{"resource_form_value1","resource_form_value2"});
            expectedParameters.put("resource_render", new String[]{"resource_render_value1","resource_render_value2"});
            expectedParameters.put("resource_form_render", new String[]{"resource_form_render_value1","resource_form_render_value2","resource_form_render_value3"});
            expectedParameters.put("form", new String[]{"form_value"});
            expectedParameters.put("form_render", new String[]{"form_render_value1","form_render_value2"});
            expectedParameters.put("render", new String[]{"render_value"});
            Map<String, String[]> expectedPrivateRenderParameters = new HashMap<String, String[]>();
            expectedPrivateRenderParameters.put("render", new String[]{"render_value"});
            expectedPrivateRenderParameters.put("resource_render", new String[]{"resource_render_value2"});
            expectedPrivateRenderParameters.put("form_render", new String[]{"form_render_value2"});
            expectedPrivateRenderParameters.put("resource_form_render", new String[]{"resource_form_render_value3"});
            assertParameterMap(expectedParameters, request);
            assertParameterMap(expectedParameters, request.getPrivateParameterMap());
            assertParameterMap(expectedPrivateRenderParameters, request.getPrivateRenderParameterMap());
            assertParameterMap(new HashMap<String, String[]>(), request.getPublicParameterMap());

            //
            PortletURL renderURL = response.createRenderURL();
            renderURL.setParameter("render", "render_value");
            renderURL.setParameter("resource_render", "resource_render_value2");
            renderURL.setParameter("form_render", "form_render_value2");
            renderURL.setParameter("resource_form_render", "resource_form_render_value3");
            renderURL.setParameter("public", "public_value");
            renderURL.setParameter("resource_public", "resource_public_value2");
            renderURL.setParameter("form_public", "form_public_value2");
            renderURL.setParameter("resource_form_public", "resource_form_public_value3");

            //
            return new InvokeGetResponse(renderURL.toString());
         }
      });
      seq.bindAction(6, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            //
            ResourceURL url = response.createResourceURL();

            //
            url.setParameter("resource", new String[]{"resource_value"});
            url.setParameter("resource_form", new String[]{"resource_form_value1"});
            url.setParameter("resource_render", new String[]{"resource_render_value1"});
            url.setParameter("resource_form_render", new String[]{"resource_form_render_value1"});
            url.setParameter("resource_public", new String[]{"resource_public_value1"});
            url.setParameter("resource_form_public", new String[]{"resource_form_public_value1"});

            //
            InvokePostResponse post = new InvokePostResponse(url.toString());
            post.setContentType(InvokePostResponse.APPLICATION_X_WWW_FORM_URLENCODED);
            Body.Form form = new Body.Form();
            form.addParameter("form", new String[]{"form_value"});
            form.addParameter("resource_form", new String[]{"resource_form_value2"});
            form.addParameter("form_render", new String[]{"form_render_value1"});
View Full Code Here

      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            blah = response.createRenderURL().toString();

            ResourceURL resourceURL = response.createResourceURL();
            resourceURL.setResourceID("blah");
            resourceURL.setParameter("foo", "bar");
            String s = resourceURL.toString();
            return new InvokeGetResponse(s);
         }
      });
      seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
View Full Code Here

         {
            response.setContentType("text/html");
            PortletRequestDispatcher dispatcher = ((AbstractUniversalTestPortlet)portlet).getPortletContext().
               getRequestDispatcher("/resourceURL.jsp");

            ResourceURL pu1 = response.createResourceURL();

            pu1.setSecure(true);
            pu1.setCacheability(ResourceURL.FULL);

            ResourceURL pu2 = response.createResourceURL();

            pu2.setSecure(true);
            pu2.setResourceID("testId1");


            ResourceURL pu3 = response.createResourceURL();
            pu3.setSecure(false);

            pu3.setParameter("testParam", new String[]{"testParamValue", "testParamValue2"});
            pu3.setParameter("secondParam", "testParamValue");
            pu3.setProperty("testProperty", "testPropValue");
            pu3.setProperty("testProperty", "testPropValue2");
            pu3.setProperty("secondProperty", "testPropValue");


            StringWriter sw = new StringWriter();

            // Create session
            request.getPortletSession();

            // escapeXml=true
            pu1.write(sw, true);
            String url1 = response.encodeURL(sw.toString());

            sw = new StringWriter();

            // escapeXml=true
            pu2.write(sw, true);
            String url2 = response.encodeURL(sw.toString());

            sw = new StringWriter();

            // escapeXml=false
            pu3.write(sw, false);
            String url3 = response.encodeURL(sw.toString());


            expectedResults = new String[]{url1, url2, url3};
View Full Code Here

   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            ResourceURL resourceURL = response.createResourceURL();
            assertEquals(ResourceURL.PAGE, resourceURL.getCacheability());
            try
            {
               resourceURL.setCacheability(null);
               fail();
            }
            catch (IllegalArgumentException ignore)
            {
            }
            try
            {
               resourceURL.setCacheability("inexistent");
               fail();
            }
            catch (IllegalArgumentException ignore)
            {
            }
            resourceURL.setCacheability(ResourceURL.PORTLET);
            assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(1, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals(ResourceURL.PORTLET, request.getCacheability());

            //
            try
            {
               response.createActionURL();
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }

            //
            try
            {
               response.createRenderURL();
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }

            //
            ResourceURL resourceURL = response.createResourceURL();
            assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());

            //
            try
            {
               resourceURL.setCacheability(ResourceURL.PAGE);
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }
            assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());

            //
            resourceURL.setCacheability(ResourceURL.PORTLET);
            assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());

            //
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(2, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals(ResourceURL.PORTLET, request.getCacheability());
            ResourceURL resourceURL = response.createResourceURL();
            assertEquals(ResourceURL.PORTLET, resourceURL.getCacheability());
            resourceURL.setCacheability(ResourceURL.FULL);
            assertEquals(ResourceURL.FULL, resourceURL.getCacheability());
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(3, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals(ResourceURL.FULL, request.getCacheability());

            //
            try
            {
               response.createActionURL();
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }

            //
            try
            {
               response.createRenderURL();
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }

            //
            ResourceURL resourceURL = response.createResourceURL();
            assertEquals(ResourceURL.FULL, resourceURL.getCacheability());

            //
            try
            {
               resourceURL.setCacheability(ResourceURL.PORTLET);
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }
            assertEquals(ResourceURL.FULL, resourceURL.getCacheability());

            //
            try
            {
               resourceURL.setCacheability(ResourceURL.PAGE);
               fail();
            }
            catch (IllegalStateException ignore)
            {
            }
            assertEquals(ResourceURL.FULL, resourceURL.getCacheability());

            //
            resourceURL.setCacheability(ResourceURL.FULL);
            assertEquals(ResourceURL.FULL, resourceURL.getCacheability());

            //
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(4, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertEquals(ResourceURL.FULL, request.getCacheability());
            ResourceURL resourceURL = response.createResourceURL();
            assertEquals(ResourceURL.FULL, resourceURL.getCacheability());
            return new EndTestResponse();
         }
      });
   }
View Full Code Here

      });
      seq.bindAction(1, UTP4.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            ResourceURL resourceURL = response.createResourceURL();
            resourceURL.setParameter("foo", new String[]{"resource_foo_value1","resource_foo_value2"});
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(2, UTP4.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
         {
            Map<String, String[]> expectedPageParameters = new HashMap<String, String[]>();
            expectedPageParameters.put("foo", new String[]{"resource_foo_value1","resource_foo_value2","render_foo_value1","render_foo_value2"});
            assertParameterMap(expectedPageParameters, request);

            //
            ResourceURL resourceURL = response.createResourceURL();
            resourceURL.setCacheability(ResourceURL.PORTLET);
            resourceURL.setParameter("foo", new String[]{"resource_foo_value3","resource_foo_value4"});
            return new InvokeGetResponse(resourceURL.toString());
         }
      });
      seq.bindAction(3, UTP4.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
View Full Code Here

            assertEquals(scopeId, request.getParameter(PortletRequest.ACTION_SCOPE_ID));
            Object bar = request.getAttribute("foo");
            assertEquals("bar", bar);

            //
            ResourceURL url = response.createResourceURL();
            url.setCacheability(ResourceURL.PORTLET);
            return new InvokeGetResponse(url.toString());
         }
      });
      seq.bindAction(3, UTP1.RESOURCE_JOIN_POINT, new PortletResourceTestAction()
      {
         protected Response run(Portlet portlet, ResourceRequest request, ResourceResponse response, PortletTestContext context) throws PortletException, IOException
View Full Code Here

    ExternalContext externalContext = facesContext.getExternalContext();
    MimeResponse mimeResponse = (MimeResponse) externalContext.getResponse();
    Map<String, Object> attributes = uiComponent.getAttributes();
    PortletURL portletURL = (PortletURL) mimeResponse.createResourceURL();
    ResourceURL resourceURL = (ResourceURL) portletURL;
    String id = (String) attributes.get(StringPool.ID);
    String cacheability = (String) attributes.get("cacheability");

    try {

      if (id != null) {
        resourceURL.setResourceID(id);
      }

      if (cacheability != null) {
        resourceURL.setCacheability(cacheability);
      }
      else {
        resourceURL.setCacheability(ResourceURL.PAGE);
      }

      super.encodeEnd(facesContext, uiComponent, resourceURL);
    }
    catch (Exception e) {
View Full Code Here

    // an appropriate ResourceURL.
    else if (inProtocol) {

      // TCK TestPage071: nonFacesResourceTest
      String urlWithModifiedParameters = _toString(false);
      ResourceURL resourceURL = portletContainer.createResourceURL(urlWithModifiedParameters);
      resourceURL.setResourceID(getContextRelativePath());
      baseURL = resourceURL;
    }

    // Otherwise, assume that the URL is for an resource external to the portlet context like
    // "/portalcontext/resources/foo.png" and return a BaseURL string representation of it.
View Full Code Here

TOP

Related Classes of javax.portlet.ResourceURL

Copyright © 2018 www.massapicom. 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.