How to set a default value to a DateField?

Hi,
How can I set a default date to a DateField which name is wodateField? I only find the method getValue(),setRangeStart(),setRangeEnd(). There’s no setValue().

    <layout expand="ccsWoesTable"
            spacing="true">
        <filter id="filter"
                applyTo="ccsWoesTable"
                datasource="ccsWoesDs">
            <properties include=".*"/>
        </filter>
        <table id="ccsWoesTable"
               multiselect="true"
               width="100%">
            <actions>
                <action id="create"/>
                <action id="edit"/>
                <action id="remove"/>
                <action id="upload"
                        invoke="upload"/>
            </actions>
            <columns>
                <column id="wodate"/>
                <column id="dpment"/>
                <column id="shf"/>
                <column id="begintime"/>
                <column id="endtime"/>
                <column id="hrs"/>
            </columns>
            <rows datasource="ccsWoesDs"/>
            <rowsCount/>
            <buttonsPanel id="buttonsPanel"
                          alwaysVisible="true">
                <button id="createBtn"
                        action="ccsWoesTable.create"
                        caption="msg://btn_create"/>
                <button id="editBtn"
                        action="ccsWoesTable.edit"
                        caption="msg://btn_edit"/>
                <button id="removeBtn"
                        action="ccsWoesTable.remove"
                        caption="msg://btn_delete"/>
            </buttonsPanel>
        </table>
        <buttonsPanel>
            <dateField id="wodateField"
                       dateFormat="yyyy/MM/dd"
                       width="199px"/>
            <lookupField id="shiftField"/>
            <button id="uploadBtn"
                    action="ccsWoesTable.upload"
                    caption="msg://btn_upload"/>
        </buttonsPanel>
    </layout>

Hello, @thomaslei

You can set a value to the DateField component in the same way as for other components:

screen descriptor:

<dateField id="dateField"/>

screen controller:

@Inject
private DateField dateField;

@Override
public void init(Map<String, Object> params) {
    super.init(params);

    dateField.setValue(new Date());
}

Regards,
Daniil

Hi,
It works well. Thank you

Another method :slight_smile:

image

Thank you very much. You put the value in the entity.