[richfaces-svn-commits] JBoss Rich Faces SVN: r2104 - in trunk: samples/calendar-sample/src/main/webapp/pages and 5 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Aug 7 11:31:17 EDT 2007


Author: akushunin
Date: 2007-08-07 11:31:17 -0400 (Tue, 07 Aug 2007)
New Revision: 2104

Modified:
   trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java
   trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
   trunk/ui/calendar/src/main/config/component/calendar.xml
   trunk/ui/calendar/src/main/java/
   trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
   trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
   trunk/ui/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java
   trunk/ui/calendar/src/test/java/org/richfaces/component/CurrentDateEventTest.java
Log:
added new atribute boundaryDateMode.
Updated sample.
Some corretions in JUnit Tests.

Modified: trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java
===================================================================
--- trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java	2007-08-07 14:56:08 UTC (rev 2103)
+++ trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java	2007-08-07 15:31:17 UTC (rev 2104)
@@ -29,15 +29,17 @@
 
 /**
  * 20/07/2007
- * @author Alexej Kushunin 
- * @mailto: akushunin at exadel.com 
- *
+ * 
+ * @author Alexej Kushunin
+ * @mailto: akushunin at exadel.com
+ * 
  */
 public class CalendarBean {
-	
-	private static final String[] WEEK_DAY_LABELS = new String[] {"Sun *", "Mon +", "Tue +", "Wed +", "Thu +", "Fri +", "Sat *"};
+
+	private static final String[] WEEK_DAY_LABELS = new String[] { "Sun *",
+			"Mon +", "Tue +", "Wed +", "Thu +", "Fri +", "Sat *" };
 	private Locale locale;
-	
+
 	private boolean popup;
 	private boolean readonly;
 	private String pattern;
@@ -46,9 +48,10 @@
 	private String jointPoint;
 	private String direction;
 	private String inputType;
-	
+	private String boundary;
+
 	private boolean useCustomDayLabels;
-	
+
 	public Locale getLocale() {
 		return locale;
 	}
@@ -57,7 +60,6 @@
 		this.locale = locale;
 	}
 
-	
 	public boolean isPopup() {
 		return popup;
 	}
@@ -65,7 +67,6 @@
 	public void setPopup(boolean popup) {
 		this.popup = popup;
 	}
-	
 
 	public String getPattern() {
 		return pattern;
@@ -76,17 +77,17 @@
 	}
 
 	public CalendarBean() {
-		
+
 		locale = Locale.US;
 		popup = true;
 		pattern = "MMM d, yyyy";
 		jointPoint = "bottom-left";
 		direction = "bottom-right";
-		readonly=true;
-		inputType="readonly";
+		readonly = true;
+		inputType = "readonly";
+		boundary = "inactive";
 	}
-	
-	
+
 	public String getInputType() {
 		return inputType;
 	}
@@ -103,13 +104,13 @@
 		this.readonly = readonly;
 	}
 
-	public void selectLocale(ValueChangeEvent event){
-		
+	public void selectLocale(ValueChangeEvent event) {
+
 		String tLocale = (String) event.getNewValue();
 		if (tLocale != null) {
-			String lang = tLocale.substring(0,2);
+			String lang = tLocale.substring(0, 2);
 			String country = tLocale.substring(3);
-			locale = new Locale(lang,country,"");
+			locale = new Locale(lang, country, "");
 		}
 	}
 
@@ -120,7 +121,7 @@
 	public void setUseCustomDayLabels(boolean useCustomDayLabels) {
 		this.useCustomDayLabels = useCustomDayLabels;
 	}
-	
+
 	public Object getWeekDayLabelsShort() {
 		if (isUseCustomDayLabels()) {
 			return WEEK_DAY_LABELS;
@@ -132,9 +133,10 @@
 	public String getCurrentDateAsText() {
 		Date currentDate = getCurrentDate();
 		if (currentDate != null) {
-			return DateFormat.getDateInstance(DateFormat.FULL).format(currentDate);
+			return DateFormat.getDateInstance(DateFormat.FULL).format(
+					currentDate);
 		}
-		
+
 		return null;
 	}
 
@@ -153,23 +155,37 @@
 	public void setSelectedDate(Date selectedDate) {
 		this.selectedDate = selectedDate;
 	}
-	
+
 	public String getJointPoint() {
 		return jointPoint;
 	}
+
 	public void setJointPoint(String jointPoint) {
 		this.jointPoint = jointPoint;
 	}
-	public void selectJointPoint(ValueChangeEvent event){
+
+	public void selectJointPoint(ValueChangeEvent event) {
 		jointPoint = (String) event.getNewValue();
 	}
+
 	public String getDirection() {
 		return direction;
 	}
+
 	public void setDirection(String direction) {
 		this.direction = direction;
 	}
-	public void selectDirection(ValueChangeEvent event){
+
+	public void selectDirection(ValueChangeEvent event) {
 		direction = (String) event.getNewValue();
 	}
+
+	public String getBoundary() {
+		return boundary;
+	}
+
+	public void setBoundary(String boundary) {
+		this.boundary = boundary;
+	}
+
 }
\ No newline at end of file

Modified: trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
===================================================================
--- trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp	2007-08-07 14:56:08 UTC (rev 2103)
+++ trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp	2007-08-07 15:31:17 UTC (rev 2104)
@@ -45,7 +45,8 @@
 					jointPoint="#{calendarBean.jointPoint}"
 					direction="#{calendarBean.direction}"
 					buttonLabel="PopUp"					
-					inputType="#{calendarBean.inputType}">
+					inputType="#{calendarBean.inputType}"
+					boundaryDatesMode="#{calendarBean.boundary}">
 					
 					<f:validator validatorId="org.richfaces.CalendarValidator" />
 					
@@ -100,6 +101,12 @@
 						<f:selectItem itemLabel="hidden" itemValue="hidden"/>
 						<f:selectItem itemLabel="editable" itemValue="editable"/>						
 					</h:selectOneRadio>
+					<h:outputText value="BoundaryDatesMode:" />
+					<h:selectOneRadio onclick="submit()" value="#{calendarBean.boundary}">
+						<f:selectItem itemLabel="inactive" itemValue="inactive"/>
+						<f:selectItem itemLabel="select" itemValue="select"/>
+						<f:selectItem itemLabel="scroll" itemValue="scroll"/>						
+					</h:selectOneRadio>
 								
 		
 

Modified: trunk/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- trunk/ui/calendar/src/main/config/component/calendar.xml	2007-08-07 14:56:08 UTC (rev 2103)
+++ trunk/ui/calendar/src/main/config/component/calendar.xml	2007-08-07 15:31:17 UTC (rev 2104)
@@ -163,7 +163,14 @@
 			<classname>java.lang.String</classname>
 			<description></description>
 			<defaultvalue>"readonly"</defaultvalue>
-		</property>		
+		</property>
+		<property>
+			<name>boundaryDatesMode</name>
+			<classname>java.lang.String</classname>
+			<description></description>
+			<defaultvalue>"inactive"</defaultvalue>
+		</property>
+				
 		
 	</component>
 </components>


Property changes on: trunk/ui/calendar/src/main/java
___________________________________________________________________
Name: svn:ignore
   + META-INF


Modified: trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
--- trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java	2007-08-07 14:56:08 UTC (rev 2103)
+++ trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java	2007-08-07 15:31:17 UTC (rev 2104)
@@ -125,7 +125,6 @@
 
 	public abstract void setDisabled(boolean disabled);
 
-
 	public abstract String getButtonLabel();
 
 	public abstract void setButtonLabel(String buttonLabel);
@@ -138,8 +137,12 @@
 
 	public abstract void setInputType(String inputType);
 	
+	public abstract String getBoundaryDatesMode();
 
+	public abstract void setBoundaryDatesMode(String boundaryDatesMode);
+	
 
+
 	// currentDate processing -------------------------------------------------
 
 	public Calendar getCalendar() {

Modified: trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx	2007-08-07 14:56:08 UTC (rev 2103)
+++ trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx	2007-08-07 15:31:17 UTC (rev 2104)
@@ -31,6 +31,7 @@
 				jointPoint: '#{component.jointPoint}',
 				direction: '#{component.direction}',
 				toolTipMode:'#{component.toolTipMode}',
+				boundaryDatesMode:'#{component.boundaryDatesMode}',
 				popup: #{component.popup},
 				disabled: #{component.disabled},
 				<f:call name="writeSymbols" />,

Modified: trunk/ui/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java
===================================================================
--- trunk/ui/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java	2007-08-07 14:56:08 UTC (rev 2103)
+++ trunk/ui/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java	2007-08-07 15:31:17 UTC (rev 2104)
@@ -18,6 +18,7 @@
 import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
 import org.apache.commons.lang.StringUtils;
 
+import com.gargoylesoftware.htmlunit.ElementNotFoundException;
 import com.gargoylesoftware.htmlunit.html.HtmlButton;
 import com.gargoylesoftware.htmlunit.html.HtmlElement;
 import com.gargoylesoftware.htmlunit.html.HtmlInput;
@@ -35,6 +36,8 @@
 
 	private UICalendar calendar;
 
+	private UICalendar calendar1;
+
 	private static Set javaScripts = new HashSet();
 
 	static {
@@ -42,7 +45,8 @@
 		javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
 		javaScripts.add("org/richfaces/renderkit/html/scripts/events.js");
 		javaScripts.add("org/richfaces/renderkit/html/scripts/utils.js");
-		javaScripts.add("org/richfaces/renderkit/html/scripts/json/json-dom.js");
+		javaScripts
+				.add("org/richfaces/renderkit/html/scripts/json/json-dom.js");
 		javaScripts.add("org/richfaces/renderkit/html/scripts/calendar.js");
 	}
 
@@ -57,25 +61,30 @@
 		form = new HtmlForm();
 		form.setId("form");
 		facesContext.getViewRoot().getChildren().add(form);
-		calendar = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE);
+		calendar = (UICalendar) application
+				.createComponent(UICalendar.COMPONENT_TYPE);
+		calendar1 = (UICalendar) application
+				.createComponent(UICalendar.COMPONENT_TYPE);
 		calendar.setLocale(Locale.UK);
 		calendar.setDatePattern("d/MM/yyyy");
 		calendar.setTimeZone(TimeZone.getTimeZone("Europe/London"));
-		/*String[] strarr = TimeZone.getAvailableIDs();
-		for(int i=0; i < strarr.length; i++){
-			System.out.println(strarr[i]);	
-		}	*/	
+		/*
+		 * String[] strarr = TimeZone.getAvailableIDs(); for(int i=0; i <
+		 * strarr.length; i++){ System.out.println(strarr[i]); }
+		 */
 		calendar.setButtonLabel("PopUp");
-		//TODO test popup false
-		//TODO test CurrentDate = null
+		// XXX test popup false
+		// XXX test CurrentDate = null
 		calendar.setPopup(true);
 		Calendar calendarObject = Calendar.getInstance();
-		calendarObject.set(2001, Calendar.SEPTEMBER, 11,1,1,1);
+		calendarObject.set(2001, Calendar.SEPTEMBER, 11, 1, 1, 1);
 		calendar.setId("calendar");
 		calendar.setSubmittedValue(calendarObject.getTime());
 		form.getChildren().add(calendar);
-		
-
+		calendar1.setId("_calendar");
+		calendar1.setPopup(false);
+		calendar1.setCurrentDate(null);
+		form.getChildren().add(calendar1);
 	}
 
 	/*
@@ -151,80 +160,112 @@
 
 	public void testCalendarRenderer() throws Exception {
 
-/*		UIViewRoot root = facesContext.getViewRoot();
-    	root.processDecodes(facesContext);
-    	root.processValidators(facesContext);
-    	root.processUpdates(facesContext);
-    	root.processApplication(facesContext);
-*/		
+		/*
+		 * UIViewRoot root = facesContext.getViewRoot();
+		 * root.processDecodes(facesContext);
+		 * root.processValidators(facesContext);
+		 * root.processUpdates(facesContext);
+		 * root.processApplication(facesContext);
+		 */
 		HtmlPage page = renderView();
 		assertNotNull(page);
 		//System.out.println(page.asXml());
-		
-		HtmlElement htmlCalendar = page.getHtmlElementById(calendar.getClientId(facesContext));
+
+		HtmlElement htmlCalendar = page.getHtmlElementById(calendar
+				.getClientId(facesContext));
 		assertNotNull(htmlCalendar);
-				
-		HtmlInput htmlCalendarInput = (HtmlInput) page.getHtmlElementById(calendar.getClientId(facesContext)+"InputDate");
-		HtmlButton htmlCalendarButton = (HtmlButton) page.getHtmlElementById(calendar.getClientId(facesContext)+"PopupButton");
-		HtmlSpan htmlCalendarSpan =(HtmlSpan) page.getHtmlElementById(calendar.getClientId(facesContext)+"Popup");
+
+		HtmlInput htmlCalendarInput = (HtmlInput) page
+				.getHtmlElementById(calendar.getClientId(facesContext)
+						+ "InputDate");
+		HtmlButton htmlCalendarButton = (HtmlButton) page
+				.getHtmlElementById(calendar.getClientId(facesContext)
+						+ "PopupButton");
+		HtmlSpan htmlCalendarSpan = (HtmlSpan) page.getHtmlElementById(calendar
+				.getClientId(facesContext)
+				+ "Popup");
 		assertNotNull(htmlCalendarInput);
 		assertNotNull(htmlCalendarButton);
 		assertNotNull(htmlCalendarSpan);
-		
-    	assertEquals("10/09/2001", htmlCalendarInput.getValueAttribute());
 
+		assertEquals("10/09/2001", htmlCalendarInput.getValueAttribute());
+
+		HtmlElement htmlCalendar1 = page.getHtmlElementById(calendar1
+				.getClientId(facesContext));
+		assertNotNull(htmlCalendar1);
+
+		try {
+			HtmlInput htmlCalendarInput1 = (HtmlInput) page
+					.getHtmlElementById(calendar1.getClientId(facesContext)
+							+ "InputDate");
+		} catch (ElementNotFoundException e) {
+			assertNotNull(e);
+		}
+		try {
+			HtmlButton htmlCalendarButton1 = (HtmlButton) page
+					.getHtmlElementById(calendar1.getClientId(facesContext)
+							+ "PopupButton");
+		} catch (ElementNotFoundException e) {
+			assertNotNull(e);
+		}
+		try {
+			HtmlSpan htmlCalendarSpan1 = (HtmlSpan) page
+					.getHtmlElementById(calendar1.getClientId(facesContext)
+							+ "Popup");
+		} catch (ElementNotFoundException e) {
+			assertNotNull(e);
+		}
+		//System.out.println(page.asXml());
 	}
-	
-	public void testCalendarDecode() throws Exception{
-		//TODO Add set Date and time
+
+	public void testCalendarDecode() throws Exception {
+		// XXX Add set Date and time
+		Calendar calendarObject = Calendar.getInstance();
+		calendarObject.set(2001, Calendar.SEPTEMBER, 11, 1, 1, 1);
 		calendar.decode(facesContext);
-		assertEquals("Tue Sep 11 01:01:01 EEST 2001", calendar.getSubmittedValue().toString());
-		Calendar calendarObject = Calendar.getInstance();
-		calendarObject.set(2002, Calendar.SEPTEMBER, 11,1,1,1);
+		assertEquals(calendarObject.getTime(), calendar.getSubmittedValue());
+		calendarObject.set(2002, Calendar.SEPTEMBER, 11, 1, 1, 1);
 		calendar.updateCurrentDate(facesContext, calendarObject.getTime());
-		assertEquals("Wed Sep 11 01:01:01 EEST 2002", calendar.getCurrentDate().toString());
-    	//assertEquals("11/09/2001", htmlCalendarInput.getValueAttribute());
+		assertEquals(calendarObject.getTime(), calendar.getCurrentDate());
 
-		
 	}
-	
+
 	public void testCalendarStyles() throws Exception {
-		 HtmlPage page = renderView();
-	        assertNotNull(page);
-	        //System.out.println(page.asXml());
-	        List links = page.getDocumentElement().getHtmlElementsByTagName("link");
-	        assertEquals(1, links.size());
-	        HtmlElement link = (HtmlElement) links.get(0);
-	        assertTrue(link.getAttributeValue("href").contains("css/calendar.xcss"));
+		HtmlPage page = renderView();
+		assertNotNull(page);
+		// System.out.println(page.asXml());
+		List links = page.getDocumentElement().getHtmlElementsByTagName("link");
+		assertEquals(1, links.size());
+		HtmlElement link = (HtmlElement) links.get(0);
+		assertTrue(link.getAttributeValue("href").contains("css/calendar.xcss"));
 	}
 
 	public void testCalendarScrits() throws Exception {
 		HtmlPage page = renderView();
 		assertNotNull(page);
-		
+
 		List scripts = page.getDocumentElement().getHtmlElementsByTagName(
 				"script");
 		for (Iterator it = scripts.iterator(); it.hasNext();) {
 			HtmlScript item = (HtmlScript) it.next();
 			String srcAttr = item.getSrcAttribute();
-			if(item.getFirstChild()!=null ){
+			if (item.getFirstChild() != null) {
 				String scriptBodyString = item.getFirstChild().toString();
-				if(scriptBodyString.contains("new Calendar")){
+				if (scriptBodyString.contains("new Calendar")&&scriptBodyString.contains("form:calendar")) {
 					
-				assertTrue(scriptBodyString.contains("datePattern"));
-				assertTrue(scriptBodyString.contains("d/MM/yyyy"));
-				assertTrue(scriptBodyString.contains("selectedDate"));
-				assertTrue(scriptBodyString.contains("Date(2001,8,11)"));
-				assertTrue(scriptBodyString.contains("popup: true"));
-	
+					assertTrue(scriptBodyString.contains("datePattern"));
+					assertTrue(scriptBodyString.contains("d/MM/yyyy"));
+					assertTrue(scriptBodyString.contains("selectedDate"));
+					assertTrue(scriptBodyString.contains("Date(2001,8,11)"));
+					assertTrue(scriptBodyString.contains("popup: true"));
+
+				}
 			}
-			}
 
 			if (StringUtils.isNotBlank(srcAttr)) {
 				boolean found = false;
 				for (Iterator srcIt = javaScripts.iterator(); srcIt.hasNext();) {
 					String src = (String) srcIt.next();
-
 					found = srcAttr.contains(src);
 					if (found) {
 						break;

Modified: trunk/ui/calendar/src/test/java/org/richfaces/component/CurrentDateEventTest.java
===================================================================
--- trunk/ui/calendar/src/test/java/org/richfaces/component/CurrentDateEventTest.java	2007-08-07 14:56:08 UTC (rev 2103)
+++ trunk/ui/calendar/src/test/java/org/richfaces/component/CurrentDateEventTest.java	2007-08-07 15:31:17 UTC (rev 2104)
@@ -56,7 +56,7 @@
         calendar = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE);;
         event1 = new CurrentDateChangeEvent (calendar, "11/2001");
         cal = Calendar.getInstance();
-        cal.set(2001, 0, 9);
+        cal.set(2001, 10, 10);
         event2 = new CurrentDateChangeEvent (calendar, cal.getTime());
         event4 = new CurrentDateChangeEvent (calendar, "");
         event3 = new AjaxEvent(calendar);
@@ -78,13 +78,11 @@
     }
     public void testBrodcastEvent() throws Exception{
     	
-    	calendar.broadcast(event4);
-    	calendar.broadcast(event1);
+ //   	calendar.broadcast(event4);
+  //  	calendar.broadcast(event1);
     	calendar.broadcast(event3);
-    	System.out.println(calendar.getCurrentDate().toString());
+ //     	calendar.broadcast(event2);
     	
-    // 	calendar.broadcast(event2);
-    	
     }
  
 }




More information about the richfaces-svn-commits mailing list