`
avi2
  • 浏览: 88736 次
社区版块
存档分类
最新评论

Dynamic list binding in Spring MVC

    博客分类:
  • java
阅读更多
The Spring MVC documentation just isn't quite there. It is pretty basic, and doesn't really help with some common medium difficulty scenarios. The one I am documenting today is how to take a typical model (with lists of dependent objects), show it in a form, and get the graph back upon submission...

Rather than go through the entire thought process from beginning to end, I am going to show the end state and then explain the major glue points that make everything work. The assumption is that you have an ok understanding of Spring MVC.

The model

Here's a simple model for the illustration. There is an object named Grid which has a list of Block objects..

public class Grid {
  private List blocks = 
    LazyList.decorate(
      new ArrayList(),
      FactoryUtils.instantiateFactory(Block.class));

  public List getBlocks() {
    return blocks;
  }

  public void setBlocks(List list) {
    blocks = list;
  }
}



the LazyList class is the key here. This is in from the commons-collections package. I'll talk about why this is key later.

public class Block {
  private String id, description;

  public String getDescription() {
    return description;
  }

  public String getId() {
    return id;
  }

  public void setDescription(String string) {
    description = string;
  }

  public void setId(String string) {
    id = string;
  }
}

分享到:
评论

相关推荐

    Spring.MVC.A.Tutorial.2nd.Edition.1771970316

    This is a tutorial on Spring MVC, a module in the Spring Framework for rapidly developing web applications. The MVC in Spring MVC stands for Model-View-Controller, a design pattern widely used in ...

    spring mvc 3.0.5工程所需包整合

    3.0.5.RELEASE.jar,org.springframework.asm-3.0.5.RELEASE.jar,org.springframework.aspects-3.0.5.RELEASE.jar,org.springframework.beans-3.0.5.RELEASE.jar,org.springframework.binding-2.3.0.RELEASE.jar...

    Spring MVC 学习笔记 十一 data binding

    工程文件 博文链接:https://starscream.iteye.com/blog/1072179

    Getting.started.with.Spring.Framework.2nd.Edition1491011912.epub

    Chapter 11 – Validation and data binding in Spring Web MVC Chapter 12 –Developing RESTful web services using Spring Web MVC Chapter 13 – More Spring Web MVC – internationalization, file upload and...

    CVE-2022-22963 复现Demo

    CVE-2022-22963 复现Demo,A Spring MVC or Spring WebFlux application running on JDK 9+ may be vulnerable to remote code execution (RCE) via data binding. The specific exploit requires the application ...

    spring framework4

    Spring MVC and Spring WebFlux web frameworks Integration: remoting, JMS, JCA, JMX, email, tasks, scheduling, cache. Languages: Kotlin, Groovy, dynamic languages. Minimum requirements JDK 8+ for Spring...

    Web框架编程-SpringMVC框架编程

    Spring MVC(Model-View-Controller)是一个基于Java的MVC(模型-视图-控制器)框架,用于构建Web应用程序。它是Spring Framework的一部分,提供了一种简单、灵活且可扩展的方式来开发Web应用程序。 下面是Spring ...

    asp.net mvc

    The string “area” in Route values now has special meaning in ASP.NET MVC, in the same way that “controller” and “action” do. One implication is that if ...

    Pro ASP.NET MVC 5 epub

    The new, more tightly integrated, Visual Studio 2013 IDE has been created specifically with MVC application development in mind and provides a full suite of tools to improve development times and ...

    spring-boot-reference.pdf

    Auto-configured Spring REST Docs Tests with Mock MVC Auto-configured Spring REST Docs Tests with REST Assured 43.3.20. User Configuration and Slicing 43.3.21. Using Spock to Test Spring Boot ...

    Pro ASP.NET MVC 5.mobi

    The new, more tightly integrated, Visual Studio 2013 IDE has been created specifically with MVC application development in mind and provides a full suite of tools to improve development times and ...

    精通Asp.net MVC3(英文名字:Wrox.Professional.ASP.NET.MVC.3.Aug.2011)

    Explains the role of Controllers in the MVC framework and what role models play in binding and data access strategies Demonstrates how to display and process forms Covers the new features added in ...

    Programming Microsoft ASP.NET MVC, 3rd Edition

    Testing and testability in ASP.NET MVC Chapter 10. An executive guide to Web API Part III: Mobile clients Chapter 11. Effective JavaScript Chapter 12. Making websites mobile-friendly Chapter 13. ...

    java8集合源码分析-thinking-in-spring:小马哥极客时间Spring编程思想示例项目

    Binding) 类型装换(Type Conversion) Spring 表达式(Spring Express Language) 面向切面编程(AOP) 数据存储(Data Access) JDBC 事务抽象(Transactions) DAO 支持(DAO Support) O/R映射(O/R Mapping) XML 编列(XML ...

    C#应用BindingSource实现数据同步的方法

    本文以实例形式讲述了C#应用BindingSource实现数据同步的方法,对C#数据库程序开发来说具有一定的参考借鉴价值。具体实现方法如下: 下面的代码示例演示如何使用 BindingSource 组件,将三个控件(两个文本框控件和...

    Mastering.Spring.Cloud

    Mastering Spring Cloud Packt Upsell Why subscribe? PacktPub.com Contributors About the author About the reviewer Packt is searching for authors like you Preface Who this book is for What this book ...

    DeepDTA_Deep Drug-Target Binding Affinity Prediction2018.pdf

    The increase in the affinity data available in DT knowledge-bases allows the use of advanced learning techniques such as deep learning architectures in the prediction of binding affinities. In this ...

    Pro ASP.NET MVC 5.pdf

    The new, more tightly integrated, Visual Studio 2013 IDE has been created specifically with MVC application development in mind and provides a full suite of tools to improve development times and ...

Global site tag (gtag.js) - Google Analytics