当前位置: 首页>>代码示例>>Java>>正文


Java PortletRequestDispatcher类代码示例

本文整理汇总了Java中javax.portlet.PortletRequestDispatcher的典型用法代码示例。如果您正苦于以下问题:Java PortletRequestDispatcher类的具体用法?Java PortletRequestDispatcher怎么用?Java PortletRequestDispatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PortletRequestDispatcher类属于javax.portlet包,在下文中一共展示了PortletRequestDispatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doServeResource

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
        throws Exception {
    
    String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);

    PortletRequestDispatcher portletRequestDispatcher = null;

    if (cmd.equals(Constants.IMPORT)) {
        portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest, "/import/processes_list/view.jsp");
    } else {
        portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest,
                "/import/new_import/import_task_records_resources.jsp");
    }

    portletRequestDispatcher.include(resourceRequest, resourceResponse);
}
 
开发者ID:inofix,项目名称:ch-inofix-timetracker,代码行数:18,代码来源:ImportTaskRecordsMVCResourceCommand.java

示例2: doServeResource

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
@Override
protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
        throws Exception {
    
    String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);

    PortletRequestDispatcher portletRequestDispatcher = null;

    if (cmd.equals(Constants.IMPORT)) {
        portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest, "/import/processes_list/view.jsp");
    } else {
        portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest,
                "/import/new_import/import_contacts_resources.jsp");
    }

    portletRequestDispatcher.include(resourceRequest, resourceResponse);
}
 
开发者ID:inofix,项目名称:ch-inofix-contact-manager,代码行数:18,代码来源:ImportContactsMVCResourceCommand.java

示例3: doServeResource

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
@Override
    protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
            throws Exception {
        
//        _log.info("doServeResource()");

        String cmd = ParamUtil.getString(resourceRequest, Constants.CMD);

//        _log.info("cmd = " + cmd);

        PortletRequestDispatcher portletRequestDispatcher = null;

        if (cmd.equals(Constants.IMPORT)) {
            portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest, "/import/processes_list/view.jsp");
        } else {
            portletRequestDispatcher = getPortletRequestDispatcher(resourceRequest,
                    "/import/new_import/import_measurements_resources.jsp");
        }

        portletRequestDispatcher.include(resourceRequest, resourceResponse);
    }
 
开发者ID:inofix,项目名称:ch-inofix-data-manager,代码行数:22,代码来源:ImportMeasurementsMVCResourceCommand.java

示例4: serveResource

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
/**
 * Serve the resource as specified in the given request to the given response,
 * using the PortletContext's request dispatcher.
 * <p>This is roughly equivalent to Portlet 2.0 GenericPortlet.
 * @param request the current resource request
 * @param response the current resource response
 * @param context the current Portlet's PortletContext
 * @throws PortletException propagated from Portlet API's forward method
 * @throws IOException propagated from Portlet API's forward method
 */
public static void serveResource(ResourceRequest request, ResourceResponse response, PortletContext context)
		throws PortletException, IOException {

	String id = request.getResourceID();
	if (id != null) {
		if (!PortletUtils.isProtectedResource(id)) {
			PortletRequestDispatcher rd = context.getRequestDispatcher(id);
			if (rd != null) {
				rd.forward(request, response);
				return;
			}
		}
		response.setProperty(ResourceResponse.HTTP_STATUS_CODE, "404");
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:PortletUtils.java

示例5: perform

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
public void perform(TaskRequest req, TaskResponse res) {

		RenderRequest preq = (RenderRequest) request.evaluate(req, res);
		RenderResponse pres = (RenderResponse) response.evaluate(req, res);
		String rsc = (String) resource.evaluate(req, res);

		try {

			// Load the PortletRequest...
			for (String key : req.getAttributeNames()) {
				preq.setAttribute(key, req.getAttribute(key));
			}

			PortletRequestDispatcher prd = preq.getPortletSession(true).getPortletContext().getRequestDispatcher(rsc);
			prd.include(preq, pres);

		} catch (Throwable t) {
			String msg = "Error dispatching to the specified resource:  " + rsc;
			throw new RuntimeException(msg, t);
		}

	}
 
开发者ID:drewwills,项目名称:cernunnos,代码行数:23,代码来源:RequestDispatcherTask.java

示例6: doView

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
@Override
protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
    AccessToken accessToken = getAccessToken();
    final Twitter twitter = getOAuthProvider().getAuthorizedSocialApiObject(accessToken, Twitter.class);

    User twitterUser = new TwitterPortletRequest<User>(request, response, getPortletContext(), getOAuthProvider()) {

        @Override
        protected User invokeRequest() throws TwitterException {
            return twitter.verifyCredentials();
        }

    }.executeRequest();

    if (twitterUser != null) {
        request.setAttribute("twitterUserInfo", twitterUser);
        PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/jsp/twitter/userinfo.jsp");
        prd.include(request, response);
    }
}
 
开发者ID:exo-samples,项目名称:docs-samples,代码行数:21,代码来源:TwitterPortlet.java

示例7: executeRequest

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
public T executeRequest() throws IOException, PortletException {
    try {
        return invokeRequest();
    } catch (TwitterException te) {
        String jspErrorPage;
        if (te.getStatusCode() == 401) {
            request.setAttribute(OAuthPortletFilter.ATTRIBUTE_ERROR_MESSAGE, "Twitter access token is invalid.");
            request.setAttribute(OAuthPortletFilter.ATTRIBUTE_OAUTH_PROVIDER, oauthProvider);
            jspErrorPage = "/jsp/error/token.jsp";
        } else {
            request.setAttribute(OAuthPortletFilter.ATTRIBUTE_ERROR_MESSAGE, getErrorMessage(te));
            jspErrorPage = "/jsp/error/error.jsp";
        }

        System.err.println(getErrorMessage(te));
        PortletRequestDispatcher prd = portletContext.getRequestDispatcher(jspErrorPage);
        prd.include(request, response);
    }

    return null;
}
 
开发者ID:exo-samples,项目名称:docs-samples,代码行数:22,代码来源:TwitterPortletRequest.java

示例8: doView

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
@Override
protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
    AccessToken accessToken = getAccessToken();
    final Oauth2 service = getOAuthProvider().getAuthorizedSocialApiObject(accessToken, Oauth2.class);

    Userinfo userInfo = new GooglePortletRequest<Userinfo>(request, response, getPortletContext(), getOAuthProvider(),
            REQUIRED_SCOPE) {

        @Override
        protected Userinfo invokeRequest() throws IOException {
            return service.userinfo().v2().me().get().execute();
        }

    }.executeRequest();

    if (userInfo != null) {
        request.setAttribute(GOOGLE_USER_INFO, userInfo);
    }

    PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/jsp/google/userinfo.jsp");
    prd.include(request, response);
}
 
开发者ID:exo-samples,项目名称:docs-samples,代码行数:23,代码来源:GoogleUserInfoPortlet.java

示例9: loadAccessTokenOrRedirectToObtainIt

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
protected AccessToken loadAccessTokenOrRedirectToObtainIt(String username, OAuthProvider oauthProvider,
        RenderRequest request, RenderResponse response) throws IOException, PortletException {
    // Try requestContext first. Otherwise obtain OAuthProvider via API
    AccessToken accessToken = requestContext.getAccessToken(oauthProviderKey);
    if (accessToken == null) {
        accessToken = oauthProvider.loadAccessToken(username);
    }

    if (accessToken == null) {
        // Will be processed by method AbstractSocialPortlet.actionRedirectToOAuthFlow
        PortletURL actionURL = response.createActionURL();
        actionURL.setParameter(ActionRequest.ACTION_NAME, AbstractSocialPortlet.ACTION_OAUTH_REDIRECT);

        request.setAttribute(ATTRIBUTE_ERROR_MESSAGE, oauthProvider.getFriendlyName()
                + " access token not available for you.");
        request.setAttribute(ATTRIBUTE_OAUTH_PROVIDER, oauthProvider);
        PortletRequestDispatcher prd = filterConfig.getPortletContext().getRequestDispatcher("/jsp/error/token.jsp");
        prd.include(request, response);
    }

    return accessToken;
}
 
开发者ID:exo-samples,项目名称:docs-samples,代码行数:23,代码来源:OAuthPortletFilter.java

示例10: render

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   // Prereq for: V2DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_getAttribute
   portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_getAttribute", "Value1");

   // Prereq for: V2DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_getAttributeNames
   portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_getAttributeNames", "Value1");

   // Now do the actual dispatch
   String target = SERVLET_PREFIX + "DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_servlet" + SERVLET_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:20,代码来源:DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest.java

示例11: checkSameNameParameter

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
protected TestResult checkSameNameParameter(PortletContext context,
                                            PortletRequest request,
                                            PortletResponse response)
throws IOException, PortletException {

	// Dispatch to the companion servlet: call checkSameNameParameter().
	StringBuffer buffer = new StringBuffer();
	buffer.append(SERVLET_PATH).append("?")
			.append(KEY_TARGET).append("=").append(TARGET_SAME_NAME_PARAM)
			.append("&").append(KEY_C).append("=").append(VALUE_C1)
			.append("&").append(KEY_C).append("=").append(VALUE_C2)
			.append("&").append(KEY_C).append("=").append(VALUE_C3);

	if (LOG.isDebugEnabled()) {
		LOG.debug("Dispatching to: " + buffer.toString());
	}
	PortletRequestDispatcher dispatcher = context.getRequestDispatcher(
			buffer.toString());
	dispatcher.include((RenderRequest) request, (RenderResponse) response);

	// Retrieve test result returned by the companion servlet.
    TestResult result = (TestResult) request.getAttribute(RESULT_KEY);
	request.removeAttribute(RESULT_KEY);
	return result;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:26,代码来源:DispatcherRenderParameterTest.java

示例12: checkAddedSameNameParameter

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
protected TestResult checkAddedSameNameParameter(PortletContext context,
                                                 PortletRequest request,
                                                 PortletResponse response)
throws IOException, PortletException {
	// Dispatch to the companion servlet: call checkAddedSameNameParameter().
	StringBuffer buffer = new StringBuffer();
	buffer.append(SERVLET_PATH).append("?")
			.append(KEY_TARGET).append("=").append(TARGET_ADDED_SAME_NAME_PARAM)
			.append("&").append(KEY_RENDER).append("=").append(VALUE_ADDED1)
			.append("&").append(KEY_RENDER).append("=").append(VALUE_ADDED2);

	if (LOG.isDebugEnabled()) {
		LOG.debug("Dispatching to: " + buffer.toString());
	}
	PortletRequestDispatcher dispatcher = context.getRequestDispatcher(
			buffer.toString());
	dispatcher.include((RenderRequest) request, (RenderResponse) response);

	// Retrieve test result returned by the companion servlet.
    TestResult result = (TestResult) request.getAttribute(RESULT_KEY);
	request.removeAttribute(RESULT_KEY);
	return result;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:24,代码来源:DispatcherRenderParameterTest.java

示例13: getNamedDispatcher

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
public PortletRequestDispatcher getNamedDispatcher(ServletContext servletContext, PortletApplicationDefinition app,
                                                   String name)
{
    if (LOG.isDebugEnabled())
    {
        LOG.debug("Named PortletRequestDispatcher requested for name: "+name+" at context: "+app.getContextPath());
    }
    
    RequestDispatcher dispatcher = servletContext.getNamedDispatcher(name);
    if (dispatcher != null)
    {
        return new PortletRequestDispatcherImpl(dispatcher, name, true);
    }
    if (LOG.isInfoEnabled())
    {
        LOG.info("No matching request dispatcher found for name: "+ name);
    }
    return null;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:20,代码来源:RequestDispatcherServiceImpl.java

示例14: processAction

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
@Override
public void processAction(ActionRequest portletReq, ActionResponse portletResp)
      throws PortletException, IOException {

   portletResp.setRenderParameters(portletReq.getParameterMap());
   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);


   // Prereq for: V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPActionRequest_getAttribute
   portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPActionRequest_getAttribute", "Value1");

   // Prereq for: V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPActionRequest_getAttributeNames
   portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPActionRequest_getAttributeNames", "Value1");

   // Now do the actual dispatch
   String target = JSP_PREFIX + "DispatcherReqRespTests1_SPEC2_19_ForwardJSPActionRequest" + JSP_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:22,代码来源:DispatcherReqRespTests1_SPEC2_19_ForwardJSPActionRequest.java

示例15: processEvent

import javax.portlet.PortletRequestDispatcher; //导入依赖的package包/类
@Override
public void processEvent(EventRequest portletReq, EventResponse portletResp)
      throws PortletException, IOException {


   portletResp.setRenderParameters(portletReq);

   long tid = Thread.currentThread().getId();
   portletReq.setAttribute(THREADID_ATTR, tid);

   // Prereq for: V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventRequest_getAttribute
   portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventRequest_getAttribute", "Value1");

   // Prereq for: V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventRequest_getAttributeNames
   portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventRequest_getAttributeNames", "Value1");

   // Now do the actual dispatch
   String target = JSP_PREFIX + "DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventRequest" + JSP_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);
   
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:24,代码来源:DispatcherReqRespTests1_SPEC2_19_ForwardJSPEventRequest_event.java


注:本文中的javax.portlet.PortletRequestDispatcher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。