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


Java PortletMode类代码示例

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


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

示例1: standardHandleMethod

import javax.portlet.PortletMode; //导入依赖的package包/类
@Test
public void standardHandleMethod() throws Exception {
	DispatcherPortlet portlet = new DispatcherPortlet() {
		@Override
		protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
			GenericWebApplicationContext wac = new GenericWebApplicationContext();
			wac.registerBeanDefinition("controller", new RootBeanDefinition(MyController.class));
			wac.refresh();
			return wac;
		}
	};
	portlet.init(new MockPortletConfig());

	MockRenderRequest request = new MockRenderRequest(PortletMode.VIEW);
	MockRenderResponse response = new MockRenderResponse();
	portlet.render(request, response);
	assertEquals("test", response.getContentAsString());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:Portlet20AnnotationControllerTests.java

示例2: mavResolver

import javax.portlet.PortletMode; //导入依赖的package包/类
@Test
public void mavResolver() throws Exception {
	DispatcherPortlet portlet = new DispatcherPortlet() {
		@Override
		protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException {
			GenericWebApplicationContext wac = new GenericWebApplicationContext();
			wac.registerBeanDefinition("controller",
					new RootBeanDefinition(ModelAndViewResolverController.class));
			RootBeanDefinition adapterDef = new RootBeanDefinition(AnnotationMethodHandlerAdapter.class);
			adapterDef.getPropertyValues()
					.add("customModelAndViewResolver", new MyModelAndViewResolver());
			wac.registerBeanDefinition("handlerAdapter", adapterDef);
			wac.refresh();
			return wac;
		}
	};
	portlet.init(new MockPortletConfig());

	MockRenderRequest request = new MockRenderRequest(PortletMode.VIEW);
	MockRenderResponse response = new MockRenderResponse();
	portlet.render(request, response);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:PortletAnnotationControllerTests.java

示例3: portletModeMappingViewRenderRequestWithUnauthorizedUserRole

import javax.portlet.PortletMode; //导入依赖的package包/类
@Test
public void portletModeMappingViewRenderRequestWithUnauthorizedUserRole() throws Exception {
	MockRenderRequest request = new MockRenderRequest();
	MockRenderResponse response = new MockRenderResponse();
	request.setPortletMode(PortletMode.VIEW);
	request.addUserRole("role3");
	request.setParameter("action", "not mapped");
	request.setParameter("myParam", "not mapped");
	complexDispatcherPortlet.doDispatch(request, response);
	Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
	Exception exception = (Exception) model.get("exception");
	assertNotNull(exception);
	assertTrue(exception.getClass().equals(PortletSecurityException.class));
	InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
	assertEquals("failed-default-1", view.getBeanName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:DispatcherPortletTests.java

示例4: testSerialization

import javax.portlet.PortletMode; //导入依赖的package包/类
public void testSerialization() throws IOException, ClassNotFoundException
{
	PortletState state = new PortletState("id");
	state.setPortletMode(PortletMode.VIEW);
	state.setWindowState(WindowState.MAXIMIZED);

	ByteArrayOutputStream bao = new ByteArrayOutputStream();
	ObjectOutputStream out = new ObjectOutputStream(bao);

	out.writeObject(state);

	ByteArrayInputStream bai = new ByteArrayInputStream(bao.toByteArray());
	ObjectInputStream in = new ObjectInputStream(bai);
	PortletState alter = (PortletState) in.readObject();

	assertEquals(state, alter);

}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:19,代码来源:PortletStateTest.java

示例5: testEncodeDecode

import javax.portlet.PortletMode; //导入依赖的package包/类
public void testEncodeDecode()
{
	PortletState state = new PortletState("id");
	state.setAction(true);
	state.setSecure(true);
	state.setWindowState(WindowState.MAXIMIZED);
	state.setPortletMode(PortletMode.EDIT);

	String uriSafe = encoder.encode(state);
	PortletState read = encoder.decode(uriSafe);
	assertEquals(state.getId(), read.getId());
	assertEquals(state.isAction(), read.isAction());
	assertEquals(state.isSecure(), read.isSecure());
	assertEquals(state.getWindowState(), read.getWindowState());
	assertEquals(state.getPortletMode(), read.getPortletMode());
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:17,代码来源:SimplePortletStateEncoderTest.java

示例6: getFeedContent

import javax.portlet.PortletMode; //导入依赖的package包/类
/**
 * Get the feed content
 * @param request
 * @param response
 * @return Map of params or null if any required data is missing
 */
private SyndFeed getFeedContent(RenderRequest request, RenderResponse response) {
	
	SyndFeed feed;
	
	//check cache, otherwise get fresh
	//we use the feedUrl as the cacheKey
	String feedUrl = getConfiguredFeedUrl(request);
	if(StringUtils.isBlank(feedUrl)) {
		log.debug("No feed URL configured");
		doError("error.no.config", "error.heading.config", getPortletModeUrl(response, PortletMode.EDIT), request, response);
		return null;
	}
	
	String cacheKey = feedUrl;
	
	feed = feedCache.get(cacheKey);
	if(feed != null) {
		log.debug("Fetching data from feed cache for: " + cacheKey);
	} else {
		//get from remote
		feed = getRemoteFeed(feedUrl, request, response);
	}
	
	return feed;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:32,代码来源:SimpleRSSPortlet.java

示例7: getPMList

import javax.portlet.PortletMode; //导入依赖的package包/类
private HashSet<PortletMode> getPMList(String mimeType) {
   HashSet<PortletMode> pms = new HashSet<PortletMode>();
   
   pms.add(PortletMode.VIEW);       // all portlets support view
   
   // Add the portlet mode to the list 
   
   for (Supports s : portlet.getSupports()) {
      if (mimeType.equalsIgnoreCase(s.getMimeType())) {
         for (String pmname : s.getPortletModes()) {
            PortletMode pm = new PortletMode(pmname);
            pms.add(pm);
         }
      }
   }

   return pms;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:19,代码来源:DriverPortletConfigImpl.java

示例8: execute

import javax.portlet.PortletMode; //导入依赖的package包/类
public ModelExport execute(AppData data, Connection conn)
		throws ConfigurationException, SQLException, IOException
{
	WindowState state = data.renderRequest.getWindowState();
	if (!state.equals(WindowState.MINIMIZED))
	{
		PortletMode mode = data.renderRequest.getPortletMode();
		if (PortletMode.VIEW.equals(mode))
		{
			return this.view;
		}
		else if (PortletMode.EDIT.equals(mode))
		{
			return this.edit;
		}
		else if (PortletMode.HELP.equals(mode))
		{
			return this.help;
		}
		else
		{
			log.error("Unknown portlet mode: " + mode + ".");
		}
	}
	return null;
}
 
开发者ID:micromagic,项目名称:eterna,代码行数:27,代码来源:RenderExecute.java

示例9: getDefinedPortletModes

import javax.portlet.PortletMode; //导入依赖的package包/类
/**
 * Provides a list of all static PortletMode available in the specifications by using introspection
 * 
 * @return Hashtable
 */
private static Hashtable<String, Object> getDefinedPortletModes() {
   Hashtable<String, Object> portletModes = new Hashtable<String, Object>();
   Field[] f = PortletMode.class.getDeclaredFields();

   for (int i = 0; i < f.length; i++) {
      if (f[i].getType().isAssignableFrom(javax.portlet.PortletMode.class)) {
         try {
            portletModes.put(f[i].get(f[i]).toString().toUpperCase(), f[i].get(f[i]));
         } catch (IllegalAccessException e) {
         }
      }
   }

   return portletModes;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:21,代码来源:PortletURLTag168.java

示例10: invoke1b

import javax.portlet.PortletMode; //导入依赖的package包/类
@Test
public void invoke1b() throws Exception {
   meths.reset();
   PortletInvoker i = new PortletInvoker(ams, "portlet1");
   PortletMode mode = new PortletMode("CustomMode");
   req.setMode(mode);
   i.renderHeaders(req, resp);
   List<String> names = meths.getMethods();
   assertNotNull(names);
   assertEquals(3, names.size());
   List<String> soll = Arrays.asList(new String[] {
         Header1.class.getSimpleName() + "#header1a",
         Header1.class.getSimpleName() + "#header1b",
         Header1.class.getSimpleName() + "#header1c"
         });
   for (String name : names) {
      assertTrue(soll.contains(name));
   }
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:20,代码来源:InvokeHeaderTest.java

示例11: processAction

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

  String action = request.getParameter("action");
  
  if ("editPrefs".equals(action)) {
    PortletPreferences prefs = request.getPreferences();
    for (String key : prefs.getMap().keySet()) {
      String value = request.getParameter(key);
      prefs.setValue(key, value);
    }
    prefs.store();

  } else {
    String url = request.getParameter("URL");
    if (!StringUtils.isBlank(url)) {
      PortletMessaging.publish(request, IFrameGenericPortlet.IFRAME_SRC_URL, url.trim());
    }
  }

  response.setPortletMode(PortletMode.VIEW);
}
 
开发者ID:km-works,项目名称:reverse-web-proxy-portlet,代码行数:24,代码来源:ReverseProxyIFramePortlet.java

示例12: generateSearchUrl

import javax.portlet.PortletMode; //导入依赖的package包/类
/**
 * Returns a list of search URLs to be put in the request attributes
 *
 * @param themeDisplay The theme display
 * @param layout The current page
 * @return A list of search URLs to be put in the request attributes
 */
private List<SearchUrl> generateSearchUrl(HttpServletRequest request, ThemeDisplay themeDisplay, Layout layout) {
    LayoutTypePortlet layoutType = (LayoutTypePortlet) layout.getLayoutType();
    UnicodeProperties props = layoutType.getTypeSettingsProperties();

    return layoutType.getPortlets().stream()
        .filter(portlet -> portlet.getPortletName().equals(FlashlightSearchPortletKeys.PORTLET_NAME))
        .map(portletInstance -> {

            String columnId = StringPool.BLANK;
            for(Entry<String, String> entry : props.entrySet()) {
                if(entry.getValue().equals(portletInstance.getPortletId())) {
                    columnId = entry.getKey();
                    break;
                }
            }

            String portletUrl;

            try {
                portletUrl = this.portal.getLayoutFriendlyURL(layout, themeDisplay);
            } catch (PortalException e) {
                portletUrl = StringPool.BLANK;
                LOG.error(e);
            }

            SearchUrlRequestParameter[] params = new SearchUrlRequestParameter[] {
                new SearchUrlRequestParameter(PARAM_PORTLET_ID, portletInstance.getPortletId()),
                new SearchUrlRequestParameter(PARAM_PORTLET_LIFECYCLE, LIFECYCLE_RENDER),
                new SearchUrlRequestParameter(PARAM_PORTLET_MODE, PortletMode.VIEW.toString()),
                new SearchUrlRequestParameter(PARAM_PORTLET_COLUMN_ID, columnId),
                new SearchUrlRequestParameter(PARAM_PORTLET_COLUMN_COUNT, Integer.toString(layoutType.getNumOfColumns()))
            };

            String portletNamespace = this.portal.getPortletNamespace(portletInstance.getPortletId());

            return new SearchUrl(layout, portletUrl, params, portletNamespace);
        })
        .collect(Collectors.toList());
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:47,代码来源:SearchUrlAction.java

示例13: render

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

	ThemeDisplay themeDisplay =
		(ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
	PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
	String portletId = portletDisplay.getId();

	JSONObject urlObject = JSONFactoryUtil.createJSONObject();
	JSONObject apiObject = JSONFactoryUtil.createJSONObject();

	// url
	PortletURL dossierInfoURL = PortletURLFactoryUtil.create(
		renderRequest, portletId, themeDisplay.getPlid(),
		PortletRequest.RENDER_PHASE);

	dossierInfoURL.setPortletMode(PortletMode.VIEW);
	dossierInfoURL.setWindowState(LiferayWindowState.EXCLUSIVE);
	dossierInfoURL.setParameter(
		"mvcPath", "/templates/lookup_dossier/dossierinfo.ftl");

	urlObject.put("dossierinfo", dossierInfoURL.toString());

	// api
	apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2");
	apiObject.put(
		"portletNamespace",
		themeDisplay.getPortletDisplay().getNamespace());

	// set varible
	renderRequest.setAttribute("ajax", urlObject);
	renderRequest.setAttribute("api", apiObject);

	super.render(renderRequest, renderResponse);

}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:39,代码来源:LookupDossierResult.java

示例14: render

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

	ThemeDisplay themeDisplay =
		(ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
	PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
	String portletId = portletDisplay.getId();

	JSONObject urlObject = JSONFactoryUtil.createJSONObject();
	JSONObject apiObject = JSONFactoryUtil.createJSONObject();

	// url
	PortletURL registerResultURL = PortletURLFactoryUtil.create(
		renderRequest, portletId, themeDisplay.getPlid(),
		PortletRequest.RENDER_PHASE);

	registerResultURL.setPortletMode(PortletMode.VIEW);
	registerResultURL.setWindowState(LiferayWindowState.EXCLUSIVE);
	registerResultURL.setParameter(
		"mvcPath", "/templates/applicant/register_result.ftl");

	urlObject.put("register_result", registerResultURL.toString());

	// api
	apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2");
	apiObject.put(
		"portletNamespace",
		themeDisplay.getPortletDisplay().getNamespace());

	// set varible
	renderRequest.setAttribute("ajax", urlObject);
	renderRequest.setAttribute("api", apiObject);

	super.render(renderRequest, renderResponse);

}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:39,代码来源:RegisterPorltet.java

示例15: render

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

	ThemeDisplay themeDisplay =
		(ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
	PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
	String portletId = portletDisplay.getId();

	JSONObject urlObject = JSONFactoryUtil.createJSONObject();
	JSONObject apiObject = JSONFactoryUtil.createJSONObject();

	// url
	PortletURL confirmPasswordURL = PortletURLFactoryUtil.create(
		renderRequest, portletId, themeDisplay.getPlid(),
		PortletRequest.RENDER_PHASE);

	confirmPasswordURL.setPortletMode(PortletMode.VIEW);
	confirmPasswordURL.setWindowState(LiferayWindowState.EXCLUSIVE);
	confirmPasswordURL.setParameter(
		"mvcPath", "/templates/applicant/confirm_password.ftl");

	urlObject.put("confirm_password", confirmPasswordURL.toString());

	// api
	apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2");
	apiObject.put(
		"portletNamespace",
		themeDisplay.getPortletDisplay().getNamespace());

	// set varible
	renderRequest.setAttribute("ajax", urlObject);
	renderRequest.setAttribute("api", apiObject);

	super.render(renderRequest, renderResponse);

}
 
开发者ID:VietOpenCPS,项目名称:opencps-v2,代码行数:39,代码来源:ForgottenAccount.java


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