Package org.gatein.pc.api.invocation.response

Examples of org.gatein.pc.api.invocation.response.FragmentResponse


        Text markup = null;
        if (pir instanceof FragmentResponse) {
            JavascriptManager jsMan = context.getJavascriptManager();
            jsMan.loadScriptResource(ResourceScope.PORTLET, getApplicationId());

            FragmentResponse fragmentResponse = (FragmentResponse) pir;
            switch (fragmentResponse.getType()) {
                case FragmentResponse.TYPE_CHARS:
                    markup = Text.create(fragmentResponse.getContent());
                    break;
                case FragmentResponse.TYPE_BYTES:
                    markup = Text.create(fragmentResponse.getBytes(), Charset.forName("UTF-8"));
                    break;
                case FragmentResponse.TYPE_EMPTY:
                    markup = Text.create("");
                    break;
            }
            setConfiguredTitle(fragmentResponse.getTitle());

            // setup portlet properties
            if (fragmentResponse.getProperties() != null) {
                // setup transport headers
                if (fragmentResponse.getProperties().getTransportHeaders() != null) {
                    MultiValuedPropertyMap<String> transportHeaders = fragmentResponse.getProperties().getTransportHeaders();
                    for (String key : transportHeaders.keySet()) {
                        if (JAVASCRIPT_DEPENDENCY.equals(key)) {
                            for (String value : transportHeaders.getValues(key)) {
                                jsMan.require(value);
                            }
                        } else {
                            for (String value : transportHeaders.getValues(key)) {
                                prcontext.getResponse().setHeader(key, value);
                            }
                        }
                    }
                }

                // setup up portlet cookies
                if (fragmentResponse.getProperties().getCookies() != null) {
                    List<Cookie> cookies = fragmentResponse.getProperties().getCookies();
                    for (Cookie cookie : cookies) {
                        prcontext.getResponse().addCookie(cookie);
                    }
                }

                // setup markup headers
                if (fragmentResponse.getProperties().getMarkupHeaders() != null) {
                    MultiValuedPropertyMap<Element> markupHeaders = fragmentResponse.getProperties().getMarkupHeaders();

                    List<Element> markupElements = markupHeaders.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
                    if (markupElements != null) {
                        for (Element element : markupElements) {
                            if (!context.useAjax() && "title".equals(element.getNodeName().toLowerCase())
View Full Code Here


        Text markup = null;
        if (pir instanceof FragmentResponse) {
            JavascriptManager jsMan = context.getJavascriptManager();
            jsMan.loadScriptResource(ResourceScope.PORTLET, getApplicationId());

            FragmentResponse fragmentResponse = (FragmentResponse) pir;
            switch (fragmentResponse.getType()) {
                case FragmentResponse.TYPE_CHARS:
                    markup = Text.create(fragmentResponse.getContent());
                    break;
                case FragmentResponse.TYPE_BYTES:
                    markup = Text.create(fragmentResponse.getBytes(), Charset.forName("UTF-8"));
                    break;
                case FragmentResponse.TYPE_EMPTY:
                    markup = Text.create("");
                    break;
            }
            setConfiguredTitle(fragmentResponse.getTitle());

            // setup portlet properties
            if (fragmentResponse.getProperties() != null) {
                // setup transport headers
                if (fragmentResponse.getProperties().getTransportHeaders() != null) {
                    MultiValuedPropertyMap<String> transportHeaders = fragmentResponse.getProperties().getTransportHeaders();
                    for (String key : transportHeaders.keySet()) {
                        if (JAVASCRIPT_DEPENDENCY.equals(key)) {
                            for (String value : transportHeaders.getValues(key)) {
                                jsMan.require(value);
                            }
                        } else {
                            for (String value : transportHeaders.getValues(key)) {
                                prcontext.getResponse().setHeader(key, value);
                            }
                        }
                    }
                }

                // setup up portlet cookies
                if (fragmentResponse.getProperties().getCookies() != null) {
                    List<Cookie> cookies = fragmentResponse.getProperties().getCookies();
                    for (Cookie cookie : cookies) {
                        prcontext.getResponse().addCookie(cookie);
                    }
                }

                // setup markup headers
                if (fragmentResponse.getProperties().getMarkupHeaders() != null) {
                    MultiValuedPropertyMap<Element> markupHeaders = fragmentResponse.getProperties().getMarkupHeaders();

                    List<Element> markupElements = markupHeaders.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
                    if (markupElements != null) {
                        for (Element element : markupElements) {
                            if (!context.useAjax() && "title".equals(element.getNodeName().toLowerCase())
View Full Code Here

   protected PortletInvocationResponse createContentResponse(MarkupContext markupContext, RenderInvocation invocation,
                                                             ResponseProperties properties, Map<String, Object> attributes,
                                                             String mimeType, byte[] bytes, String markup,
                                                             org.gatein.pc.api.cache.CacheControl cacheControl)
   {
      return new FragmentResponse(properties, attributes, mimeType, bytes, markup, markupContext.getPreferredTitle(),
         cacheControl, invocation.getPortalContext().getModes());
   }
View Full Code Here

         PortletInvocationResponse portletResponse = uiPortlet_.invoke(renderInvocation);

         String content;
         if (portletResponse instanceof FragmentResponse)
         {
            FragmentResponse fragmentResponse = (FragmentResponse)portletResponse;
            content = new String(fragmentResponse.getBytes(), "UTF-8");
         }
         else
         {
            PortletContainerException pcException;
View Full Code Here

                   && uicomponent.hasPermission())
               {
                  PortletInvocationResponse response = uicomponent.invoke(renderInvocation);
                  if (response instanceof FragmentResponse)
                  {
                    FragmentResponse fragmentResponse = (FragmentResponse)response;
                    switch (fragmentResponse.getType())
                    {
                    case FragmentResponse.TYPE_CHARS:
                      markup = Text.create(fragmentResponse.getContent());
                      break;
                    case FragmentResponse.TYPE_BYTES:
                      markup = Text.create(fragmentResponse.getBytes(), Charset.forName("UTF-8"));
                      break;
                    case FragmentResponse.TYPE_EMPTY:
                      markup = Text.create("");
                      break;
                    }
                    portletTitle = fragmentResponse.getTitle();

                    // setup portlet properties
                    if (fragmentResponse.getProperties() != null)
                    {
                      //setup transport headers
                      if (fragmentResponse.getProperties().getTransportHeaders() != null)
                      {
                        MultiValuedPropertyMap<String> transportHeaders =
                          fragmentResponse.getProperties().getTransportHeaders();
                        for (String key : transportHeaders.keySet())
                        {
                          for (String value : transportHeaders.getValues(key))
                          {
                            prcontext.getResponse().setHeader(key, value);
                          }
                        }
                      }
                     
                      //setup up portlet cookies
                      if (fragmentResponse.getProperties().getCookies() != null)
                      {
                         List<Cookie> cookies = fragmentResponse.getProperties().getCookies();
                         for (Cookie cookie : cookies)
                         {
                            prcontext.getResponse().addCookie(cookie);
                         }
                      }

                      //setup markup headers
                      if (fragmentResponse.getProperties().getMarkupHeaders() != null)
                      {
                        MultiValuedPropertyMap<Element> markupHeaders =
                          fragmentResponse.getProperties().getMarkupHeaders();

                        List<Element> markupElements = markupHeaders.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
                        if (markupElements != null)
                        {
                          for (Element element : markupElements)
View Full Code Here

      }

      // generate appropriate CacheControl
      org.gatein.pc.api.cache.CacheControl cacheControl = createCacheControl(markupContext);

      FragmentResponse result = new FragmentResponse(null, null, mimeType, null, markup,
         markupContext.getPreferredTitle(), cacheControl, invocation.getPortalContext().getModes());

      log.debug("Response processed");
      return result;
   }
View Full Code Here

    public Text generateRenderMarkup(PortletInvocationResponse pir, WebuiRequestContext context) {
        PortalRequestContext prcontext = (PortalRequestContext) context;

        Text markup = null;
        if (pir instanceof FragmentResponse) {
            FragmentResponse fragmentResponse = (FragmentResponse) pir;
            switch (fragmentResponse.getType()) {
                case FragmentResponse.TYPE_CHARS:
                    markup = Text.create(fragmentResponse.getContent());
                    break;
                case FragmentResponse.TYPE_BYTES:
                    markup = Text.create(fragmentResponse.getBytes(), Charset.forName("UTF-8"));
                    break;
                case FragmentResponse.TYPE_EMPTY:
                    markup = Text.create("");
                    break;
            }
            setConfiguredTitle(fragmentResponse.getTitle());

            // setup portlet properties
            if (fragmentResponse.getProperties() != null) {
                // setup transport headers
                if (fragmentResponse.getProperties().getTransportHeaders() != null) {
                    MultiValuedPropertyMap<String> transportHeaders = fragmentResponse.getProperties().getTransportHeaders();
                    for (String key : transportHeaders.keySet()) {
                        JavascriptManager jsMan = context.getJavascriptManager();
                        if (JAVASCRIPT_DEPENDENCY.equals(key)) {
                            for (String value : transportHeaders.getValues(key)) {
                                jsMan.require(value);
                            }
                        } else {
                            for (String value : transportHeaders.getValues(key)) {
                                prcontext.getResponse().setHeader(key, value);
                            }
                        }
                    }
                }

                // setup up portlet cookies
                if (fragmentResponse.getProperties().getCookies() != null) {
                    List<Cookie> cookies = fragmentResponse.getProperties().getCookies();
                    for (Cookie cookie : cookies) {
                        prcontext.getResponse().addCookie(cookie);
                    }
                }

                // setup markup headers
                if (fragmentResponse.getProperties().getMarkupHeaders() != null) {
                    MultiValuedPropertyMap<Element> markupHeaders = fragmentResponse.getProperties().getMarkupHeaders();

                    List<Element> markupElements = markupHeaders.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
                    if (markupElements != null) {
                        for (Element element : markupElements) {
                            if (!context.useAjax() && "title".equals(element.getNodeName().toLowerCase())
View Full Code Here

   {

      // encoding should be ignored here TODO: check that this is true
      if (markup != null)
      {
         return new FragmentResponse(properties, null, mimeType, null, markup, markupContext.getPreferredTitle(), cacheControl, invocation.getPortalContext().getModes());
      }
      else
      {
         return new FragmentResponse(properties, null, mimeType, null, bytes, markupContext.getPreferredTitle(), cacheControl, invocation.getPortalContext().getModes());
      }
   }
View Full Code Here

               if (portalMode % 2 == 0 || uicomponent.getCurrentPortletMode().equals(PortletMode.EDIT))
               {
                  PortletInvocationResponse response = uicomponent.invoke(renderInvocation);
                  if (response instanceof FragmentResponse)
                  {
                    FragmentResponse fragmentResponse = (FragmentResponse)response;
                    switch (fragmentResponse.getType())
                    {
                    case FragmentResponse.TYPE_CHARS:
                      markup = Text.create(fragmentResponse.getContent());
                      break;
                    case FragmentResponse.TYPE_BYTES:
                      markup = Text.create(fragmentResponse.getBytes(), Charset.forName("UTF-8"));
                      break;
                    case FragmentResponse.TYPE_EMPTY:
                      markup = Text.create("");
                      break;
                    }
                    portletTitle = fragmentResponse.getTitle();

                    // setup portlet properties
                    if (fragmentResponse.getProperties() != null)
                    {
                      //setup transport headers
                      if (fragmentResponse.getProperties().getTransportHeaders() != null)
                      {
                        MultiValuedPropertyMap<String> transportHeaders =
                          fragmentResponse.getProperties().getTransportHeaders();
                        for (String key : transportHeaders.keySet())
                        {
                          for (String value : transportHeaders.getValues(key))
                          {
                            prcontext.getResponse().setHeader(key, value);
                          }
                        }
                      }
                     
                      //setup up portlet cookies
                      if (fragmentResponse.getProperties().getCookies() != null)
                      {
                         List<Cookie> cookies = fragmentResponse.getProperties().getCookies();
                         for (Cookie cookie : cookies)
                         {
                            prcontext.getResponse().addCookie(cookie);
                         }
                      }

                      //setup markup headers
                      if (fragmentResponse.getProperties().getMarkupHeaders() != null)
                      {
                        MultiValuedPropertyMap<Element> markupHeaders =
                          fragmentResponse.getProperties().getMarkupHeaders();

                        List<Element> markupElements = markupHeaders.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
                        if (markupElements != null)
                        {
                          for (Element element : markupElements)
View Full Code Here

         PortletInvocationResponse portletResponse = uiPortlet_.invoke(renderInvocation);

         String content;
         if (portletResponse instanceof FragmentResponse)
         {
            FragmentResponse fragmentResponse = (FragmentResponse)portletResponse;
            content = fragmentResponse.getContent();
         }
         else
         {
            PortletContainerException pcException;
View Full Code Here

TOP

Related Classes of org.gatein.pc.api.invocation.response.FragmentResponse

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.