Package javax.portlet

Examples of javax.portlet.PortletRequest


        if (!(request instanceof VaadinPortletRequest)) {
            throw new IllegalArgumentException(
                    "Request is not a VaadinPortletRequest");
        }

        PortletRequest portletRequest = ((VaadinPortletRequest) request)
                .getPortletRequest();
        if (portletRequest instanceof RenderRequest) {
            // In most cases the first request is a render request that
            // renders the HTML fragment. This should create a Vaadin
            // session unless there is already one.
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

     *
     * @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

   
    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

    }

    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);
        }

        if (portletRequest instanceof ActionRequest)
        {
            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();
            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();
            }
           
            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 UIViewRoot());
                    facesContext.getViewRoot().setViewId(view);
                    facesContext.getViewRoot().setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
                    portletRequest.getPortletSession().setAttribute(createViewRootKey(facesContext, view, viewId), viewRoot);
                }                  
            }
            portletRequest.setAttribute(REQUEST_SERVLET_PATH, view.replaceAll(".jsp", ".jsf"));
        }
       
    }
View Full Code Here

public class CaptchaValidator extends AbstractValidator implements Serializable {

    @Override
    protected boolean isValid(String value, UIFormInput uiInput) {
        PortletRequestContext ctx = PortletRequestContext.getCurrentInstance();
        PortletRequest req = ctx.getRequest();
        PortletSession session = req.getPortletSession();

        Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);

        return ((captcha != null) && (captcha.isCorrect(value)));
    }
View Full Code Here

    private final String id;

    public UIGroovyPortlet() throws Exception {
        PortletRequestContext context = (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
        PortletRequest prequest = context.getRequest();
        template_ = prequest.getPreferences().getValue("template", DEFAULT_TEMPLATE);
        windowId = prequest.getWindowID();
        id = windowId + "-portlet";
    }
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.