Package javax.portlet

Examples of javax.portlet.PortletRequest


     *
     * @see org.apache.velocity.tools.view.servlet.VelocityViewServlet#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context)
     */
    protected Template handleRequest(HttpServletRequest request, HttpServletResponse response, Context ctx) throws Exception
    {
        PortletRequest renderRequest = (PortletRequest) request.getAttribute(PORTLET_REQUEST);
        RenderResponse renderResponse = (RenderResponse) request.getAttribute(PORTLET_RESPONSE);
        PortletConfig portletConfig = (PortletConfig) request.getAttribute(PORTLET_CONFIG);
       
        if (renderRequest != null)
        {
            renderRequest.setAttribute(VELOCITY_CONTEXT_ATTR, ctx);
            Context portletContext = (Context)renderRequest.getAttribute(GenericVelocityPortlet.PORTLET_BRIDGE_CONTEXT);
            if (portletContext != null)
            {
                // merge in portletContext
                Object[] keys = portletContext.getKeys();
                for (int ix = 0; ix < keys.length; ix++)
View Full Code Here


    String portletWindowPrefix;

    public static HttpSession createProxy(HttpServletRequest request)
    {
        HttpSession servletSession = request.getSession();
        PortletRequest portletRequest = (PortletRequest) request.getAttribute("javax.portlet.request");
        if (portletRequest != null)
        {
            PortletSession portletSession = portletRequest.getPortletSession();
            servletSession = (HttpSession)createProxy(request, "javax.portlet.p."+PortletWindowUtils.getPortletWindowId(portletSession));
        }
        return servletSession;
    }
View Full Code Here

    }

    public UIViewRoot resolveViewRoot(String defaultViewName, PortletRequest portletRequest)
    {
        // shoot: can't get the entity id and be portable
        PortletRequest request = (PortletRequest) externalContext.getRequest();
        String viewId = request.getParameter(JSF_VIEW_ID);

        if (viewId == null)
        {
            viewId = defaultViewName;
            if (log.isDebugEnabled())
            {
                log.debug("Request view id is null.  Using default view.");
            }
        }
        if (log.isDebugEnabled())
        {
            log.debug("Resolving view root - Using view id: " + viewId);
        }

        String requestType = (String)portletRequest.getAttribute(FacesPortlet.REQUEST_TYPE);
        if (requestType != null && requestType.equals(FacesPortlet.ACTION_REQUEST))
        {
            if (log.isDebugEnabled())
            {
                log.debug("Resolving action: " + viewId);
            }
            setViewRoot(viewRoot);
            portletRequest.setAttribute(FacesPortlet.REQUEST_SERVLET_PATH, viewId.replaceAll(".jsp", ".jsf"));
            return null;
        }

        UIViewRoot viewRoot = (UIViewRoot) request.getPortletSession().getAttribute(viewId,
                PortletSession.PORTLET_SCOPE);
        if (null == viewRoot)
        {
            if (log.isDebugEnabled())
            {
                log.debug("Creating new view root: " + viewId);
            }
            viewRoot = application.getViewHandler().createView(this, viewId);
            //viewRoot = new UIViewRoot();
            UIViewRoot newViewRoot = new PortletUIViewRoot(viewRoot);
            viewRoot = newViewRoot;
            viewRoot.setViewId(viewId);
            viewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
            request.getPortletSession().setAttribute(viewId, viewRoot, PortletSession.PORTLET_SCOPE);
        }
        else
        {
            if (log.isDebugEnabled())
            {
View Full Code Here

    }

    private String createViewRootKey(FacesContext context, String defaultView,
            String viewId)
    {
        PortletRequest portletRequest = (PortletRequest) context
                .getExternalContext().getRequest();
        // String view = portletRequest.getParameter(viewId);
        String view = (String) portletRequest.getPortletSession().getAttribute(
                viewId, PortletSession.PORTLET_SCOPE);

        if (view == null)
        {
            view = defaultView;
View Full Code Here

    private void setDefaultView(FacesContext facesContext, String defaultView,
            String viewId)
    {
        // Need to be able to transport viewId between actionRequest and
        // renderRequest.
        PortletRequest portletRequest = (PortletRequest) facesContext
                .getExternalContext().getRequest();
        if (portletRequest instanceof ActionRequest)
        {
            String view = (String) portletRequest.getPortletSession()
                    .getAttribute(viewId, PortletSession.PORTLET_SCOPE);

            if ((null != facesContext.getViewRoot())
                    && (null != facesContext.getViewRoot().getViewId()))
            {
                defaultView = facesContext.getViewRoot().getViewId();
            }
            // else if (null != portletRequest.getParameter(viewId))
            else if (null != view)
            {
                // defaultView = portletRequest.getParameter(viewId);
                defaultView = view;
            }

            UIViewRoot viewRoot = (UIViewRoot) portletRequest
                    .getPortletSession()
                    .getAttribute(
                            createViewRootKey(facesContext, defaultView, viewId));
            if (viewRoot != null)
            {
                facesContext.setViewRoot(viewRoot);
                defaultView = facesContext.getViewRoot().getViewId();
            } else
            {
                facesContext.setViewRoot(new PortletUIViewRoot());
                facesContext.getViewRoot().setViewId(view);
                facesContext.getViewRoot().setRenderKitId(
                        facesContext.getApplication().getDefaultRenderKitId());
                portletRequest.getPortletSession().setAttribute(
                        createViewRootKey(facesContext, view, viewId),
                        facesContext.getViewRoot());
            }
            portletRequest.setAttribute(REQUEST_SERVLET_PATH, defaultView
                    .replaceAll("[.]jsp", ".jsf"));
        } else if (portletRequest instanceof RenderRequest)
        {
            // String view = portletRequest.getParameter(viewId);
            String view = (String) portletRequest.getPortletSession()
                    .getAttribute(viewId, PortletSession.PORTLET_SCOPE);

            if (null == facesContext.getViewRoot())
            {
                if (view == null)
                {
                    view = defaultView;
                }
                UIViewRoot viewRoot = (UIViewRoot) portletRequest
                        .getPortletSession().getAttribute(
                                createViewRootKey(facesContext, view, viewId));
                if (null != viewRoot)
                {
                    facesContext.setViewRoot(viewRoot);
                    defaultView = facesContext.getViewRoot().getViewId();
                } else
                {
                    facesContext.setViewRoot(new PortletUIViewRoot());
                    facesContext.getViewRoot().setViewId(view);
                    facesContext.getViewRoot().setRenderKitId(
                            facesContext.getApplication().getDefaultRenderKitId());
                    portletRequest.getPortletSession().setAttribute(
                            createViewRootKey(facesContext, view, viewId),
                            facesContext.getViewRoot());
                }
            }
            portletRequest.setAttribute(REQUEST_SERVLET_PATH, view.replaceAll(
                    ".jsp", ".jsf"));
        }
    }
View Full Code Here

   
    public String save()
    {
        if (this.date != null)
        {
            PortletRequest request = (PortletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
            PortletPreferences prefs = request.getPreferences();
            try
            {
               
                prefs.setValue(getDateKey(this.date), this.notes);
                prefs.store();
View Full Code Here

        if (this.date == null)
        {
            return "editNotes";
        }
        String selectedDate = getDateKey(this.date);
        PortletRequest request = (PortletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
        notes = request.getPreferences().getValue(selectedDate, "");
        return "editNotes"; // goto the navigation rule
    }
View Full Code Here

    {
        ExternalContext externalContext = facesContext.getExternalContext();

        if (PortletUtil.isPortletRequest(facesContext))
        {
            PortletRequest request = (PortletRequest)externalContext.getRequest();
            return request.getParameter(MyFacesGenericPortlet.VIEW_ID);
        }

        String viewId = externalContext.getRequestPathInfo()//getPathInfo
        if (viewId == null)
        {
View Full Code Here

   */
  public void testGetAttributes() {
    try {
      Map map = null;
      UserInfoAttributesServiceImpl uias = UserInfoAttributesServiceImpl.getInstance(props);
      PortletRequest pr = new MockPortletRequest();
      map = uias.getAttributes(pr);
      String sex = (String)map.get(P3PAttributes.USER_GENDER);
      assertTrue(sex.equals(TEST_USER_GENDER));
      System.out.println("Sex: " + sex);
      String fname = (String)map.get(P3PAttributes.USER_NAME_GIVEN);
View Full Code Here

    /**
     * Processes the <CODE>defineObjects</CODE> tag.
     * @return <CODE>SKIP_BODY</CODE>
     */
    public int doStartTag() throws JspException {
        PortletRequest renderRequest = (PortletRequest) pageContext.getRequest()
            .getAttribute(Constants.PORTLET_REQUEST);
        RenderResponse renderResponse = (RenderResponse) pageContext.getRequest()
            .getAttribute(Constants.PORTLET_RESPONSE);
        PortletConfig portletConfig = (PortletConfig) pageContext.getRequest()
            .getAttribute(Constants.PORTLET_CONFIG);
View Full Code Here

TOP

Related Classes of javax.portlet.PortletRequest

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.