Released DotVVM 3.2 and Preview 1 of DotVVM 4.0

Published: 9/2/2021 2:56:30 PM

Few days ago, we have released DotVVM 3.2 which brings many important fixes and improvements over the previous versions. If you have already upgraded to DotVVM 3.0 or 3.1, you should definitely move to DotVVM 3.2 – we are not aware of any breaking changes so far, and there is a lot of improvements.


New JavaScript translations

If you adopted the new JS translations and started using LINQ and other methods in data-bindings, you’ll like the new additions we now support from DotVVM 3.2:

  • DateTime property getters
  • UrlEncode/UrlDecode in WebUtility
  • string.IsNullOrWhiteSpace
  • string.Equals and other methods with StringComparison overloads

Thanks to these new abilities, you can do more things on the client-side without communicating with the server. These methods can be used in static commands and value bindings.

Improvements

In DotVVM 3.0, we have introduced the new way of working with viewmodel on the client-side – the state API. However, not all parts of DotVVM were using this new API which could cause some weird behaviors and synchronization issues. If you wrote anything in the viewmodel using the Knockout observables, the changes were propagated into another observables asynchronously. From DotVVM 3.2, the static commands and REST API bindings are using the new state API, which fixes some problems and is also a bit faster.

We have also changed the way how REST API bindings client classes are generated, thanks to the new version of command-line tooling we introduced in DotVVM 3.1. When you try to regenerate the REST API bindings, you may find some changes in the generated code – mostly because of updated versions of the Swashbuckle packages which are responsible for generating the client classes.

See the full release notes for more information.


DotVVM 4.0 Preview 1

A lot of work has already been done on DotVVM 4.0 branch. We have published several internal previews and tested the release on several projects, and today we have published the first public preview of DotVVM 4.0.

It introduces a new and easy way of creating custom controls – the CompositeControl class. It is useful when you need to compose a control from one or more existing ones – you simply define the GetContents method which takes control properties as parameters, and returns the hierarchy of controls. There is also a new ValueOrBinding<T> class which helps to deal with properties that support both constant values and value bindings.

public class TextBoxFormField : CompositeControl
{
    public static DotvvmControl GetContents(
        ValueOrBinding<string> text,
        string labelText
    )
    {
        return new HtmlGenericControl("div")
            .SetAttribute("class", "form-item")
            .AppendChildren(
                new HtmlGenericControl("label")
                    .SetProperty(HtmlGenericControl.InnerTextProperty, labelText),
                new TextBox()
                    .SetProperty(TextBox.TextProperty, text),
                new Validator()
                    .SetProperty(Validator.ValueProperty, text)
            );            
    }
}

As you can see, the control creates a div element in which there is a label, TextBox and a Validator control. Such control can then be used like this:

<cc:TextBoxFormField Text="{value: FirstName}" LabelText="First Name" />

The Text property can contain a binding, because it is backed by a parameter with ValueOrBinding<string>. The LabelText property cannot use the binding, because the corresponding parameter in the GetContents method is just a string. You can declare binding-only properties by using IValueBinding<T>, and there are more rules and conventions that are respected by this method.

This new API allows us to build control wrappers (like Bootstrap for DotVVM, or wrappers for Fluent UI Web Components) more quickly, and it will also help you to get rid of repetitive portions of the markup.


We’ll be happy to hear your feedback. Just talk to us on Gitter chat, or join us on our regular monthly community meetups.

Tomáš Herceg

I am the CEO of RIGANTI, a small software development company located in Prague, Czech Republic.

I am Microsoft Most Valuable Professional and the founder of DotVVM project.


Subscribe to the newsletter!

Thank you for subscribing!


Social Sites


Popular