Skip to content

[Discussion] Do we need to add advice on usage of dynamic bloc #121

@benjamin-dreux

Description

@benjamin-dreux

In the last few days I'm using more and more HtmlFlow.

At first i tended use dynamic bloc in the lowest place possible in the html tree.

Then I wonder what would happened if I switched to a using it the other way arround.

Now I'm back to the lowest place possible.

My reason is to be able to compose my page view more easly.

See some of my exemples

static void template(Div<?> container) {
        // spotless:off
        container
            .form()
                .attrMethod(EnumMethodType.POST)
                .attrId("contact")
                .<ContactEditModel>dynamic((form, model) -> form
                    .attrAction("/contacts/%s/update".formatted(model.id()))
                )           
                .of( ContactEditView::hiddenInputId )       
                .of( ContactEditView::isOrganizationField )       
                .of( ContactEditView::firstNameField)
                .of( ContactEditView::lastNameField)
                .of( ContactEditView::nameField)
                
                
                .of(ContactEditView::addressBlock)
                .of(ContactEditView::telephoneBlock)
                .of(ContactEditView::emailBlock)
                
                .of(ContactEditView::buttonsBlock)

            .__();
            // spotless:on
    }
   static void hiddenInputId(Form<?> parent) {
        // spotless:off
        parent.input()
            .attrType(EnumTypeInputType.HIDDEN)
            .attrName("id")
            .<ContactEditModel>dynamic((input, model) -> 
                    input 
                    .attrValue("%s".formatted(model.id()))
            )
            
        .__();
        // spotless:on
    }
....

This is one of the cool thing of this library, we can compose views.
What I want to discuss is, should the documentation push the user in using the dynamic block on the lower position.
What I assume to be a side benefit is the fact that the cache of the view is better used with the way of using htmlFlow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions