View Javadoc

1   /*
2    * Copyright 2004-2005 Andreas Andreou
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *  http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.tapfx.components.confirm;
17  
18  import org.apache.tapestry.ApplicationRuntimeException;
19  import org.apache.tapestry.BaseComponent;
20  
21  /***
22   * @author <a href="mailto:shomburg@hsofttec.com">S.Homburg</a>
23   * @version $Id: ConfirmLink.java,v 1.2 2005/11/07 20:00:19 andyhot Exp $
24   */
25  public abstract class ConfirmLink extends BaseComponent
26  {
27      public abstract String getKey();
28      public abstract String getMessage();
29  
30      public String getOnClickCommand()
31      {
32          String message = getKey();
33          if (message == null)
34              message = getMessage();
35          else
36              message = getPage().getMessages().getMessage(message);
37  
38          if (message == null)
39              throw new ApplicationRuntimeException("Neither 'key' nor 'message' parameters were specified!");
40          return "return confirm('" + message + "');";
41      }
42  }