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.hivemind.ApplicationRuntimeException;
19  import org.apache.tapestry.BaseComponent;
20  
21  /***
22   * @author <a href="mailto:shomburg@hsofttec.com">S.Homburg</a>
23   * @author andyhot
24   * @version $Id: ConfirmLink.java,v 1.3 2005/11/07 03:24:06 andyhot Exp $
25   */
26  public abstract class ConfirmLink extends BaseComponent
27  {
28      public abstract String getKey();
29      public abstract String getMessage();
30  
31      public String getOnClickCommand()
32      {
33          String message = getKey();
34          if (message == null)
35              message = getMessage();
36          else
37              message = getPage().getMessages().getMessage(message);
38  
39          if (message == null)
40              throw new ApplicationRuntimeException("Neither 'key' nor 'message' parameters were specified!");
41          
42          return "return confirm('" + message + "');";
43      }
44      
45    
46  }