    001// Copyright 2013 The Apache Software Foundation
    002//
    003// Licensed under the Apache License, Version 2.0 (the "License");
    004// you may not use this file except in compliance with the License.
    005// You may obtain a copy of the License at
    006//
    007//     http://www.apache.org/licenses/LICENSE-2.0
    008//
    009// Unless required by applicable law or agreed to in writing, software
    010// distributed under the License is distributed on an "AS IS" BASIS,
    011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012// See the License for the specific language governing permissions and
    013// limitations under the License.
    014
    015package org.apache.tapestry5.corelib.mixins;
    016
    017import org.apache.tapestry5.BindingConstants;
    018import org.apache.tapestry5.MarkupWriter;
    019import org.apache.tapestry5.annotations.Import;
    020import org.apache.tapestry5.annotations.MixinAfter;
    021import org.apache.tapestry5.annotations.Parameter;
    022
    023/**
    024 * A mixin that can be placed on a clickable component, such as {@link org.apache.tapestry5.corelib.components.LinkSubmit},
    025 * and will raise a confirmation dialog when the element is clicked.
    026 * <p/>
    027 * Due to conflicts between jQuery (as used by Bootstrap's JavaScript library) and Prototype, this mixin does not operate
    028 * when the {@linkplain org.apache.tapestry5.SymbolConstants#JAVASCRIPT_INFRASTRUCTURE_PROVIDER JavaScript infrastructure provider}
    029 * is "prototype".
    030 *
    031 * @tapestrydoc
    032 * @since 5.4
    033 */
    034@MixinAfter
    035@Import(module = "t5/core/confirm-click")
    036public class Confirm
    037{
    038    /**
    039     * The message to present to the user in the body of the modal dialog.
    040     */
    041    @Parameter(value = "message:private-default-confirm-message", defaultPrefix = BindingConstants.LITERAL)
    042    private String message;
    043
    044    /**
    045     * The title for the modal dialog.
    046     */
    047    @Parameter(value = "message:private-default-confirm-title", defaultPrefix = BindingConstants.LITERAL)
    048    private String title;
    049
    050    void beginRender(MarkupWriter writer)
    051    {
    052        writer.attributes("data-confirm-title", title,
    053                "data-confirm-message", message);
    054    }
    055}