View Javadoc

1   // Copyright 2008 Thiago H. de Paula Figueiredo
2   //
3   // Licensed under the Apache License, Version 2.0 (the "License");
4   // you may not use this file except in compliance with the License.
5   // You may obtain a copy of the License at
6   //
7   //     http://www.apache.org/licenses/LICENSE-2.0
8   //
9   // Unless required by applicable law or agreed to in writing, software
10  // distributed under the License is distributed on an "AS IS" BASIS,
11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  // See the License for the specific language governing permissions and
13  // limitations under the License.
14  
15  package br.com.arsmachina.tapestrycrud.components;
16  
17  
18  import org.apache.tapestry5.BindingConstants;
19  import org.apache.tapestry5.annotations.BeforeRenderBody;
20  import org.apache.tapestry5.annotations.IncludeStylesheet;
21  import org.apache.tapestry5.annotations.Parameter;
22  import org.apache.tapestry5.corelib.components.Grid;
23  
24  import br.com.arsmachina.tapestrycrud.Constants;
25  
26  /**
27   * Component used to easily standardize and internationalize the 
28   * {@link Grid}'s "no records to display" message.
29   * It puts the message inside a <code>div</code> with class <code>t-crud-emptygrid</code>.
30   * <a href="http://ars-machina.svn.sourceforge.net/viewvc/ars-machina/example/trunk/src/main/webapp/project/ListProject.tml?view=markup"
31   * 		>Ars Machina Project Example</a>.
32   * 
33   * @author Thiago H. de Paula Figueiredo
34   */
35  @IncludeStylesheet(Constants.TAPESTRY_CRUD_CSS_ASSET)
36  public class EmptyGridMessage {
37  
38  	/**
39  	 * Key of the empty grid message.
40  	 */
41  	public static final String MESSAGE_GRID_EMPTY = "message.grid.empty";
42  
43  	/**
44  	 * Generated <code>&lt;p&gt;</code> CSS class.
45  	 */
46  	public static final String CSS_CLASS = "t-crud-emptygrid";
47  
48  	/**
49  	 * Message to be shown.
50  	 */
51  	@Parameter(defaultPrefix = BindingConstants.MESSAGE, value = MESSAGE_GRID_EMPTY)
52  	private String message;
53  
54  	/**
55  	 * Returns the value of the <code>message</code> property.
56  	 * 
57  	 * @return a {@link String}.
58  	 */
59  	public String getMessage() {
60  		return message;
61  	}
62  
63  	/**
64  	 * Changes the value of the <code>message</code> property.
65  	 * 
66  	 * @param message a {@link String}.
67  	 */
68  	public void setMessage(String message) {
69  		this.message = message;
70  	}
71  	
72  	/**
73  	 * Discards the tag body.
74  	 * @return <code>false</code>.
75  	 */
76  	@BeforeRenderBody
77  	public boolean discardBody() {
78  		return false;
79  	}
80  
81  }