Git Product home page Git Product logo

caisson's People

Contributors

v79 avatar

Watchers

 avatar  avatar

caisson's Issues

Bind models from JSON objects

The client could submit a JSON string as a parameter presenting an object. We could use GSON or something to construct the model object from the JSON string.

See Ktor ContentNegotiation for inspiration.

But how would this fit with with our flow? Probably a different implementation and binding, request.bindJson<Person>()?

Provide a way of overriding the parameter names when binding

Currently, the input name in the view must match the property name in the constructor of the model class. Consider providing a way of overriding this so that the view name can be different.

Perhaps as an annotation, or an additional parameter to the bind() method. Perhaps a map?

Introduce a compound converter annotation to bundle together related fields as a single object

In a web form, a person's address will typically have a number of fields (3 lines, plus town, country, postcode, etc). Rather than requiring the model class to list all of these, allow the developer to create a class which represents an entire address. Use an annotation to tell Caisson to 'bundle up' all the related fields as a single object.

data class Address(val addr1: String, val town: String //etc)
data class Person(val name: String, @CCompoundConverter(AddressConverter::class) val address: Address)

To make this work we'll have to enforce a naming scheme on the HTML form elements. Perhaps each of the address input fields will need to be prepended with the name of the constructor parameter? E.g.

<input type="text" name="address.addr1"/>
<input type="text" name="address.town"/>
<!-- etc -->

Ensure that init block is called

Create a class with some additional properties that are set during the init{} block and test these values are set during binding.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.