[[are-you-sure]]
= 'Are you sure?' idiom

:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
:page-partial:


Sometimes an action might perform irreversible changes.
In such a case it's probably a good idea for the UI to require that the end-user explicitly confirms that they intended to invoke the action.


One way to meet this requirement is using the framework's built-in xref:refguide:applib:index/annotation/Action.adoc#semantics[@Action#semantics] attribute:

[source,java]
----
@Action(
        semantics = SemanticsOf.IDEMPOTENT_ARE_YOU_SURE
)
public SimpleObject updateName(
        @Parameter(maxLength = NAME_LENGTH)
        @ParameterLayout(named = "New name")
        final String name) {
    setName(name);
    return this;
}
----


This will render as:

image::hints-and-tips/action-semantics-are-you-sure.png[]


