本文整理汇总了Java中org.springframework.ui.ExtendedModelMap类的典型用法代码示例。如果您正苦于以下问题:Java ExtendedModelMap类的具体用法?Java ExtendedModelMap怎么用?Java ExtendedModelMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExtendedModelMap类属于org.springframework.ui包,在下文中一共展示了ExtendedModelMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveModelAttribute
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
private WebDataBinder resolveModelAttribute(String attrName, MethodParameter methodParam,
ExtendedModelMap implicitModel, NativeWebRequest webRequest, Object handler) throws Exception {
// Bind request parameter onto object...
String name = attrName;
if ("".equals(name)) {
name = Conventions.getVariableNameForParameter(methodParam);
}
Class<?> paramType = methodParam.getParameterType();
Object bindObject;
if (implicitModel.containsKey(name)) {
bindObject = implicitModel.get(name);
}
else if (this.methodResolver.isSessionAttribute(name, paramType)) {
bindObject = this.sessionAttributeStore.retrieveAttribute(webRequest, name);
if (bindObject == null) {
raiseSessionRequiredException("Session attribute '" + name + "' required - not found in session");
}
}
else {
bindObject = BeanUtils.instantiateClass(paramType);
}
WebDataBinder binder = createBinder(webRequest, bindObject, name);
initBinder(handler, name, binder, webRequest);
return binder;
}
示例2: resolveModelAndView
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@Override
public org.springframework.web.servlet.ModelAndView resolveModelAndView(Method handlerMethod,
Class<?> handlerType,
Object returnValue,
ExtendedModelMap implicitModel,
NativeWebRequest webRequest) {
if (returnValue instanceof MySpecialArg) {
return new org.springframework.web.servlet.ModelAndView(new View() {
@Override
public String getContentType() {
return "text/html";
}
@Override
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response)
throws Exception {
response.getWriter().write("myValue");
}
});
}
return UNRESOLVED;
}
示例3: resolveModelAndView
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@Override
public ModelAndView resolveModelAndView(Method handlerMethod,
Class handlerType,
Object returnValue,
ExtendedModelMap implicitModel,
NativeWebRequest webRequest) {
if (returnValue instanceof MySpecialArg) {
return new ModelAndView(new View() {
@Override
public String getContentType() {
return "text/html";
}
@Override
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response)
throws Exception {
response.getWriter().write("myValue");
}
});
}
return UNRESOLVED;
}
示例4: resolveModelAndView
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
public ModelAndView resolveModelAndView(Method handlerMethod,
Class handlerType,
Object returnValue,
ExtendedModelMap implicitModel,
NativeWebRequest webRequest) {
if (returnValue instanceof MySpecialArg) {
return new ModelAndView(new View() {
@Override
public String getContentType() {
return "text/html";
}
@Override
public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response)
throws Exception {
response.getWriter().write("myValue");
}
});
}
return UNRESOLVED;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:ServletAnnotationControllerHandlerMethodTests.java
示例5: testBookController
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
public void testBookController() throws Exception {
BooksController controller = (BooksController)booksPortletContext.getBean("booksController");
ModelMap model = new ExtendedModelMap();
// ask the controller to handle the request
String view = controller.viewBook(Integer.valueOf(1), (Model)model);
// show the viewname
logger.info("view: " + view);
assertEquals("incorrect view", "bookView", view);
// show the model includes the book
assertTrue("model should contain a book", model.containsAttribute("book"));
Book book = (Book)model.get("book");
// check the book's details
logger.info("book.author: " + book.getAuthor());
assertEquals("incorrect author", "Neal Stephenson", book.getAuthor());
logger.info("book.title: " + book.getTitle());
assertEquals("incorrect title", "Snow Crash", book.getTitle());
logger.info("book.count: " + book.getCount());
assertEquals("incorrect count", Integer.valueOf(50), book.getCount());
}
示例6: likeTest
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@Test
public void likeTest() {
HttpSession session = new MockHttpSession();
session.setAttribute("user", user);
shareController.reshare(ORIGIANL_MESSAGE_ID, "Comment", "", false, Collections.<String>emptyList(), new ExtendedModelMap(),
user.getId(), session, new MockHttpServletResponse());
Collection<Message> incomingMessages = messageController
.getIncomingMessages(receivingUser, session, DEFAULT_MESSAGE_ID, false);
Assert.assertEquals(1, incomingMessages.size());
Message msg = incomingMessages.iterator().next();
Assert.assertEquals(ORIGIANL_MSG_TEXT, msg.getOriginalMessage()
.getText());
Assert.assertEquals(1, msg.getOriginalMessage().getAuthor().getScore());
}
示例7: testExecuteCommand_ModelMap
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@Test
public void testExecuteCommand_ModelMap() throws Exception {
// given
ExtendedModelMap model = new ExtendedModelMap();
String logAccessConfigId ="one-id";
String cmd = "cat file.log";
String encoding = Constants.DEFAULT_ENCODING_OPTION;
DisplayType displayType = DisplayType.RAW;
// when
String viewName = commandController.executeCommand(model, request, logAccessConfigId, cmd, encoding, displayType);
// then
Assert.assertEquals(Constants.VIEW_RAW, viewName);
Assert.assertEquals(true, request.getAttribute(Constants.SHOW_OPTIONS_KEY));
Assert.assertEquals(encoding, request.getAttribute(Constants.ENCODING_KEY));
Assert.assertEquals(displayType, request.getAttribute(Constants.DISPLAY_TYPE_KEY));
Assert.assertNotNull(request.getAttribute(Constants.BREADCRUMBS_KEY));
Assert.assertNotNull(model.get(Constants.RAW_CONTENT_KEY));
}
示例8: testExecuteCommand_BreadCrumbs_TailFile
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testExecuteCommand_BreadCrumbs_TailFile() throws Exception {
// given
ExtendedModelMap model = new ExtendedModelMap();
String logAccessConfigId ="one-id";
String cmd = "tail -1000 file.log";
String encoding = Constants.DEFAULT_ENCODING_OPTION;
DisplayType displayType = DisplayType.RAW;
// when
commandController.executeCommand(model, request, logAccessConfigId, cmd, encoding, displayType);
// then
List<Breadcrumb> breadcrumbs = (List<Breadcrumb>) request.getAttribute(Constants.BREADCRUMBS_KEY);
Assert.assertEquals(2, breadcrumbs.size());
Assert.assertEquals(logAccessConfigId, breadcrumbs.get(0).getLabel());
Assert.assertEquals("file.log", breadcrumbs.get(1).getLabel());
}
示例9: testGetListE
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@Test
public void testGetListE() {
MockHttpServletRequest request = new MockHttpServletRequest(servletContext);
Model uiModel = new ExtendedModelMap();
User user = new UserImpl();
user.setLoginName(USER);
user.setViewCampus(VIEW_CAMPUS[3]);
MockHttpSession session = new MockHttpSession();
session.setAttribute(Constants.KME_USER_KEY, user);
request.setSession(session);
String viewName;
try {
viewName = getController().getList(request, uiModel, TOOL_NAMES[7]);
} catch (NullPointerException npe) {
LOG.error(npe.getLocalizedMessage(), npe);
viewName = null;
}
assertTrue("View name is incorrect: Expected " + REDIRECT_CAMPUS + " and found " + viewName, REDIRECT_CAMPUS.equals(viewName));
}
示例10: testExecuteCommand_BreadCrumbs_TailSubFolderFile
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testExecuteCommand_BreadCrumbs_TailSubFolderFile() throws Exception {
// given
ExtendedModelMap model = new ExtendedModelMap();
String logAccessConfigId ="one-id";
String cmd = "tail -1000 folder1/folder2/file.log";
String encoding = Constants.DEFAULT_ENCODING_OPTION;
DisplayType displayType = DisplayType.RAW;
// when
commandController.executeCommand(model, request, logAccessConfigId, cmd, encoding, displayType);
// then
List<Breadcrumb> breadcrumbs = (List<Breadcrumb>) request.getAttribute(Constants.BREADCRUMBS_KEY);
Assert.assertEquals(4, breadcrumbs.size());
Assert.assertEquals(logAccessConfigId, breadcrumbs.get(0).getLabel());
Assert.assertEquals("folder1", breadcrumbs.get(1).getLabel());
Assert.assertEquals("folder2", breadcrumbs.get(2).getLabel());
Assert.assertEquals("file.log", breadcrumbs.get(3).getLabel());
}
示例11: testExecuteCommand_BreadCrumbs_ListTarGzEntries
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testExecuteCommand_BreadCrumbs_ListTarGzEntries() throws Exception {
// given
ExtendedModelMap model = new ExtendedModelMap();
String logAccessConfigId ="one-id";
String cmd = "tar -ztvf backup/apache-access.tar.gz";
String encoding = Constants.DEFAULT_ENCODING_OPTION;
DisplayType displayType = DisplayType.TABLE;
// when
commandController.executeCommand(model, request, logAccessConfigId, cmd, encoding, displayType);
// then
List<Breadcrumb> breadcrumbs = (List<Breadcrumb>) request.getAttribute(Constants.BREADCRUMBS_KEY);
Assert.assertEquals(3, breadcrumbs.size());
Assert.assertEquals(logAccessConfigId, breadcrumbs.get(0).getLabel());
Assert.assertEquals("backup", breadcrumbs.get(1).getLabel());
Assert.assertEquals("apache-access.tar.gz", breadcrumbs.get(2).getLabel());
}
示例12: testExecuteCommand_BreadCrumbs_ListTarGzEntry
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testExecuteCommand_BreadCrumbs_ListTarGzEntry() throws Exception {
// given
ExtendedModelMap model = new ExtendedModelMap();
String logAccessConfigId ="one-id";
String cmd = "tar -O -zxf backup/apache-access.tar.gz backup/apache-access-3l.log.gz | gzip -dc | tail -1000";
String encoding = Constants.DEFAULT_ENCODING_OPTION;
DisplayType displayType = DisplayType.RAW;
// when
commandController.executeCommand(model, request, logAccessConfigId, cmd, encoding, displayType);
// then
List<Breadcrumb> breadcrumbs = (List<Breadcrumb>) request.getAttribute(Constants.BREADCRUMBS_KEY);
Assert.assertEquals(4, breadcrumbs.size());
Assert.assertEquals(logAccessConfigId, breadcrumbs.get(0).getLabel());
Assert.assertEquals("backup", breadcrumbs.get(1).getLabel());
Assert.assertEquals("apache-access.tar.gz", breadcrumbs.get(2).getLabel());
Assert.assertEquals("apache-access-3l.log.gz", breadcrumbs.get(3).getLabel());
}
示例13: testViewPreferences
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@Test
public void testViewPreferences() {
Model model = new ExtendedModelMap();
Map<String, PortalPreference> preferenceMap = new HashMap<String, PortalPreference>();
expect(service.getPreferencesAsMap()).andReturn(preferenceMap);
replay(service);
String view = controller.viewPreferences(null,REFERRER_ID, model);
assertEquals(ViewNames.ADMIN_PREFERENCES, view);
assertEquals(preferenceMap, model.asMap().get("preferenceMap"));
assertFalse(model.containsAttribute("actionresult"));
assertTrue(model.containsAttribute("topnav"));
assertTrue(model.containsAttribute("tabs"));
assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
verify(service);
}
示例14: testViewPreferences_afterUpdate
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@Test
public void testViewPreferences_afterUpdate() {
Model model = new ExtendedModelMap();
Map<String, PortalPreference> preferenceMap = new HashMap<String, PortalPreference>();
expect(service.getPreferencesAsMap()).andReturn(preferenceMap);
replay(service);
final String action = "update";
String view = controller.viewPreferences(action,REFERRER_ID, model);
assertEquals(ViewNames.ADMIN_PREFERENCES, view);
assertEquals(preferenceMap, model.asMap().get("preferenceMap"));
assertEquals(action, model.asMap().get("actionresult"));
assertTrue(model.containsAttribute("topnav"));
assertTrue(model.containsAttribute("tabs"));
assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
verify(service);
}
示例15: testEditPreferences
import org.springframework.ui.ExtendedModelMap; //导入依赖的package包/类
@Test
public void testEditPreferences() {
Model model = new ExtendedModelMap();
Map<String, PortalPreference> preferenceMap = new HashMap<String, PortalPreference>();
expect(service.getPreferencesAsMap()).andReturn(preferenceMap);
replay(service);
String view = controller.editPreferences(model,REFERRER_ID);
assertEquals(ViewNames.ADMIN_PREFERENCE_DETAIL, view);
assertTrue(model.asMap().get("preferenceForm") instanceof PortalPreferenceForm);
assertTrue(model.containsAttribute(ModelKeys.TOKENCHECK));
assertTrue(model.containsAttribute("topnav"));
assertTrue(model.containsAttribute("tabs"));
assertThat((String) model.asMap().get(ModelKeys.REFERRING_PAGE_ID), is(equalTo(REFERRER_ID)));
}