本文整理汇总了Java中javax.portlet.MimeResponse类的典型用法代码示例。如果您正苦于以下问题:Java MimeResponse类的具体用法?Java MimeResponse怎么用?Java MimeResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MimeResponse类属于javax.portlet包,在下文中一共展示了MimeResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: doResolveException
import javax.portlet.MimeResponse; //导入依赖的package包/类
@Override
protected ModelAndView doResolveException(
PortletRequest request, MimeResponse response, Object handler, Exception ex) {
if (handler != null) {
Method handlerMethod = findBestExceptionHandlerMethod(handler, ex);
if (handlerMethod != null) {
NativeWebRequest webRequest = new PortletWebRequest(request, response);
try {
Object[] args = resolveHandlerArguments(handlerMethod, handler, webRequest, ex);
if (logger.isDebugEnabled()) {
logger.debug("Invoking request handler method: " + handlerMethod);
}
Object retVal = doInvokeMethod(handlerMethod, handler, args);
return getModelAndView(retVal);
}
catch (Exception invocationEx) {
logger.error("Invoking request method resulted in exception : " + handlerMethod, invocationEx);
}
}
}
return null;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:AnnotationMethodHandlerExceptionResolver.java
示例2: doResolveException
import javax.portlet.MimeResponse; //导入依赖的package包/类
/**
* Actually resolve the given exception that got thrown during on handler execution,
* returning a ModelAndView that represents a specific error page if appropriate.
* @param request current portlet request
* @param response current portlet response
* @param handler the executed handler, or null if none chosen at the time of
* the exception (for example, if multipart resolution failed)
* @param ex the exception that got thrown during handler execution
* @return a corresponding ModelAndView to forward to, or null for default processing
*/
@Override
protected ModelAndView doResolveException(
PortletRequest request, MimeResponse response, Object handler, Exception ex) {
// Log exception, both at debug log level and at warn level, if desired.
if (logger.isDebugEnabled()) {
logger.debug("Resolving exception from handler [" + handler + "]: " + ex);
}
logException(ex, request);
// Expose ModelAndView for chosen error view.
String viewName = determineViewName(ex, request);
if (viewName != null) {
return getModelAndView(viewName, ex, request);
}
else {
return null;
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:SimpleMappingExceptionResolver.java
示例3: doFilter
import javax.portlet.MimeResponse; //导入依赖的package包/类
public void doFilter(RenderRequest request, RenderResponse response, FilterChain chain) throws IOException, PortletException
{
Element metaViewport = response.createElement("meta");
metaViewport.setAttribute("name", "viewport");
metaViewport.setAttribute("content", "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1");
response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, metaViewport);
metaViewport = response.createElement("meta");
metaViewport.setAttribute("name", "apple-mobile-web-app-capable");
metaViewport.setAttribute("content", "yes");
response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, metaViewport);
/*
metaViewport = response.createElement("link");
metaViewport.setAttribute("rel", "apple-touch-icon");
metaViewport.setAttribute("href", "/demo-extension/img/chat-icon.png");
response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, metaViewport);
*/
//
chain.doFilter(request, response);
}
开发者ID:exo-addons,项目名称:portlet-pack,代码行数:24,代码来源:ResponseFilter.java
示例4: doFilter
import javax.portlet.MimeResponse; //导入依赖的package包/类
public void doFilter(RenderRequest request, RenderResponse response, FilterChain chain) throws IOException, PortletException
{
String account = request.getPreferences().getValue("account", null);
if (account!=null) {
Element jQuery1 = response.createElement("script");
jQuery1.setAttribute("type", "text/javascript");
String textContent = "var _gaq = _gaq || [];\n" +
" _gaq.push(['_setAccount', '"+account+"']);\n" +
" _gaq.push(['_trackPageview']);\n" +
"\n" +
" (function() {\n" +
" var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n" +
" ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n" +
" var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n" +
" })();";
jQuery1.setTextContent(textContent);
response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, jQuery1);
}
//
chain.doFilter(request, response);
}
开发者ID:exo-addons,项目名称:portlet-pack,代码行数:26,代码来源:ResponseFilter.java
示例5: render
import javax.portlet.MimeResponse; //导入依赖的package包/类
public void render(String viewName, Map model, PortletRequest request, MimeResponse response) throws Exception {
TestBean tb = (TestBean) model.get("testBean");
if (tb == null) {
tb = (TestBean) model.get("myCommand");
}
if (tb.getName().endsWith("myDefaultName")) {
assertTrue(tb.getDate().getYear() == 107);
}
Errors errors = (Errors) model.get(BindingResult.MODEL_KEY_PREFIX + "testBean");
if (errors == null) {
errors = (Errors) model.get(BindingResult.MODEL_KEY_PREFIX + "myCommand");
}
if (errors.hasFieldErrors("date")) {
throw new IllegalStateException();
}
List<TestBean> testBeans = (List<TestBean>) model.get("testBeanList");
response.getWriter().write(viewName + "-" + tb.getName() + "-" + errors.getFieldError("age").getCode() +
"-" + testBeans.get(0).getName() + "-" + model.get("myKey"));
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:20,代码来源:Portlet20AnnotationControllerTests.java
示例6: PortletRequestHelper
import javax.portlet.MimeResponse; //导入依赖的package包/类
/**
* Creates a new request helper for the specified PageContext. Retrieves the PortletRequest and RenderResponse from
* the PageContext.
* @param pageContext Current JSP context.
* @throws IllegalStateException If the PortletRequest or RenderResponse are not found in the PageContext.
*/
public PortletRequestHelper(PageContext pageContext)
{
if (pageContext == null)
{
throw new IllegalArgumentException("pageContext may not be null");
}
this.portletRequest = (PortletRequest) pageContext.findAttribute(JAVAX_PORTLET_REQUEST);
if (this.portletRequest == null)
{
throw new IllegalStateException("A PortletRequest could not be found in the PageContext for the key='"
+ JAVAX_PORTLET_REQUEST
+ "'");
}
this.renderResponse = (MimeResponse) pageContext.findAttribute(JAVAX_PORTLET_RESPONSE);
if (this.portletRequest == null)
{
throw new IllegalStateException("A RenderResponse could not be found in the PageContext for the key='"
+ JAVAX_PORTLET_RESPONSE
+ "'");
}
}
开发者ID:webbfontaine,项目名称:displaytag,代码行数:30,代码来源:PortletRequestHelper.java
示例7: doStartTag
import javax.portlet.MimeResponse; //导入依赖的package包/类
@Override
public int doStartTag() throws JspException {
Object obj = pageContext.getRequest().getAttribute(Constants.PORTLET_RESPONSE);
if ((obj == null) || !(obj instanceof MimeResponse)) {
throw new JspException("Could not obtain MimeResponse to create the URL.");
}
MimeResponse resp = (MimeResponse) obj;
RenderURL rurl = null;
if (isCopyCurrentRenderParameters() == true) {
rurl = resp.createRenderURL(Copy.ALL);
} else {
rurl = resp.createRenderURL(Copy.NONE);
}
params = rurl.getRenderParameters();
setUrl(rurl);
handlePMandWS();
handleDefaultEscapeXML();
handleSecureFlag();
return EVAL_BODY_INCLUDE;
}
开发者ID:apache,项目名称:portals-pluto,代码行数:25,代码来源:RenderURLTag362.java
示例8: doStartTag
import javax.portlet.MimeResponse; //导入依赖的package包/类
@Override
public int doStartTag() throws JspException {
Object obj = pageContext.getRequest().getAttribute(Constants.PORTLET_RESPONSE);
if ((obj == null) || !(obj instanceof MimeResponse)) {
throw new JspException("Could not obtain MimeResponse to create the URL.");
}
MimeResponse resp = (MimeResponse) obj;
ActionURL aurl = null;
if (isCopyCurrentRenderParameters() == true) {
aurl = resp.createActionURL(Copy.ALL);
} else {
aurl = resp.createActionURL(Copy.NONE);
}
rparams = aurl.getRenderParameters();
aparams = aurl.getActionParameters();
setUrl(aurl);
handlePMandWS();
handleDefaultEscapeXML();
handleSecureFlag();
return EVAL_BODY_INCLUDE;
}
开发者ID:apache,项目名称:portals-pluto,代码行数:26,代码来源:ActionURLTag362.java
示例9: render
import javax.portlet.MimeResponse; //导入依赖的package包/类
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
portletResp.setContentType("text/html");
PrintWriter writer = portletResp.getWriter();
writer.write("<h3>Event Companion Portlet </h3>\n");
writer.write("<p>DispatcherTests2_SPEC2_19_IncludeJSPEvent_event</p>\n");
String msg = (String) portletReq.getPortletSession().getAttribute(
RESULT_ATTR_PREFIX + "DispatcherTests2_SPEC2_19_IncludeJSPEvent", APPLICATION_SCOPE);
msg = (msg == null) ? "Not ready. click test case link." : msg;
writer.write("<p>" + msg + "</p>\n");
/* TestCase: V2DispatcherTests2_SPEC2_19_IncludeJSPEvent_dispatch2 */
/* Details: "Parameters specified in the query strings must be */
/* aggregated with the portlet render parameters" */
PortletURL urlEvent = ((MimeResponse) portletResp).createRenderURL();
urlEvent.setParameter("qparm2", "renderVal2");
TestSetupLink tlEvent = new TestSetupLink(V2DISPATCHERTESTS2_SPEC2_19_INCLUDEJSPEVENT_DISPATCH2, urlEvent);
tlEvent.writeTo(writer);
}
开发者ID:apache,项目名称:portals-pluto,代码行数:23,代码来源:DispatcherTests2_SPEC2_19_IncludeJSPEvent_event.java
示例10: render
import javax.portlet.MimeResponse; //导入依赖的package包/类
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {
portletResp.setContentType("text/html");
PrintWriter writer = portletResp.getWriter();
writer.write("<h3>Event Companion Portlet </h3>\n");
writer.write("<p>DispatcherTests2_SPEC2_19_ForwardJSPEvent_event</p>\n");
String msg = (String) portletReq.getPortletSession().getAttribute(
RESULT_ATTR_PREFIX + "DispatcherTests2_SPEC2_19_ForwardJSPEvent", APPLICATION_SCOPE);
msg = (msg == null) ? "Not ready. click test case link." : msg;
writer.write("<p>" + msg + "</p>\n");
/* TestCase: V2DispatcherTests2_SPEC2_19_ForwardJSPEvent_dispatch2 */
/* Details: "Parameters specified in the query strings must be */
/* aggregated with the portlet render parameters" */
PortletURL urlEvent = ((MimeResponse) portletResp).createRenderURL();
urlEvent.setParameter("qparm2", "renderVal2");
TestSetupLink tlEvent = new TestSetupLink(V2DISPATCHERTESTS2_SPEC2_19_FORWARDJSPEVENT_DISPATCH2, urlEvent);
tlEvent.writeTo(writer);
}
开发者ID:apache,项目名称:portals-pluto,代码行数:23,代码来源:DispatcherTests2_SPEC2_19_ForwardJSPEvent_event.java
示例11: processTCKReq
import javax.portlet.MimeResponse; //导入依赖的package包/类
protected void processTCKReq(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
PortletRequest portletReq = (PortletRequest) request.getAttribute("javax.portlet.request");
PortletResponse portletResp = (PortletResponse) request.getAttribute("javax.portlet.response");
request.getAttribute("javax.portlet.config");
Thread.currentThread().getId();
portletReq.getAttribute(THREADID_ATTR);
PrintWriter writer = ((MimeResponse) portletResp).getWriter();
// Create result objects for the tests
PortletURL purl = ((MimeResponse) portletResp).createRenderURL();
TestLink tl = new TestLink(V2DISPATCHERTESTS3S_SPEC2_19_FORWARDSERVLETRESOURCE_DISPATCH4, purl);
tl.writeTo(writer);
}
开发者ID:apache,项目名称:portals-pluto,代码行数:19,代码来源:DispatcherTests3S_SPEC2_19_ForwardServletResource_servlet.java
示例12: doRender
import javax.portlet.MimeResponse; //导入依赖的package包/类
/**
* Actually render the given view.
* <p>The default implementation delegates to
* {@link org.springframework.web.servlet.ViewRendererServlet}.
* @param view the View to render
* @param model the associated model
* @param request current portlet render/resource request
* @param response current portlet render/resource response
* @throws Exception if there's a problem rendering the view
*/
protected void doRender(View view, Map<String, ?> model, PortletRequest request, MimeResponse response) throws Exception {
// Expose Portlet ApplicationContext to view objects.
request.setAttribute(ViewRendererServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, getPortletApplicationContext());
// These attributes are required by the ViewRendererServlet.
request.setAttribute(ViewRendererServlet.VIEW_ATTRIBUTE, view);
request.setAttribute(ViewRendererServlet.MODEL_ATTRIBUTE, model);
// Include the content of the view in the render/resource response.
doDispatch(getPortletContext().getRequestDispatcher(this.viewRendererUrl), request, response);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:DispatcherPortlet.java
示例13: doDispatch
import javax.portlet.MimeResponse; //导入依赖的package包/类
/**
* Perform a dispatch on the given PortletRequestDispatcher.
* <p>The default implementation uses a forward for resource requests
* and an include for render requests.
* @param dispatcher the PortletRequestDispatcher to use
* @param request current portlet render/resource request
* @param response current portlet render/resource response
* @throws Exception if there's a problem performing the dispatch
*/
protected void doDispatch(PortletRequestDispatcher dispatcher, PortletRequest request, MimeResponse response)
throws Exception {
// In general, we prefer a forward for resource responses, in order to have full Servlet API
// support in the target resource (e.g. on uPortal). However, on Liferay, a resource forward
// displays an empty page, so we have to resort to an include there...
if (PortletRequest.RESOURCE_PHASE.equals(request.getAttribute(PortletRequest.LIFECYCLE_PHASE)) &&
!dispatcher.getClass().getName().startsWith("com.liferay")) {
dispatcher.forward(request, response);
}
else {
dispatcher.include(request, response);
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:DispatcherPortlet.java
示例14: applyCacheSeconds
import javax.portlet.MimeResponse; //导入依赖的package包/类
/**
* Apply the given cache seconds to the render response
* @param response current portlet render response
* @param seconds positive number of seconds into the future that the
* response should be cacheable for, 0 to prevent caching
*/
protected final void applyCacheSeconds(MimeResponse response, int seconds) {
if (seconds > 0) {
cacheForSeconds(response, seconds);
}
else if (seconds == 0) {
preventCaching(response);
}
// Leave caching to the portlet configuration otherwise.
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:PortletContentGenerator.java
示例15: getResourceURL
import javax.portlet.MimeResponse; //导入依赖的package包/类
/**
* Creates a resource URL from the given faces context.
*
* @param context
* the faces context
* @return the resource URL
*/
public static String getResourceURL(FacesContext context, String path)
{
MimeResponse portletResponse = (MimeResponse) context.getExternalContext().getResponse();
ResourceURL resourceURL = portletResponse.createResourceURL();
resourceURL.setResourceID(path);
return resourceURL.toString();
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:15,代码来源:AlfrescoFacesPortlet.java
示例16: doRender
import javax.portlet.MimeResponse; //导入依赖的package包/类
/**
* Actually render the given view.
* <p>The default implementation delegates to
* {@link org.springframework.web.servlet.ViewRendererServlet}.
* @param view the View to render
* @param model the associated model
* @param request current portlet render/resource request
* @param response current portlet render/resource response
* @throws Exception if there's a problem rendering the view
*/
protected void doRender(View view, Map model, PortletRequest request, MimeResponse response) throws Exception {
// Expose Portlet ApplicationContext to view objects.
request.setAttribute(ViewRendererServlet.WEB_APPLICATION_CONTEXT_ATTRIBUTE, getPortletApplicationContext());
// These attributes are required by the ViewRendererServlet.
request.setAttribute(ViewRendererServlet.VIEW_ATTRIBUTE, view);
request.setAttribute(ViewRendererServlet.MODEL_ATTRIBUTE, model);
// Include the content of the view in the render/resource response.
doDispatch(getPortletContext().getRequestDispatcher(this.viewRendererUrl), request, response);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:22,代码来源:DispatcherPortlet.java
示例17: PortletHref
import javax.portlet.MimeResponse; //导入依赖的package包/类
/**
* Creates a new PortletHref. The actual PortletURL object is not generated until the toString method is called.
* @param portletRequest request to to feature checking with, may not be null.
* @param renderResponse response to generate the URLs from, may not be null.
*/
public PortletHref(PortletRequest portletRequest, MimeResponse renderResponse)
{
if (portletRequest == null)
{
throw new IllegalArgumentException("portletRequest may not be null");
}
if (renderResponse == null)
{
throw new IllegalArgumentException("renderResponse may not be null");
}
this.portletRequest = portletRequest;
this.renderResponse = renderResponse;
}
开发者ID:webbfontaine,项目名称:displaytag,代码行数:20,代码来源:PortletHref.java
示例18: checkEqualMimeResponse
import javax.portlet.MimeResponse; //导入依赖的package包/类
public boolean checkEqualMimeResponse(MimeResponse injectedPortletArtifact,
MimeResponse mimeResponse) {
if (injectedPortletArtifact.equals(mimeResponse)) {
return true;
}
int injectedBufferSize = injectedPortletArtifact.getBufferSize();
int portletBufferSize = mimeResponse.getBufferSize();
String injectedCharacterEncoding = injectedPortletArtifact
.getCharacterEncoding();
String portletCharacterEncoding = mimeResponse.getCharacterEncoding();
String injectedContentType = injectedPortletArtifact.getContentType();
String portletContentType = mimeResponse.getContentType();
if (checkEqualResponses(injectedPortletArtifact, mimeResponse)
&& injectedBufferSize == portletBufferSize
&& ((injectedCharacterEncoding == null && portletCharacterEncoding == null) ||
injectedCharacterEncoding.equals(portletCharacterEncoding))
&& (injectedContentType == null && portletContentType == null) ||
injectedContentType.equals(portletContentType)
) {
return true;
} else {
return false;
}
}
开发者ID:apache,项目名称:portals-pluto,代码行数:30,代码来源:Utils.java
示例19: processTCKReq
import javax.portlet.MimeResponse; //导入依赖的package包/类
protected void processTCKReq(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
PortletRequest portletReq = (PortletRequest) request.getAttribute("javax.portlet.request");
PortletResponse portletResp = (PortletResponse) request.getAttribute("javax.portlet.response");
request.getAttribute("javax.portlet.config");
Thread.currentThread().getId();
portletReq.getAttribute(THREADID_ATTR);
PrintWriter writer = ((MimeResponse) portletResp).getWriter();
JSR286DispatcherTestCaseDetails tcd = new JSR286DispatcherTestCaseDetails();
// Create result objects for the tests
/* TestCase: V2DispatcherTests4_SPEC2_19_ForwardServletRender_invoke3 */
/* Details: "Parameters to the forward method for a target servlet */
/* can be wrapped request and response classes from the portlet */
/* lifecyle method initiating the include" */
TestResult tr0 = tcd.getTestResultFailed(V2DISPATCHERTESTS4_SPEC2_19_FORWARDSERVLETRENDER_INVOKE3);
try {
// If this gets executed, include worked.
tr0.setTcSuccess(true);
} catch (Exception e) {
tr0.appendTcDetail(e.toString());
}
tr0.writeTo(writer);
}
开发者ID:apache,项目名称:portals-pluto,代码行数:30,代码来源:DispatcherTests4_SPEC2_19_ForwardServletRender_servlet.java
示例20: processTCKReq
import javax.portlet.MimeResponse; //导入依赖的package包/类
protected void processTCKReq(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
PortletRequest portletReq = (PortletRequest) request.getAttribute("javax.portlet.request");
PortletResponse portletResp = (PortletResponse) request.getAttribute("javax.portlet.response");
request.getAttribute("javax.portlet.config");
Thread.currentThread().getId();
portletReq.getAttribute(THREADID_ATTR);
PrintWriter writer = ((MimeResponse) portletResp).getWriter();
JSR286DispatcherTestCaseDetails tcd = new JSR286DispatcherTestCaseDetails();
// Create result objects for the tests
/* TestCase: V2DispatcherTests4_SPEC2_19_ForwardServletResource_invoke3 */
/* Details: "Parameters to the forward method for a target servlet */
/* can be wrapped request and response classes from the portlet */
/* lifecyle method initiating the include" */
TestResult tr0 = tcd.getTestResultFailed(V2DISPATCHERTESTS4_SPEC2_19_FORWARDSERVLETRESOURCE_INVOKE3);
try {
// If this gets executed, include worked.
tr0.setTcSuccess(true);
} catch (Exception e) {
tr0.appendTcDetail(e.toString());
}
tr0.writeTo(writer);
}
开发者ID:apache,项目名称:portals-pluto,代码行数:30,代码来源:DispatcherTests4_SPEC2_19_ForwardServletResource_servlet.java
注:本文中的javax.portlet.MimeResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论