TOC PREV NEXT INDEX



PDF
ICEfaces Online Reference




 


 




Modifying TimeZoneWrapper.java


Each row in the dataTable is populated by a TimeZoneWrapper bean. Each cell in the dataTable is then populated by properties of the TimeZoneWrapper beans. So, we have to modify TimeZoneWrapper to add the requisite properties and accessor methods.

1. Add imports for the utility classes we use for calculating times with.
import java.util.TimeZone;
 
import java.util.Calendar;
 
import java.text.DateFormat;
 

 
2. Declare a String to hold the associated selectBooleanCheckbox component ID.
private String checkboxId;
 
3. Declare a helper DateFormat instance for the time bean property.
private DateFormat dateFormat;
 
4. Alter the constructor to initialize the new fields; checkboxId and dateFormat.
/**
 
 * @param id id used to identify the time zone.
 
 * @param mapId map button component id in web page
 
 * @param checkId checkbox component id in web page
 
 */
 
public TimeZoneWrapper(String id, String mapId, String checkId)
 
{
 
		this.id = id;
 
		this.mapCommandButtonId = mapId;
 
		this.checkboxId = checkId;
 
		this.dateFormat = TimeZoneBean.buildDateFormatForTimeZone(
 
				TimeZone.getTimeZone(id) );
 
}
 

 
5. Add getter accessor methods for the displayName, time, useDaylightTime, inDaylightTime, location properties.
public String getDisplayName() {
 
		TimeZone timeZone = TimeZone.getTimeZone(id); 
 
		return TimeZoneBean.displayNameTokenizer( timeZone.getDisplayName() );
 
}
 
...
 
public String getTime() {
 
		return TimeZoneBean.formatCurrentTime( dateFormat );
 
}
 
...
 
public String getUseDaylightTime() {
 
		TimeZone timeZone = TimeZone.getTimeZone(id); 
 
		if( timeZone.useDaylightTime() )
 
				return "Yes"; 
 
		return "No";
 
}
 
...
 
public String getInDaylightTime() {
 
		TimeZone timeZone = TimeZone.getTimeZone(id);
 
		Calendar cal = Calendar.getInstance(timeZone); 
 
		if( timeZone.inDaylightTime(cal.getTime()) )
 
				return "Yes"; 
 
		return "No";
 
}
 
...
 
public String getLocation() {
 
		return id;
 
}
 

 
6. Modify isRelevantComponentId(String) to add support for our new checkbox component ID.
public boolean isRelevantComponentId(String componentId) {
 
		boolean relevant = ( componentId.endsWith(mapCommandButtonId) ||
 
		                     componentId.endsWith(checkboxId) ); 
 
		return relevant;
 
}
 

 
7. Add a getter accessor method for our new checkboxId property.
public String getCheckboxId() {
 
		return checkboxId;
 
}
 


Copyright 2005-2006. ICEsoft Technologies, Inc.
http://www.icesoft.com

TOC PREV NEXT INDEX