View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
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, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.tuigwaa.plugin.database.component;
17  
18  import org.seasar.tuigwaa.controller.config.ValidatorUtils;
19  
20  import com.isenshi.util.CharUtil;
21  
22  public class ActionLink {
23  
24  	private String label;
25  
26  	private String path;
27  
28  	private boolean buttonFlag;
29  
30  	private boolean needConfirmation;
31  
32  	public ActionLink(String label, String path, boolean buttonFlag,
33  			boolean needConfirmation) {
34  		this.label = label;
35  		this.path = path;
36  		this.buttonFlag = buttonFlag;
37  		this.needConfirmation = needConfirmation;
38  	}
39  
40  	public String getLabel() {
41  		return label;
42  	}
43  
44  	public void setLabel(String label) {
45  		this.label = label;
46  	}
47  
48  	public String getPath() {
49  		return doCreatePath(path);
50  	}
51  
52  	public String getPath(Long id) {
53  		return doCreatePath(CharUtil.replace(path, "id", "" + id));
54  	}
55  
56  	public void setPath(String path) {
57  		this.path = path;
58  	}
59  
60  	public boolean isButtonFlag() {
61  		return buttonFlag;
62  	}
63  
64  	private String doCreatePath(String curPath) {
65  		if (needConfirmation) {
66  			boolean needMoreEncode = !buttonFlag;
67  			return ValidatorUtils.getDeleteConfirmationFunc(curPath,
68  					needMoreEncode);
69  		} else {
70  			return curPath;
71  		}
72  	}
73  
74  }