JBoss Rich Faces SVN: r20135 - trunk/ui/input/ui/src/main/java/org/richfaces/utils.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-11-22 14:18:00 -0500 (Mon, 22 Nov 2010)
New Revision: 20135
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/utils/CalendarHelper.java
Log:
https://jira.jboss.org/browse/RF-9685 Calendar component: client-side events
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/utils/CalendarHelper.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/utils/CalendarHelper.java 2010-11-22 18:57:32 UTC (rev 20134)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/utils/CalendarHelper.java 2010-11-22 19:18:00 UTC (rev 20135)
@@ -33,6 +33,7 @@
import javax.faces.FacesException;
import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.DateTimeConverter;
@@ -126,7 +127,9 @@
return result;
}
- public static Locale getAsLocale(FacesContext facesContext, AbstractCalendar calendar) {
+ public static Locale getAsLocale(FacesContext facesContext, UIComponent component) {
+ AbstractCalendar calendar=(AbstractCalendar) component;
+
if (calendar == null || facesContext == null) {
return null;
}
14 years, 1 month
JBoss Rich Faces SVN: r20134 - sandbox/trunk/examples/fileupload-demo/src/main/webapp.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-11-22 13:57:32 -0500 (Mon, 22 Nov 2010)
New Revision: 20134
Modified:
sandbox/trunk/examples/fileupload-demo/src/main/webapp/fileupload.xhtml
Log:
RF-9501
Modified: sandbox/trunk/examples/fileupload-demo/src/main/webapp/fileupload.xhtml
===================================================================
--- sandbox/trunk/examples/fileupload-demo/src/main/webapp/fileupload.xhtml 2010-11-22 18:35:31 UTC (rev 20133)
+++ sandbox/trunk/examples/fileupload-demo/src/main/webapp/fileupload.xhtml 2010-11-22 18:57:32 UTC (rev 20134)
@@ -4,6 +4,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j"
xmlns:fu="http://richfaces.org/fileUpload">
<!--
JBoss, Home of Professional Open Source
@@ -41,7 +42,7 @@
<br />
<fu:fileUpload fileUploadListener="#{fileUploadBean.listener}"/>
<h:outputText value="File name:" />
- <h:outputText value="#{fileUploadBean.item.fileName}" />
+ <a4j:outputPanel ajaxRendered="true">#{fileUploadBean.item.fileName}</a4j:outputPanel>
<input type="submit" />
</h:form>
</h:body>
14 years, 1 month
JBoss Rich Faces SVN: r20133 - in branches/RF-8742-1: examples/input-demo/src/main/webapp/examples and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-11-22 13:35:31 -0500 (Mon, 22 Nov 2010)
New Revision: 20133
Modified:
branches/RF-8742-1/
branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/calendar.xhtml
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
branches/RF-8742-1/ui/input/ui/src/main/templates/calendar.template.xml
Log:
Merged revisions 20116,20118-20119,20128-20129 via svnmerge from
https://svn.jboss.org/repos/richfaces/trunk
.......
r20116 | amarkhel | 2010-11-19 03:49:05 -0800 (Fri, 19 Nov 2010) | 1 line
RF-9683 Calendar component: data model support. Calling getCurrentDate() was replaces by getCurrentDateOrDefault()
.......
r20118 | abelevich | 2010-11-19 04:40:47 -0800 (Fri, 19 Nov 2010) | 1 line
RF-9781
.......
r20119 | amarkhel | 2010-11-19 05:09:29 -0800 (Fri, 19 Nov 2010) | 1 line
RF-9630 Calendar component: disabled state support. Processing the disabled calendar icon was added.
.......
r20128 | amarkhel | 2010-11-22 04:48:50 -0800 (Mon, 22 Nov 2010) | 3 lines
https://jira.jboss.org/browse/RF-9685 Calendar component: client-side events + demo
https://jira.jboss.org/browse/RF-7794 rich:calendar needs event handler "onclean",
https://jira.jboss.org/browse/RF-9602 calendar: onchange not implemented so value can't be stored via ajax for (common use-case)
.......
r20129 | amarkhel | 2010-11-22 04:49:02 -0800 (Mon, 22 Nov 2010) | 3 lines
https://jira.jboss.org/browse/RF-9685 Calendar component: client-side events + demo
https://jira.jboss.org/browse/RF-7794 rich:calendar needs event handler "onclean",
https://jira.jboss.org/browse/RF-9602 calendar: onchange not implemented so value can't be stored via ajax for (common use-case)
.......
Property changes on: branches/RF-8742-1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-20107
+ /trunk:1-20132
Modified: branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
--- branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-22 13:30:34 UTC (rev 20132)
+++ branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-22 18:35:31 UTC (rev 20133)
@@ -4,6 +4,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j"
xmlns:calendar="http://richfaces.org/input">
<!--
JBoss, Home of Professional Open Source
@@ -34,7 +35,7 @@
</h:head>
<h:body>
<h:form id="form">
- <h:panelGrid id="panel" columns="2">
+ <h:panelGrid id="panel" columns="3">
<h:panelGroup layout="block">
<calendar:calendar value="#{calendarBean.selectedDate}" id="calendar"
jointPoint="#{calendarBean.jointPoint}" direction="#{calendarBean.direction}"
@@ -43,9 +44,24 @@
dataModel="#{calendarDataModel}"
mode="#{calendarBean.mode}"
showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
- cellHeight="22px" style="width:200px" minDaysInFirstWeek="3">
- <f:convertDateTime pattern="#{calendarBean.pattern}" />
+ cellHeight="22px" style="width:200px" minDaysInFirstWeek="3"
+ oncollapse="return onEvent.call(this, event);"
+ onexpand="return onEvent.call(this, event);"
+ oncurrentdateselect="return onEvent.call(this, event);"
+ oncurrentdateselected="return onEvent.call(this, event);"
+ ondateselect="return onEvent.call(this, event);"
+ ondateselected="return onEvent.call(this, event);"
+ ontimeselect="return onEvent.call(this, event);"
+ ontimeselected="return onEvent.call(this, event);"
+ oncomplete="return onEvent.call(this, event);"
+ onclean="return onEvent.call(this, event);"
+ ondatemouseout="return onEvent.call(this, event);"
+ ondatemouseover="return onEvent.call(this, event);"
+
+ >
+ <f:ajax event="change" render="echo-text" />
</calendar:calendar>
+ <h:outputText id="echo-text" value="#{calendarBean.selectedDate}" />
</h:panelGroup>
<h:panelGrid columns="2">
<h:outputText value="Popup Mode:" />
@@ -101,6 +117,17 @@
<f:selectItem itemLabel="bottom-right" itemValue="bottom-right" />
</h:selectOneMenu>
</h:panelGrid>
+ <h:panelGroup layout="block">
+ <div>
+ <a4j:log mode="inline"></a4j:log>
+ </div>
+ <script type="text/javascript">
+ onEvent = function(event, element, data){
+ RichFaces.log.info("jQuery Event: "+(event instanceof jQuery.Event)+"; event: "+event.type+"; data:"+(data || (event['rich']||{})['data'])+"; this.id:"+this.id+"; component:"+ (event['rich']||{})['component']||RichFaces.$(this.id));
+ };
+ //RichFaces.Event.bindById("form:calendar", "dateselect dateselected currentdateselect currentdateselected timeselect timeselected changed clean collapse expand complete datemouseout datemouseout", onEvent);
+ </script>
+ </h:panelGroup>
</h:panelGrid>
</h:form>
</h:body>
Modified: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-11-22 13:30:34 UTC (rev 20132)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-11-22 18:35:31 UTC (rev 20133)
@@ -272,7 +272,47 @@
@Attribute(events = @EventName("inputblur"))
public abstract String getOninputblur();
+
+ @Attribute(events = @EventName("change"))
+ public abstract String getOnchange();
+
+ @Attribute(events = @EventName("dateselect"))
+ public abstract String getOndateselect();
+
+ @Attribute(events = @EventName("dateselected"))
+ public abstract String getOndateselected();
+
+ @Attribute(events = @EventName("currentdateselect"))
+ public abstract String getOncurrentdateselect();
+
+ @Attribute(events = @EventName("currentdateselected"))
+ public abstract String getOncurrentdateselected();
+ @Attribute(events = @EventName("complete"))
+ public abstract String getOncomplete();
+
+ @Attribute(events = @EventName("collapse"))
+ public abstract String getOncollapse();
+
+ @Attribute(events = @EventName("datemouseout"))
+ public abstract String getOndatemouseout();
+
+ @Attribute(events = @EventName("datemouseover"))
+ public abstract String getOndatemouseover();
+
+ @Attribute(events = @EventName("expand"))
+ public abstract String getOnExpand();
+
+ @Attribute(events = @EventName("timeselect"))
+ public abstract String getOntimeselect();
+
+ @Attribute(events = @EventName("timeselected"))
+ public abstract String getOntimeselected();
+
+ @Attribute(events = @EventName("clean"))
+ public abstract String getOnclean();
+
+
@Attribute
public Object getLocale() {
Object locale = getStateHelper().eval(PropertyKeys.locale);
@@ -494,9 +534,9 @@
if (Modes.AJAX.toString().equalsIgnoreCase(getMode())) {
dateRangeBegin = CalendarHelper.getAsDate(facesContext, this,
- getDefaultPreloadBegin((Date) getCurrentDate()));
+ getDefaultPreloadBegin((Date) getCurrentDateOrDefault()));
dateRangeEnd = CalendarHelper.getAsDate(facesContext, this,
- getDefaultPreloadEnd((Date) getCurrentDate()));
+ getDefaultPreloadEnd((Date) getCurrentDateOrDefault()));
} else {
dateRangeBegin = CalendarHelper.getAsDate(facesContext, this, getPreloadDateRangeBegin());
dateRangeEnd = CalendarHelper.getAsDate(facesContext, this, getPreloadDateRangeEnd());
Modified: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-11-22 13:30:34 UTC (rev 20132)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-11-22 18:35:31 UTC (rev 20133)
@@ -104,7 +104,7 @@
public abstract String getOnkeypress();
@Attribute(events=@EventName("keyup"))
- public abstract String getOnkeypup();
+ public abstract String getOnkeyup();
@Attribute(events=@EventName("mousedown"))
public abstract String getOnmousedown();
@@ -149,7 +149,7 @@
public abstract String getOninputkeypress();
@Attribute(events=@EventName("inputkeyup"))
- public abstract String getOninputkeypup();
+ public abstract String getOninputkeyup();
@Attribute(events=@EventName("inputfocus"))
public abstract String getOninputfocus();
Modified: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-22 13:30:34 UTC (rev 20132)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-22 18:35:31 UTC (rev 20133)
@@ -41,7 +41,6 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialViewContext;
-import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.DateTimeConverter;
@@ -79,58 +78,10 @@
public static final String CALENDAR_BUNDLE = "org.richfaces.renderkit.calendar";
- public static final String OPTION_ENABLE_MANUAL_INPUT = "enableManualInput";
-
public static final String OPTION_DISABLED = "disabled";
- public static final String OPTION_READONLY = "readonly";
-
- public static final String OPTION_RESET_TIME_ON_DATE_SELECT = "resetTimeOnDateSelect";
-
- public static final String OPTION_SHOW_APPLY_BUTTON = "showApplyButton";
-
public static final String OPTION_MIN_DAYS_IN_FIRST_WEEK = "minDaysInFirstWeek";
- public static final String OPTION_POPUP = "popup";
-
- public static final String OPTION_SHOW_INPUT = "showInput";
-
- public static final String OPTION_SHOW_HEADER = "showHeader";
-
- public static final String OPTION_SHOW_FOOTER = "showFooter";
-
- public static final String OPTION_SHOW_WEEKS_BAR = "showWeeksBar";
-
- public static final String OPTION_TODAY_CONTROL_MODE = "todayControlMode";
-
- public static final String OPTION_DATE_PATTERN = "datePattern";
-
- public static final String OPTION_JOINT_POINT = "jointPoint";
-
- public static final String OPTION_DIRECTION = "direction";
-
- public static final String OPTION_BOUNDARY_DATES_MODE = "boundaryDatesMode";
-
- public static final String OPTION_HORIZONTAL_OFFSET = "horizontalOffset";
-
- public static final String OPTION_VERTICAL_OFFSET = "verticalOffset";
-
- public static final String OPTION_CURRENT_DATE = "currentDate";
-
- public static final String OPTION_SELECTED_DATE = "selectedDate";
-
- public static final String OPTION_DAY_CELL_CLASS = "dayCellClass";
-
- public static final String OPTION_DAY_STYLE_CLASS = "dayStyleClass";
-
- public static final String OPTION_LABELS = "labels";
-
- public static final String OPTION_DEFAULT_TIME = "defaultTime";
-
- public static final String OPTION_HIDE_POPUP_ON_SCROLL = "hidePopupOnScroll";
-
- public static final String OPTION_SHOW_WEEK_DAYS_BAR = "showWeekDaysBar";
-
public static final String MONTH_LABELS_SHORT = "monthLabelsShort";
public static final String MONTH_LABELS = "monthLabels";
@@ -149,9 +100,6 @@
public static final String CURRENT_DATE_INPUT = "InputCurrentDate";
- public static final String OPTION_MODE = "mode";
-
-
protected static final Map<String, ComponentAttribute> CALENDAR_INPUT_HANDLER_ATTRIBUTES = Collections.unmodifiableMap(ComponentAttribute.createMap(
new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
.setEventNames("inputclick")
@@ -205,8 +153,8 @@
return;
}
- AbstractCalendar calendar = (AbstractCalendar)component;
- if (calendar.isDisabled()){
+ AbstractCalendar calendar = (AbstractCalendar) component;
+ if (calendar.isDisabled()) {
return;
}
@@ -245,7 +193,7 @@
// skip conversion of already converted date
if (submittedValue instanceof Date) {
- return (Date)submittedValue;
+ return (Date) submittedValue;
}
// Store submitted value in the local variable as a string
@@ -276,7 +224,7 @@
Object curVal = calendar.getValue();
Converter converter = SelectUtils.findConverter(facesContext, calendar, "value");
- if(converter == null) {
+ if (converter == null) {
converter = createDefaultConverter();
}
@@ -285,7 +233,7 @@
if (converter != null) {
value = converter.getAsString(facesContext, calendar, curVal);
} else {
- value = curVal !=null ? curVal.toString() : "";
+ value = curVal != null ? curVal.toString() : "";
}
}
@@ -298,7 +246,7 @@
}
public String getButtonIcon(FacesContext facesContext, UIComponent component) {
- boolean disable = (Boolean)component.getAttributes().get("disabled");
+ boolean disable = (Boolean)component.getAttributes().get(OPTION_DISABLED);
String buttonIcon = (String)component.getAttributes().get("buttonIcon");
if (disable) {
buttonIcon = (String)component.getAttributes().get("buttonIconDisabled");
@@ -307,16 +255,15 @@
if(buttonIcon != null && buttonIcon.trim().length() != 0) {
buttonIcon = RenderKitUtils.getResourceURL(buttonIcon, facesContext);
} else {
- buttonIcon = disable ? CALENDAR_ICON_RESOURCE_NAME: CALENDAR_ICON_RESOURCE_NAME;
+ buttonIcon = disable ? CALENDAR_DISABLE_ICON_RESOURCE_NAME: CALENDAR_ICON_RESOURCE_NAME;
buttonIcon = RenderKitUtils.getResourcePath(facesContext, "org.richfaces.images",buttonIcon);
}
-
return buttonIcon;
}
public Object getSelectedDate(FacesContext facesContext, UIComponent component) throws IOException {
Object returnValue = null;
- AbstractCalendar calendar = (AbstractCalendar)component;
+ AbstractCalendar calendar = (AbstractCalendar) component;
if (calendar.isValid()) {
Date date;
Object value = calendar.getValue();
@@ -344,13 +291,14 @@
return result;
}
- public Object getCurrentDate(FacesContext facesContext, AbstractCalendar calendar) throws IOException {
+ public Object getCurrentDate(FacesContext facesContext, UIComponent component) throws IOException {
+ AbstractCalendar calendar = (AbstractCalendar) component;
Date date = CalendarHelper.getCurrentDateOrDefault(facesContext, calendar);
return formatDate(date);
}
public String getCurrentDateAsString(FacesContext facesContext, UIComponent component) throws IOException {
- AbstractCalendar calendar = (AbstractCalendar)component;
+ AbstractCalendar calendar = (AbstractCalendar) component;
Format formatter = new SimpleDateFormat("MM/yyyy");
Date currentDate = CalendarHelper.getCurrentDateOrDefault(facesContext, calendar);
@@ -368,7 +316,7 @@
return result;
}
- public String getDayCellClass(FacesContext facesContext, AbstractCalendar calendar) {
+ public String getDayCellClass(FacesContext facesContext, UIComponent component) {
//TODO: refactor this
/*
String cellwidth = (String) component.getAttributes().get("cellWidth");
@@ -387,12 +335,15 @@
return calendar.isDayEnabled() ? JSReference.TRUE : JSReference.FALSE;
}
- public JSReference getDayStyleClass(FacesContext context, AbstractCalendar calendar) {
+ public JSReference getDayStyleClass(FacesContext context, UIComponent component) {
+ AbstractCalendar calendar = (AbstractCalendar) component;
String dayStyleClass = calendar.getDayStyleClass();
return ((dayStyleClass != null && dayStyleClass.trim().length() != 0)) ? new JSReference(dayStyleClass) : null;
}
- public Map<String, Object> getLabels(FacesContext facesContext, AbstractCalendar calendar) {
+ public Map<String, Object> getLabels(FacesContext facesContext, UIComponent component) {
+ AbstractCalendar calendar = (AbstractCalendar) component;
+
ResourceBundle bundle1 = null;
ResourceBundle bundle2 = null;
@@ -401,7 +352,7 @@
String messageBundle = facesContext.getApplication().getMessageBundle();
Locale locale = CalendarHelper.getAsLocale(facesContext, calendar);
if (null != messageBundle) {
- bundle1 = ResourceBundle.getBundle(messageBundle,locale , loader);
+ bundle1 = ResourceBundle.getBundle(messageBundle, locale, loader);
}
try {
@@ -419,10 +370,10 @@
protected Map<String, Object> getCollectedLabels(ResourceBundle [] bundles , String[] names) {
Map<String, Object> labels = new HashMap<String, Object>();
if (bundles != null && names != null) {
- for (String name: names) {
+ for (String name : names) {
String label = null;
String bundleKey = "RICH_CALENDAR_" + name.toUpperCase() + "_LABEL";
- for (ResourceBundle bundle: bundles) {
+ for (ResourceBundle bundle : bundles) {
if (bundle != null) {
try {
label = bundle.getString(bundleKey);
@@ -440,7 +391,9 @@
return labels;
}
- public Map<String, Object> getPreparedDefaultTime(FacesContext facesContext, AbstractCalendar abstractCalendar) {
+ public Map<String, Object> getPreparedDefaultTime(FacesContext facesContext, UIComponent component) {
+ AbstractCalendar abstractCalendar = (AbstractCalendar) component;
+
Date date = CalendarHelper.getFormattedDefaultTime(abstractCalendar);
Map<String, Object> result = new HashMap<String, Object>();
if (date != null) {
@@ -473,7 +426,9 @@
return shiftedLabels;
}
- protected Map<String, Object> getLocaleOptions(FacesContext facesContext, AbstractCalendar calendarComponent) {
+ protected Map<String, Object> getLocaleOptions(FacesContext facesContext, UIComponent component) {
+ AbstractCalendar calendarComponent = (AbstractCalendar) component;
+
Map<String, Object> map = new HashMap<String, Object>();
Locale locale = CalendarHelper.getAsLocale(facesContext, calendarComponent);
@@ -532,74 +487,30 @@
if (0 <= day && day <= 6) {
RenderKitUtils.addToScriptHash(map, FIRST_DAY_WEEK, day);
} else if (day != Integer.MIN_VALUE) {
- facesContext.getExternalContext().log(day + " value of firstWeekDay attribute is not a legal one for component: " + MessageUtil.getLabel(facesContext, calendarComponent) + ". Default value was applied.");
+ facesContext.getExternalContext().log(
+ day + " value of firstWeekDay attribute is not a legal one for component: "
+ + MessageUtil.getLabel(facesContext, calendarComponent) + ". Default value was applied.");
}
return map;
}
-
- public ScriptOptions createCalendarScriptOption(FacesContext facesContext, UIComponent component) throws IOException {
- AbstractCalendar calendar = (AbstractCalendar)component;
- ScriptOptions scriptOptions = new ScriptOptions(component);
- scriptOptions.addOption(OPTION_ENABLE_MANUAL_INPUT);
- scriptOptions.addOption(OPTION_DISABLED);
- scriptOptions.addOption(OPTION_READONLY);
- scriptOptions.addOption(OPTION_RESET_TIME_ON_DATE_SELECT);
- scriptOptions.addOption(OPTION_SHOW_APPLY_BUTTON);
- scriptOptions.addOption(OPTION_POPUP);
- scriptOptions.addOption(OPTION_SHOW_INPUT);
- scriptOptions.addOption(OPTION_SHOW_HEADER);
- scriptOptions.addOption(OPTION_SHOW_FOOTER);
- scriptOptions.addOption(OPTION_SHOW_WEEKS_BAR);
- scriptOptions.addOption(OPTION_TODAY_CONTROL_MODE);
- scriptOptions.addOption(OPTION_DATE_PATTERN);
- scriptOptions.addOption(OPTION_JOINT_POINT);
- scriptOptions.addOption(OPTION_DIRECTION);
- scriptOptions.addOption(OPTION_BOUNDARY_DATES_MODE);
- scriptOptions.addOption(OPTION_HORIZONTAL_OFFSET);
- scriptOptions.addOption(OPTION_VERTICAL_OFFSET);
- scriptOptions.addOption(OPTION_CURRENT_DATE, getCurrentDate(facesContext, calendar));
- scriptOptions.addOption(OPTION_SELECTED_DATE, getSelectedDate(facesContext, calendar));
- scriptOptions.addOption(OPTION_DAY_CELL_CLASS, getDayCellClass(facesContext, calendar));
- scriptOptions.addOption(OPTION_DAY_STYLE_CLASS, getDayStyleClass(facesContext, calendar));
- /*
- *add to script option
- *<cdk:scriptOption attributes="ondateselected, ondateselect, ontimeselect, ontimeselected, onchanged, ondatemouseover, ondatemouseout, onexpand, oncollapse, oncurrentdateselect, oncurrentdateselected" wrapper="eventHandler" />
- * */
- scriptOptions.addOption(OPTION_LABELS, getLabels(facesContext, calendar));
- scriptOptions.addOption(OPTION_DEFAULT_TIME, getPreparedDefaultTime(facesContext, calendar));
- scriptOptions.addOption(OPTION_HIDE_POPUP_ON_SCROLL);
- scriptOptions.addOption("showWeekDaysBar");
-
- scriptOptions.addOption("styleClass");
- scriptOptions.addOption("style", HtmlUtil.concatStyles("z-index: " + calendar.getZindex(), calendar.getStyle()));
- scriptOptions.addOption(OPTION_MODE, calendar.getMode());
-
- return scriptOptions;
+
+ public String getStyleWithZindex(FacesContext facesContext, UIComponent component) {
+ AbstractCalendar calendar = (AbstractCalendar) component;
+ String style = HtmlUtil.concatStyles("z-index: " + calendar.getZindex(), calendar.getStyle());
+ return style;
}
- public void buildAddLocaleScript(ResponseWriter writer, FacesContext facesContext, UIComponent component) throws IOException {
- if (component instanceof AbstractCalendar) {
- AbstractCalendar calendar = (AbstractCalendar)component;
- JSFunction function = new JSFunction("RichFaces.ui.Calendar.addLocale", CalendarHelper.getAsLocale(facesContext, calendar).toString(), getLocaleOptions(facesContext, calendar));
- writer.write(function.toScript());
- writer.write(";");
- }
+ public Locale getAsLocale(FacesContext facesContext, UIComponent component) {
+ return CalendarHelper.getAsLocale(facesContext, component);
}
- public void buildCalendarScript(ResponseWriter writer, FacesContext facesContext, UIComponent component) throws IOException {
- if (component instanceof AbstractCalendar) {
- AbstractCalendar calendar = (AbstractCalendar)component;
- ScriptOptions scriptOptions = createCalendarScriptOption(facesContext, calendar);
- JSFunction function = new JSFunction("new RichFaces.ui.Calendar", calendar.getClientId(facesContext), CalendarHelper.getAsLocale(facesContext, calendar).toString(), scriptOptions, "");
- StringBuffer scriptBuffer = new StringBuffer();
- scriptBuffer.append(function.toScript()).append(".load(");
- Object preload = calendar.getPreload();
- if (null != preload){
- scriptBuffer.append(RenderKitUtils.toScriptArgs(preload));
- }
-
- scriptBuffer.append(");");
- writer.write(scriptBuffer.toString());
+ public String writePreloadBody(FacesContext context, UIComponent component) throws IOException {
+ AbstractCalendar calendar = (AbstractCalendar) component;
+ Object preload = calendar.getPreload();
+ if (preload != null) {
+ return RenderKitUtils.toScriptArgs(preload);
+ } else {
+ return null;
}
}
Modified: branches/RF-8742-1/ui/input/ui/src/main/templates/calendar.template.xml
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/templates/calendar.template.xml 2010-11-22 13:30:34 UTC (rev 20132)
+++ branches/RF-8742-1/ui/input/ui/src/main/templates/calendar.template.xml 2010-11-22 18:35:31 UTC (rev 20133)
@@ -67,11 +67,25 @@
<span style="display: none;" id="#{clientId}Content"></span>
<span style="display: none;" id="#{clientId}Script">
<script type="text/javascript">
- <cdk:call
- expression="buildAddLocaleScript(responseWriter, facesContext, component);" />
- <cdk:call
- expression="buildCalendarScript(responseWriter, facesContext, component);" />
- </script>
+
+ <cdk:scriptObject name="options">
+ <cdk:scriptOption attributes="enableManualInput disabled readonly resetTimeOnDateSelect showApplyButton popup showInput showHeader showFooter showWeeksBar todayControlMode datePattern jointPoint direction boundaryDatesMode horizontalOffset verticalOffset hidePopupOnScrol showWeekDaysBar styleClass mode" />
+ <cdk:scriptOption attributes="onchange ondateselect ondateselected oncurrentdateselected oncollapse onexpand ondatemouseover ondatemouseout onclean ontimeselect ontimeselected" wrapper="eventHandler" />
+ <cdk:scriptOption name="currentDate" value="#{getCurrentDate(facesContext, component)}" />
+ <cdk:scriptOption name="selectedDate" value="#{getSelectedDate(facesContext, component)}" />
+ <cdk:scriptOption name="dayCellClass" value="#{getDayCellClass(facesContext, component)}" />
+ <cdk:scriptOption name="dayStyleClass" value="#{getDayStyleClass(facesContext, component)}" />
+ <cdk:scriptOption name="labels" value="#{getLabels(facesContext, component)}" />
+ <cdk:scriptOption name="defaultTime" value="#{getPreparedDefaultTime(facesContext, component)}" />
+ <cdk:scriptOption name="style" value="#{getStyleWithZindex(facesContext, component)}" />
+ </cdk:scriptObject>
+
+ RichFaces.ui.Calendar.addLocale("#{getAsLocale(facesContext, component).toString()}",
+ #{toScriptArgs(getLocaleOptions(facesContext, component))});
+ new RichFaces.ui.Calendar("#{clientId}", "#{getAsLocale(facesContext, component).toString()}",
+ #{toScriptArgs(options)}).load(#{writePreloadBody(facesContext, component)});
+
+ --></script>
</span>
</span>
</cc:implementation>
14 years, 1 month
JBoss Rich Faces SVN: r20132 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: richInplaceSelect and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-11-22 08:30:34 -0500 (Mon, 22 Nov 2010)
New Revision: 20132
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java
Log:
https://jira.jboss.org/browse/RF-9037
* 54 tests for rich:inplaceSelect added
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java 2010-11-22 13:30:34 UTC (rev 20132)
@@ -0,0 +1,514 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richInplaceSelect;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardNoRequest;
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URL;
+import org.jboss.test.selenium.css.CssProperty;
+
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.waiting.EventFiredCondition;
+import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
+import org.richfaces.tests.metamer.ftest.annotations.IssueTracking;
+import org.testng.annotations.Test;
+
+/**
+ * Test case for page faces/components/richInplaceSelect/simple.xhtml.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+public class TestRichInplaceSelect extends AbstractMetamerTest {
+
+ private JQueryLocator select = pjq("span[id$=inplaceSelect]");
+ private JQueryLocator label = pjq("span.rf-is-lbl");
+ private JQueryLocator input = pjq("input[id$=inplaceSelectInput]");
+ private JQueryLocator popup = pjq("span.rf-is-lst-cord");
+ private JQueryLocator edit = pjq("span.rf-is-edit");
+ private JQueryLocator options = jq("span.rf-is-opt:eq({0})"); // 00..49
+ private JQueryLocator okButton = jq("input.rf-is-btn[id$=Okbtn]");
+ private JQueryLocator cancelButton = jq("input.rf-is-btn[id$=Cancelbtn]");
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richInplaceSelect/simple.xhtml");
+ }
+
+ @Test
+ public void testInit() {
+ assertTrue(selenium.isElementPresent(select), "Inplace select is not on the page.");
+ assertTrue(selenium.isElementPresent(label), "Default label should be present on the page.");
+ assertEquals(selenium.getText(label), "Click here to edit", "Default label");
+ assertTrue(selenium.isElementPresent(input), "Input should be present on the page.");
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed on the page.");
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9664")
+ public void testClick() {
+ guardNoRequest(selenium).click(select);
+ assertFalse(selenium.belongsClass(edit, "rf-is-none"), "Edit should not contain class rf-is-none when popup is open.");
+ assertTrue(selenium.isDisplayed(popup), "Popup should be displayed.");
+
+ for (int i = 0; i < 50; i++) {
+ assertTrue(selenium.isDisplayed(options.format(i)), "Select option " + i + " should be displayed.");
+ }
+
+ String[] selectOptions = {"Alabama", "Hawaii", "Massachusetts", "New Mexico", "South Dakota"};
+ for (int i = 0; i < 50; i += 10) {
+ assertEquals(selenium.getText(options.format(i)), selectOptions[i / 10], "Select option nr. " + i);
+ }
+
+ guardNoRequest(selenium).click(options.format(10));
+ assertTrue(selenium.belongsClass(select, "rf-is-c-s"), "New class should be added to inplace select.");
+ assertTrue(selenium.belongsClass(edit, "rf-is-none"), "Edit should contain class rf-is-none when popup is closed.");
+
+ assertEquals(selenium.getText(label), "Hawaii", "Label should contain selected value.");
+ }
+
+ @Test
+ public void testDefaultLabel() {
+ selenium.type(pjq("input[type=text][id$=defaultLabelInput]"), "new label");
+ selenium.waitForPageToLoad();
+ assertEquals(selenium.getText(label), "new label", "Default label should change");
+
+ selenium.type(pjq("input[type=text][id$=defaultLabelInput]"), "");
+ selenium.waitForPageToLoad();
+ assertEquals(selenium.getText(label), "", "Default label should change");
+
+ assertTrue(selenium.isElementPresent(select), "Inplace select is not on the page.");
+ assertTrue(selenium.isElementPresent(label), "Default label should be present on the page.");
+ assertTrue(selenium.isElementPresent(input), "Input should be present on the page.");
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed on the page.");
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9844")
+ public void testEditEvent() {
+ selenium.type(pjq("input[type=text][id$=editEventInput]"), "mouseup");
+ selenium.waitForPageToLoad();
+
+ selenium.mouseDown(select);
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed.");
+ selenium.mouseUp(select);
+ assertTrue(selenium.isDisplayed(popup), "Popup should be displayed.");
+
+ selenium.type(pjq("input[type=text][id$=editEventInput]"), "nonexistingevent");
+ selenium.waitForPageToLoad();
+
+ selenium.click(select);
+ assertTrue(selenium.isDisplayed(popup), "Popup should be displayed.");
+ }
+
+ @Test
+ public void testItemClass() {
+ final String value = "metamer-ftest-class";
+ selenium.type(pjq("input[type=text][id$=itemClassInput]"), value);
+ selenium.waitForPageToLoad();
+
+ for (int i = 0; i < 50; i++) {
+ assertTrue(selenium.belongsClass(options.format(i), value), "Select option "
+ + selenium.getText(options.format(i)) + " does not contain class " + value);
+ }
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9845")
+ public void testListClass() {
+ testStyleClass(popup, "listClass");
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9647")
+ public void testListHeight() {
+ selenium.type(pjq("input[type=text][id$=listHeightInput]"), "300px");
+ selenium.waitForPageToLoad();
+
+ String height = selenium.getStyle(jq("span.rf-is-lst-scrl"), CssProperty.HEIGHT);
+ assertEquals(height, "300px", "Height of list did not change");
+
+ selenium.type(pjq("input[type=text][id$=listHeightInput]"), "");
+ selenium.waitForPageToLoad();
+
+ // it cannot handle null because of a bug in Mojarra and Myfaces and
+ // generates style="height: ; " instead of default value
+ height = selenium.getStyle(jq("span.rf-is-lst-scrl"), CssProperty.HEIGHT);
+ assertEquals(height, "200px", "Height of list did not change");
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9647")
+ public void testListWidth() {
+ selenium.type(pjq("input[type=text][id$=listWidthInput]"), "300px");
+ selenium.waitForPageToLoad();
+
+ String width = selenium.getStyle(jq("span.rf-is-lst-pos"), CssProperty.WIDTH);
+ assertEquals(width, "300px", "Width of list did not change");
+
+ selenium.type(pjq("input[type=text][id$=listWidthInput]"), "");
+ selenium.waitForPageToLoad();
+
+ // it cannot handle null because of a bug in Mojarra and Myfaces and
+ // generates style="width: ; " instead of default value
+ width = selenium.getStyle(jq("span.rf-is-lst-pos"), CssProperty.WIDTH);
+ assertEquals(width, "200px", "Width of list did not change");
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9849")
+ public void testOnblur() {
+ testFireEvent(Event.BLUR, select);
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9571")
+ public void testOnchange() {
+ selenium.type(pjq("input[type=text][id$=onchangeInput]"), "metamerEvents += \"change \"");
+ selenium.waitForPageToLoad();
+
+ selenium.click(select);
+ selenium.click(options.format(10));
+
+ waitGui.failWith("Attribute onchange does not work correctly").until(
+ new EventFiredCondition(Event.CHANGE));
+ }
+
+ @Test
+ public void testOnclick() {
+ testFireEvent(Event.CLICK, select);
+ }
+
+ @Test
+ public void testOndblclick() {
+ testFireEvent(Event.DBLCLICK, select);
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9849")
+ public void testOnfocus() {
+ testFireEvent(Event.FOCUS, select);
+ }
+
+ @Test
+ public void testOninputblur() {
+ testFireEvent(Event.BLUR, input, "inputblur");
+ }
+
+ @Test
+ public void testOninputclick() {
+ testFireEvent(Event.CLICK, input, "inputclick");
+ }
+
+ @Test
+ public void testOninputdblclick() {
+ testFireEvent(Event.DBLCLICK, input, "inputdblclick");
+ }
+
+ @Test
+ public void testOninputfocus() {
+ testFireEvent(Event.FOCUS, input, "inputfocus");
+ }
+
+ @Test
+ public void testOninputkeydown() {
+ testFireEvent(Event.KEYDOWN, input, "inputkeydown");
+ }
+
+ @Test
+ public void testOninputkeypress() {
+ testFireEvent(Event.KEYPRESS, input, "inputkeypress");
+ }
+
+ @Test
+ public void testOninputkeyup() {
+ testFireEvent(Event.KEYUP, input, "inputkeyup");
+ }
+
+ @Test
+ public void testOninputmousedown() {
+ testFireEvent(Event.MOUSEDOWN, input, "inputmousedown");
+ }
+
+ @Test
+ public void testOninputmousemove() {
+ testFireEvent(Event.MOUSEMOVE, input, "inputmousemove");
+ }
+
+ @Test
+ public void testOninputmouseout() {
+ testFireEvent(Event.MOUSEOUT, input, "inputmouseout");
+ }
+
+ @Test
+ public void testOninputmouseover() {
+ testFireEvent(Event.MOUSEOVER, input, "inputmouseover");
+ }
+
+ @Test
+ public void testOninputmouseup() {
+ testFireEvent(Event.MOUSEUP, input, "inputmouseup");
+ }
+
+ @Test
+ public void testOninputselect() {
+ testFireEvent(Event.SELECT, input, "inputselect");
+ }
+
+ @Test
+ public void testOnkeydown() {
+ testFireEvent(Event.KEYDOWN, select);
+ }
+
+ @Test
+ public void testOnkeypress() {
+ testFireEvent(Event.KEYPRESS, select);
+ }
+
+ @Test
+ public void testOnkeyup() {
+ testFireEvent(Event.KEYUP, select);
+ }
+
+ @Test
+ public void testOnlistclick() {
+ testFireEvent(Event.CLICK, popup, "listclick");
+ }
+
+ @Test
+ public void testOnlistdblclick() {
+ testFireEvent(Event.DBLCLICK, popup, "listdblclick");
+ }
+
+ @Test
+ public void testOnlistkeydown() {
+ testFireEvent(Event.KEYDOWN, popup, "listkeydown");
+ }
+
+ @Test
+ public void testOnlistkeypress() {
+ testFireEvent(Event.KEYPRESS, popup, "listkeypress");
+ }
+
+ @Test
+ public void testOnlistkeyup() {
+ testFireEvent(Event.KEYUP, popup, "listkeyup");
+ }
+
+ @Test
+ public void testOnlistmousedown() {
+ testFireEvent(Event.MOUSEDOWN, popup, "listmousedown");
+ }
+
+ @Test
+ public void testOnlistmousemove() {
+ testFireEvent(Event.MOUSEMOVE, popup, "listmousemove");
+ }
+
+ @Test
+ public void testOnlistmouseout() {
+ testFireEvent(Event.MOUSEOUT, popup, "listmouseout");
+ }
+
+ @Test
+ public void testOnlistmouseover() {
+ testFireEvent(Event.MOUSEOVER, popup, "listmouseover");
+ }
+
+ @Test
+ public void testOnlistmouseup() {
+ testFireEvent(Event.MOUSEUP, popup, "listmouseup");
+ }
+
+ @Test
+ public void testOnmousedown() {
+ testFireEvent(Event.MOUSEDOWN, select);
+ }
+
+ @Test
+ public void testOnmousemove() {
+ testFireEvent(Event.MOUSEMOVE, select);
+ }
+
+ @Test
+ public void testOnmouseout() {
+ testFireEvent(Event.MOUSEOUT, select);
+ }
+
+ @Test
+ public void testOnmouseover() {
+ testFireEvent(Event.MOUSEOVER, select);
+ }
+
+ @Test
+ public void testOnmouseup() {
+ testFireEvent(Event.MOUSEUP, select);
+ }
+
+ @Test
+ @IssueTracking("https://jira.jboss.org/browse/RF-9849")
+ public void testOnselect() {
+ testFireEvent(Event.SELECT, input);
+ }
+
+ @Test
+ public void testOpenOnEdit() {
+ selenium.click(pjq("input[type=radio][name$=openOnEditInput][value=false]"));
+ selenium.waitForPageToLoad();
+
+ selenium.click(select);
+ assertFalse(selenium.belongsClass(edit, "rf-is-none"), "Edit should not contain class rf-is-none when popup is open.");
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed.");
+
+ selenium.click(input);
+ assertTrue(selenium.isDisplayed(popup), "Popup should be displayed.");
+ }
+
+ @Test
+ public void testRendered() {
+ selenium.click(pjq("input[type=radio][name$=renderedInput][value=false]"));
+ selenium.waitForPageToLoad();
+
+ assertFalse(selenium.isElementPresent(select), "Panel should not be rendered when rendered=false.");
+ }
+
+ @Test
+ public void testSaveOnBlurSelectTrueTrue() {
+ selenium.click(pjq("input[type=radio][name$=saveOnBlurInput][value=true]"));
+ selenium.waitForPageToLoad();
+
+ selenium.click(select);
+ assertTrue(selenium.isDisplayed(popup), "Popup should be displayed.");
+
+ selenium.click(options.format(10));
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed.");
+ assertEquals(selenium.getText(label), "Hawaii", "Label should contain selected value.");
+ }
+
+ @Test
+ public void testSaveOnBlurSelectTrueFalse() {
+ selenium.click(pjq("input[type=radio][name$=saveOnBlurInput][value=true]"));
+ selenium.waitForPageToLoad();
+ selenium.click(pjq("input[type=radio][name$=saveOnSelectInput][value=false]"));
+ selenium.waitForPageToLoad();
+
+ selenium.click(select);
+ assertTrue(selenium.isDisplayed(popup), "Popup should be displayed.");
+
+ selenium.click(options.format(10));
+ assertEquals(selenium.getText(label), "Click here to edit", "Label should contain default value.");
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed.");
+
+ selenium.fireEvent(input, Event.BLUR);
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed.");
+ assertEquals(selenium.getValue(input), "Hawaii", "Input should contain selected value.");
+ waitGui.failWith("Label should contain selected value.").until(textEquals.locator(label).text("Hawaii"));
+ }
+
+ @Test
+ public void testSaveOnBlurSelectFalseTrue() {
+ selenium.click(pjq("input[type=radio][name$=saveOnBlurInput][value=false]"));
+ selenium.waitForPageToLoad();
+
+ selenium.click(select);
+ assertTrue(selenium.isDisplayed(popup), "Popup should be displayed.");
+
+ selenium.click(options.format(10));
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed.");
+ assertEquals(selenium.getText(label), "Hawaii", "Label should contain selected value.");
+ }
+
+ @Test
+ public void testSaveOnBlurSelectFalseFalse() {
+ selenium.click(pjq("input[type=radio][name$=saveOnBlurInput][value=false]"));
+ selenium.waitForPageToLoad();
+ selenium.click(pjq("input[type=radio][name$=saveOnSelectInput][value=false]"));
+ selenium.waitForPageToLoad();
+
+ selenium.click(select);
+ assertTrue(selenium.isDisplayed(popup), "Popup should be displayed.");
+
+ selenium.click(options.format(10));
+ assertEquals(selenium.getText(label), "Click here to edit", "Label should contain default value.");
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed.");
+
+ selenium.fireEvent(input, Event.BLUR);
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed.");
+ assertEquals(selenium.getText(label), "Click here to edit", "Label should contain default value.");
+ }
+
+ @Test
+ public void testShowControls() {
+ selenium.click(pjq("input[type=radio][name$=showControlsInput][value=true]"));
+ selenium.waitForPageToLoad();
+
+ selenium.click(select);
+ assertTrue(selenium.isVisible(okButton), "OK button should be visible.");
+ assertTrue(selenium.isVisible(cancelButton), "Cancel button should be visible.");
+ assertTrue(selenium.isDisplayed(popup), "Popup should be displayed.");
+ }
+
+ @Test
+ public void testClickOkButton() {
+ selenium.click(pjq("input[type=radio][name$=showControlsInput][value=true]"));
+ selenium.waitForPageToLoad();
+ selenium.click(pjq("input[type=radio][name$=saveOnSelectInput][value=false]"));
+ selenium.waitForPageToLoad();
+
+ selenium.click(select);
+ selenium.click(options.format(10));
+ assertEquals(selenium.getText(label), "Click here to edit", "Label should contain default value.");
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed.");
+
+ selenium.mouseDown(okButton);
+
+ if (selenium.isElementPresent(popup)) {
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed.");
+ }
+ waitGui.failWith("Label should contain selected value.").until(textEquals.locator(label).text("Hawaii"));
+ }
+
+ @Test
+ public void testClickCancelButton() {
+ selenium.click(pjq("input[type=radio][name$=showControlsInput][value=true]"));
+ selenium.waitForPageToLoad();
+ selenium.click(pjq("input[type=radio][name$=saveOnSelectInput][value=false]"));
+ selenium.waitForPageToLoad();
+
+ selenium.click(select);
+ selenium.click(options.format(10));
+ assertEquals(selenium.getText(label), "Click here to edit", "Label should contain default value.");
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed.");
+
+ selenium.click(cancelButton);
+ if (selenium.isElementPresent(popup)) {
+ assertFalse(selenium.isDisplayed(popup), "Popup should not be displayed.");
+ }
+ assertEquals(selenium.getText(label), "Click here to edit", "Label should contain default value.");
+ }
+}
Property changes on: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richInplaceSelect/TestRichInplaceSelect.java
___________________________________________________________________
Name: svn:keywords
+ Revision
14 years, 1 month
JBoss Rich Faces SVN: r20131 - in modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer: bean and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-11-22 08:26:33 -0500 (Mon, 22 Nov 2010)
New Revision: 20131
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Attributes.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichInplaceSelectBean.java
Log:
https://jira.jboss.org/browse/RF-9037
* default values for for inplace select added
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Attributes.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Attributes.java 2010-11-22 13:13:02 UTC (rev 20130)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/Attributes.java 2010-11-22 13:26:33 UTC (rev 20131)
@@ -71,12 +71,12 @@
private static final long serialVersionUID = -1L;
private static Logger logger = LoggerFactory.getLogger(Attributes.class);
- private static Map<Class<?>, List<Attribute>> richfacesAttributes;
+ private Map<Class<?>, List<Attribute>> richfacesAttributes;
// K - name of a component attribute, V - value of the component attribute
private Map<String, Attribute> attributes;
// class object of managed bean
private Class<?> beanClass;
-
+
/**
* Constructor for class Attributes.
*
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichInplaceSelectBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichInplaceSelectBean.java 2010-11-22 13:13:02 UTC (rev 20130)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichInplaceSelectBean.java 2010-11-22 13:26:33 UTC (rev 20131)
@@ -72,7 +72,11 @@
attributes.setAttribute("defaultLabel", "Click here to edit");
attributes.setAttribute("editEvent", "click");
+ attributes.setAttribute("listHeight", "200px");
+ attributes.setAttribute("listWidth", "200px");
+ attributes.setAttribute("openOnEdit", true);
attributes.setAttribute("rendered", true);
+ attributes.setAttribute("saveOnSelect", true);
// TODO has to be tested in another way
attributes.remove("converter");
14 years, 1 month
JBoss Rich Faces SVN: r20130 - in sandbox/trunk/ui/drag-drop/ui/src/main: config and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-11-22 08:13:02 -0500 (Mon, 22 Nov 2010)
New Revision: 20130
Added:
sandbox/trunk/ui/drag-drop/ui/src/main/config/
sandbox/trunk/ui/drag-drop/ui/src/main/config/dnd.faces-config.xml
Removed:
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/dnd.faces-config.xml
Log:
move face-config
Added: sandbox/trunk/ui/drag-drop/ui/src/main/config/dnd.faces-config.xml
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/config/dnd.faces-config.xml (rev 0)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/config/dnd.faces-config.xml 2010-11-22 13:13:02 UTC (rev 20130)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<faces-config version="2.0" metadata-complete="false"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <behavior>
+ <description> @author abelevich
+
+</description>
+ <behavior-id>org.richfaces.component.behavior.DropBehavior</behavior-id>
+ <behavior-class>org.richfaces.component.behavior.DropBehavior</behavior-class>
+ <behavior-extension>
+ <cdk:base-class>org.richfaces.component.behavior.DropBehavior
+ </cdk:base-class>
+ <cdk:generate>false</cdk:generate>
+ </behavior-extension>
+ </behavior>
+ <behavior>
+ <description> @author abelevich
+
+</description>
+ <behavior-id>org.richfaces.component.behavior.DragBehavior</behavior-id>
+ <behavior-class>org.richfaces.component.behavior.DragBehavior</behavior-class>
+ <behavior-extension>
+ <cdk:base-class>org.richfaces.component.behavior.DragBehavior
+ </cdk:base-class>
+ <cdk:generate>false</cdk:generate>
+ </behavior-extension>
+ </behavior>
+
+ <render-kit>
+ <render-kit-id>HTML_BASIC</render-kit-id>
+ <client-behavior-renderer>
+ <client-behavior-renderer-type>org.richfaces.component.behavior.DropBehavior</client-behavior-renderer-type>
+ <client-behavior-renderer-class>org.richfaces.renderkit.DropBehaviorRendererBase</client-behavior-renderer-class>
+ </client-behavior-renderer>
+ <client-behavior-renderer>
+ <client-behavior-renderer-type>org.richfaces.component.behavior.DragBehavior</client-behavior-renderer-type>
+ <client-behavior-renderer-class>org.richfaces.renderkit.DragBehaviorRendererBase</client-behavior-renderer-class>
+ </client-behavior-renderer>
+ </render-kit>
+
+ <faces-config-extension>
+ <cdk:prefix>org.richfaces.component</cdk:prefix>
+ <cdk:taglib>
+ <cdk:shortName>dnd</cdk:shortName>
+ <cdk:uri>http://richfaces.org/dnd</cdk:uri>
+ </cdk:taglib>
+ </faces-config-extension>
+
+</faces-config>
Deleted: sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/dnd.faces-config.xml
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/dnd.faces-config.xml 2010-11-22 12:49:02 UTC (rev 20129)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/dnd.faces-config.xml 2010-11-22 13:13:02 UTC (rev 20130)
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<faces-config version="2.0" metadata-complete="false"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
- xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <behavior>
- <description> @author abelevich
-
-</description>
- <behavior-id>org.richfaces.component.behavior.DropBehavior</behavior-id>
- <behavior-class>org.richfaces.component.behavior.DropBehavior</behavior-class>
- <behavior-extension>
- <cdk:base-class>org.richfaces.component.behavior.DropBehavior
- </cdk:base-class>
- <cdk:generate>false</cdk:generate>
- </behavior-extension>
- </behavior>
- <behavior>
- <description> @author abelevich
-
-</description>
- <behavior-id>org.richfaces.component.behavior.DragBehavior</behavior-id>
- <behavior-class>org.richfaces.component.behavior.DragBehavior</behavior-class>
- <behavior-extension>
- <cdk:base-class>org.richfaces.component.behavior.DragBehavior
- </cdk:base-class>
- <cdk:generate>false</cdk:generate>
- </behavior-extension>
- </behavior>
-
- <render-kit>
- <render-kit-id>HTML_BASIC</render-kit-id>
- <client-behavior-renderer>
- <client-behavior-renderer-type>org.richfaces.component.behavior.DropBehavior</client-behavior-renderer-type>
- <client-behavior-renderer-class>org.richfaces.renderkit.DropBehaviorRendererBase</client-behavior-renderer-class>
- </client-behavior-renderer>
- <client-behavior-renderer>
- <client-behavior-renderer-type>org.richfaces.component.behavior.DragBehavior</client-behavior-renderer-type>
- <client-behavior-renderer-class>org.richfaces.renderkit.DragBehaviorRendererBase</client-behavior-renderer-class>
- </client-behavior-renderer>
- </render-kit>
-
- <faces-config-extension>
- <cdk:prefix>org.richfaces.component</cdk:prefix>
- <cdk:taglib>
- <cdk:shortName>dnd</cdk:shortName>
- <cdk:uri>http://richfaces.org/dnd</cdk:uri>
- </cdk:taglib>
- </faces-config-extension>
-
-</faces-config>
14 years, 1 month
JBoss Rich Faces SVN: r20129 - in trunk/ui/input/ui/src/main: java/org/richfaces/renderkit and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-11-22 07:49:02 -0500 (Mon, 22 Nov 2010)
New Revision: 20129
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
trunk/ui/input/ui/src/main/templates/calendar.template.xml
Log:
https://jira.jboss.org/browse/RF-9685 Calendar component: client-side events + demo
https://jira.jboss.org/browse/RF-7794 rich:calendar needs event handler "onclean",
https://jira.jboss.org/browse/RF-9602 calendar: onchange not implemented so value can't be stored via ajax for (common use-case)
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-11-22 12:48:50 UTC (rev 20128)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-11-22 12:49:02 UTC (rev 20129)
@@ -272,7 +272,47 @@
@Attribute(events = @EventName("inputblur"))
public abstract String getOninputblur();
+
+ @Attribute(events = @EventName("change"))
+ public abstract String getOnchange();
+
+ @Attribute(events = @EventName("dateselect"))
+ public abstract String getOndateselect();
+
+ @Attribute(events = @EventName("dateselected"))
+ public abstract String getOndateselected();
+
+ @Attribute(events = @EventName("currentdateselect"))
+ public abstract String getOncurrentdateselect();
+
+ @Attribute(events = @EventName("currentdateselected"))
+ public abstract String getOncurrentdateselected();
+ @Attribute(events = @EventName("complete"))
+ public abstract String getOncomplete();
+
+ @Attribute(events = @EventName("collapse"))
+ public abstract String getOncollapse();
+
+ @Attribute(events = @EventName("datemouseout"))
+ public abstract String getOndatemouseout();
+
+ @Attribute(events = @EventName("datemouseover"))
+ public abstract String getOndatemouseover();
+
+ @Attribute(events = @EventName("expand"))
+ public abstract String getOnExpand();
+
+ @Attribute(events = @EventName("timeselect"))
+ public abstract String getOntimeselect();
+
+ @Attribute(events = @EventName("timeselected"))
+ public abstract String getOntimeselected();
+
+ @Attribute(events = @EventName("clean"))
+ public abstract String getOnclean();
+
+
@Attribute
public Object getLocale() {
Object locale = getStateHelper().eval(PropertyKeys.locale);
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-22 12:48:50 UTC (rev 20128)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-22 12:49:02 UTC (rev 20129)
@@ -41,7 +41,6 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.PartialViewContext;
-import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.DateTimeConverter;
@@ -79,58 +78,10 @@
public static final String CALENDAR_BUNDLE = "org.richfaces.renderkit.calendar";
- public static final String OPTION_ENABLE_MANUAL_INPUT = "enableManualInput";
-
public static final String OPTION_DISABLED = "disabled";
- public static final String OPTION_READONLY = "readonly";
-
- public static final String OPTION_RESET_TIME_ON_DATE_SELECT = "resetTimeOnDateSelect";
-
- public static final String OPTION_SHOW_APPLY_BUTTON = "showApplyButton";
-
public static final String OPTION_MIN_DAYS_IN_FIRST_WEEK = "minDaysInFirstWeek";
- public static final String OPTION_POPUP = "popup";
-
- public static final String OPTION_SHOW_INPUT = "showInput";
-
- public static final String OPTION_SHOW_HEADER = "showHeader";
-
- public static final String OPTION_SHOW_FOOTER = "showFooter";
-
- public static final String OPTION_SHOW_WEEKS_BAR = "showWeeksBar";
-
- public static final String OPTION_TODAY_CONTROL_MODE = "todayControlMode";
-
- public static final String OPTION_DATE_PATTERN = "datePattern";
-
- public static final String OPTION_JOINT_POINT = "jointPoint";
-
- public static final String OPTION_DIRECTION = "direction";
-
- public static final String OPTION_BOUNDARY_DATES_MODE = "boundaryDatesMode";
-
- public static final String OPTION_HORIZONTAL_OFFSET = "horizontalOffset";
-
- public static final String OPTION_VERTICAL_OFFSET = "verticalOffset";
-
- public static final String OPTION_CURRENT_DATE = "currentDate";
-
- public static final String OPTION_SELECTED_DATE = "selectedDate";
-
- public static final String OPTION_DAY_CELL_CLASS = "dayCellClass";
-
- public static final String OPTION_DAY_STYLE_CLASS = "dayStyleClass";
-
- public static final String OPTION_LABELS = "labels";
-
- public static final String OPTION_DEFAULT_TIME = "defaultTime";
-
- public static final String OPTION_HIDE_POPUP_ON_SCROLL = "hidePopupOnScroll";
-
- public static final String OPTION_SHOW_WEEK_DAYS_BAR = "showWeekDaysBar";
-
public static final String MONTH_LABELS_SHORT = "monthLabelsShort";
public static final String MONTH_LABELS = "monthLabels";
@@ -149,9 +100,6 @@
public static final String CURRENT_DATE_INPUT = "InputCurrentDate";
- public static final String OPTION_MODE = "mode";
-
-
protected static final Map<String, ComponentAttribute> CALENDAR_INPUT_HANDLER_ATTRIBUTES = Collections.unmodifiableMap(ComponentAttribute.createMap(
new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
.setEventNames("inputclick")
@@ -205,8 +153,8 @@
return;
}
- AbstractCalendar calendar = (AbstractCalendar)component;
- if (calendar.isDisabled()){
+ AbstractCalendar calendar = (AbstractCalendar) component;
+ if (calendar.isDisabled()) {
return;
}
@@ -245,7 +193,7 @@
// skip conversion of already converted date
if (submittedValue instanceof Date) {
- return (Date)submittedValue;
+ return (Date) submittedValue;
}
// Store submitted value in the local variable as a string
@@ -276,7 +224,7 @@
Object curVal = calendar.getValue();
Converter converter = SelectUtils.findConverter(facesContext, calendar, "value");
- if(converter == null) {
+ if (converter == null) {
converter = createDefaultConverter();
}
@@ -285,7 +233,7 @@
if (converter != null) {
value = converter.getAsString(facesContext, calendar, curVal);
} else {
- value = curVal !=null ? curVal.toString() : "";
+ value = curVal != null ? curVal.toString() : "";
}
}
@@ -315,7 +263,7 @@
public Object getSelectedDate(FacesContext facesContext, UIComponent component) throws IOException {
Object returnValue = null;
- AbstractCalendar calendar = (AbstractCalendar)component;
+ AbstractCalendar calendar = (AbstractCalendar) component;
if (calendar.isValid()) {
Date date;
Object value = calendar.getValue();
@@ -343,13 +291,14 @@
return result;
}
- public Object getCurrentDate(FacesContext facesContext, AbstractCalendar calendar) throws IOException {
+ public Object getCurrentDate(FacesContext facesContext, UIComponent component) throws IOException {
+ AbstractCalendar calendar = (AbstractCalendar) component;
Date date = CalendarHelper.getCurrentDateOrDefault(facesContext, calendar);
return formatDate(date);
}
public String getCurrentDateAsString(FacesContext facesContext, UIComponent component) throws IOException {
- AbstractCalendar calendar = (AbstractCalendar)component;
+ AbstractCalendar calendar = (AbstractCalendar) component;
Format formatter = new SimpleDateFormat("MM/yyyy");
Date currentDate = CalendarHelper.getCurrentDateOrDefault(facesContext, calendar);
@@ -367,7 +316,7 @@
return result;
}
- public String getDayCellClass(FacesContext facesContext, AbstractCalendar calendar) {
+ public String getDayCellClass(FacesContext facesContext, UIComponent component) {
//TODO: refactor this
/*
String cellwidth = (String) component.getAttributes().get("cellWidth");
@@ -386,12 +335,15 @@
return calendar.isDayEnabled() ? JSReference.TRUE : JSReference.FALSE;
}
- public JSReference getDayStyleClass(FacesContext context, AbstractCalendar calendar) {
+ public JSReference getDayStyleClass(FacesContext context, UIComponent component) {
+ AbstractCalendar calendar = (AbstractCalendar) component;
String dayStyleClass = calendar.getDayStyleClass();
return ((dayStyleClass != null && dayStyleClass.trim().length() != 0)) ? new JSReference(dayStyleClass) : null;
}
- public Map<String, Object> getLabels(FacesContext facesContext, AbstractCalendar calendar) {
+ public Map<String, Object> getLabels(FacesContext facesContext, UIComponent component) {
+ AbstractCalendar calendar = (AbstractCalendar) component;
+
ResourceBundle bundle1 = null;
ResourceBundle bundle2 = null;
@@ -400,7 +352,7 @@
String messageBundle = facesContext.getApplication().getMessageBundle();
Locale locale = CalendarHelper.getAsLocale(facesContext, calendar);
if (null != messageBundle) {
- bundle1 = ResourceBundle.getBundle(messageBundle,locale , loader);
+ bundle1 = ResourceBundle.getBundle(messageBundle, locale, loader);
}
try {
@@ -418,10 +370,10 @@
protected Map<String, Object> getCollectedLabels(ResourceBundle [] bundles , String[] names) {
Map<String, Object> labels = new HashMap<String, Object>();
if (bundles != null && names != null) {
- for (String name: names) {
+ for (String name : names) {
String label = null;
String bundleKey = "RICH_CALENDAR_" + name.toUpperCase() + "_LABEL";
- for (ResourceBundle bundle: bundles) {
+ for (ResourceBundle bundle : bundles) {
if (bundle != null) {
try {
label = bundle.getString(bundleKey);
@@ -439,7 +391,9 @@
return labels;
}
- public Map<String, Object> getPreparedDefaultTime(FacesContext facesContext, AbstractCalendar abstractCalendar) {
+ public Map<String, Object> getPreparedDefaultTime(FacesContext facesContext, UIComponent component) {
+ AbstractCalendar abstractCalendar = (AbstractCalendar) component;
+
Date date = CalendarHelper.getFormattedDefaultTime(abstractCalendar);
Map<String, Object> result = new HashMap<String, Object>();
if (date != null) {
@@ -472,7 +426,9 @@
return shiftedLabels;
}
- protected Map<String, Object> getLocaleOptions(FacesContext facesContext, AbstractCalendar calendarComponent) {
+ protected Map<String, Object> getLocaleOptions(FacesContext facesContext, UIComponent component) {
+ AbstractCalendar calendarComponent = (AbstractCalendar) component;
+
Map<String, Object> map = new HashMap<String, Object>();
Locale locale = CalendarHelper.getAsLocale(facesContext, calendarComponent);
@@ -531,74 +487,30 @@
if (0 <= day && day <= 6) {
RenderKitUtils.addToScriptHash(map, FIRST_DAY_WEEK, day);
} else if (day != Integer.MIN_VALUE) {
- facesContext.getExternalContext().log(day + " value of firstWeekDay attribute is not a legal one for component: " + MessageUtil.getLabel(facesContext, calendarComponent) + ". Default value was applied.");
+ facesContext.getExternalContext().log(
+ day + " value of firstWeekDay attribute is not a legal one for component: "
+ + MessageUtil.getLabel(facesContext, calendarComponent) + ". Default value was applied.");
}
return map;
}
-
- public ScriptOptions createCalendarScriptOption(FacesContext facesContext, UIComponent component) throws IOException {
- AbstractCalendar calendar = (AbstractCalendar)component;
- ScriptOptions scriptOptions = new ScriptOptions(component);
- scriptOptions.addOption(OPTION_ENABLE_MANUAL_INPUT);
- scriptOptions.addOption(OPTION_DISABLED);
- scriptOptions.addOption(OPTION_READONLY);
- scriptOptions.addOption(OPTION_RESET_TIME_ON_DATE_SELECT);
- scriptOptions.addOption(OPTION_SHOW_APPLY_BUTTON);
- scriptOptions.addOption(OPTION_POPUP);
- scriptOptions.addOption(OPTION_SHOW_INPUT);
- scriptOptions.addOption(OPTION_SHOW_HEADER);
- scriptOptions.addOption(OPTION_SHOW_FOOTER);
- scriptOptions.addOption(OPTION_SHOW_WEEKS_BAR);
- scriptOptions.addOption(OPTION_TODAY_CONTROL_MODE);
- scriptOptions.addOption(OPTION_DATE_PATTERN);
- scriptOptions.addOption(OPTION_JOINT_POINT);
- scriptOptions.addOption(OPTION_DIRECTION);
- scriptOptions.addOption(OPTION_BOUNDARY_DATES_MODE);
- scriptOptions.addOption(OPTION_HORIZONTAL_OFFSET);
- scriptOptions.addOption(OPTION_VERTICAL_OFFSET);
- scriptOptions.addOption(OPTION_CURRENT_DATE, getCurrentDate(facesContext, calendar));
- scriptOptions.addOption(OPTION_SELECTED_DATE, getSelectedDate(facesContext, calendar));
- scriptOptions.addOption(OPTION_DAY_CELL_CLASS, getDayCellClass(facesContext, calendar));
- scriptOptions.addOption(OPTION_DAY_STYLE_CLASS, getDayStyleClass(facesContext, calendar));
- /*
- *add to script option
- *<cdk:scriptOption attributes="ondateselected, ondateselect, ontimeselect, ontimeselected, onchanged, ondatemouseover, ondatemouseout, onexpand, oncollapse, oncurrentdateselect, oncurrentdateselected" wrapper="eventHandler" />
- * */
- scriptOptions.addOption(OPTION_LABELS, getLabels(facesContext, calendar));
- scriptOptions.addOption(OPTION_DEFAULT_TIME, getPreparedDefaultTime(facesContext, calendar));
- scriptOptions.addOption(OPTION_HIDE_POPUP_ON_SCROLL);
- scriptOptions.addOption("showWeekDaysBar");
-
- scriptOptions.addOption("styleClass");
- scriptOptions.addOption("style", HtmlUtil.concatStyles("z-index: " + calendar.getZindex(), calendar.getStyle()));
- scriptOptions.addOption(OPTION_MODE, calendar.getMode());
-
- return scriptOptions;
+
+ public String getStyleWithZindex(FacesContext facesContext, UIComponent component) {
+ AbstractCalendar calendar = (AbstractCalendar) component;
+ String style = HtmlUtil.concatStyles("z-index: " + calendar.getZindex(), calendar.getStyle());
+ return style;
}
- public void buildAddLocaleScript(ResponseWriter writer, FacesContext facesContext, UIComponent component) throws IOException {
- if (component instanceof AbstractCalendar) {
- AbstractCalendar calendar = (AbstractCalendar)component;
- JSFunction function = new JSFunction("RichFaces.ui.Calendar.addLocale", CalendarHelper.getAsLocale(facesContext, calendar).toString(), getLocaleOptions(facesContext, calendar));
- writer.write(function.toScript());
- writer.write(";");
- }
+ public Locale getAsLocale(FacesContext facesContext, UIComponent component) {
+ return CalendarHelper.getAsLocale(facesContext, component);
}
- public void buildCalendarScript(ResponseWriter writer, FacesContext facesContext, UIComponent component) throws IOException {
- if (component instanceof AbstractCalendar) {
- AbstractCalendar calendar = (AbstractCalendar)component;
- ScriptOptions scriptOptions = createCalendarScriptOption(facesContext, calendar);
- JSFunction function = new JSFunction("new RichFaces.ui.Calendar", calendar.getClientId(facesContext), CalendarHelper.getAsLocale(facesContext, calendar).toString(), scriptOptions, "");
- StringBuffer scriptBuffer = new StringBuffer();
- scriptBuffer.append(function.toScript()).append(".load(");
- Object preload = calendar.getPreload();
- if (null != preload){
- scriptBuffer.append(RenderKitUtils.toScriptArgs(preload));
- }
-
- scriptBuffer.append(");");
- writer.write(scriptBuffer.toString());
+ public String writePreloadBody(FacesContext context, UIComponent component) throws IOException {
+ AbstractCalendar calendar = (AbstractCalendar) component;
+ Object preload = calendar.getPreload();
+ if (preload != null) {
+ return RenderKitUtils.toScriptArgs(preload);
+ } else {
+ return null;
}
}
Modified: trunk/ui/input/ui/src/main/templates/calendar.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/calendar.template.xml 2010-11-22 12:48:50 UTC (rev 20128)
+++ trunk/ui/input/ui/src/main/templates/calendar.template.xml 2010-11-22 12:49:02 UTC (rev 20129)
@@ -67,11 +67,25 @@
<span style="display: none;" id="#{clientId}Content"></span>
<span style="display: none;" id="#{clientId}Script">
<script type="text/javascript">
- <cdk:call
- expression="buildAddLocaleScript(responseWriter, facesContext, component);" />
- <cdk:call
- expression="buildCalendarScript(responseWriter, facesContext, component);" />
- </script>
+
+ <cdk:scriptObject name="options">
+ <cdk:scriptOption attributes="enableManualInput disabled readonly resetTimeOnDateSelect showApplyButton popup showInput showHeader showFooter showWeeksBar todayControlMode datePattern jointPoint direction boundaryDatesMode horizontalOffset verticalOffset hidePopupOnScrol showWeekDaysBar styleClass mode" />
+ <cdk:scriptOption attributes="onchange ondateselect ondateselected oncurrentdateselected oncollapse onexpand ondatemouseover ondatemouseout onclean ontimeselect ontimeselected" wrapper="eventHandler" />
+ <cdk:scriptOption name="currentDate" value="#{getCurrentDate(facesContext, component)}" />
+ <cdk:scriptOption name="selectedDate" value="#{getSelectedDate(facesContext, component)}" />
+ <cdk:scriptOption name="dayCellClass" value="#{getDayCellClass(facesContext, component)}" />
+ <cdk:scriptOption name="dayStyleClass" value="#{getDayStyleClass(facesContext, component)}" />
+ <cdk:scriptOption name="labels" value="#{getLabels(facesContext, component)}" />
+ <cdk:scriptOption name="defaultTime" value="#{getPreparedDefaultTime(facesContext, component)}" />
+ <cdk:scriptOption name="style" value="#{getStyleWithZindex(facesContext, component)}" />
+ </cdk:scriptObject>
+
+ RichFaces.ui.Calendar.addLocale("#{getAsLocale(facesContext, component).toString()}",
+ #{toScriptArgs(getLocaleOptions(facesContext, component))});
+ new RichFaces.ui.Calendar("#{clientId}", "#{getAsLocale(facesContext, component).toString()}",
+ #{toScriptArgs(options)}).load(#{writePreloadBody(facesContext, component)});
+
+ --></script>
</span>
</span>
</cc:implementation>
14 years, 1 month
JBoss Rich Faces SVN: r20128 - trunk/examples/input-demo/src/main/webapp/examples.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-11-22 07:48:50 -0500 (Mon, 22 Nov 2010)
New Revision: 20128
Modified:
trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
Log:
https://jira.jboss.org/browse/RF-9685 Calendar component: client-side events + demo
https://jira.jboss.org/browse/RF-7794 rich:calendar needs event handler "onclean",
https://jira.jboss.org/browse/RF-9602 calendar: onchange not implemented so value can't be stored via ajax for (common use-case)
Modified: trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-19 18:24:33 UTC (rev 20127)
+++ trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-22 12:48:50 UTC (rev 20128)
@@ -4,6 +4,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j"
xmlns:calendar="http://richfaces.org/input">
<!--
JBoss, Home of Professional Open Source
@@ -34,7 +35,7 @@
</h:head>
<h:body>
<h:form id="form">
- <h:panelGrid id="panel" columns="2">
+ <h:panelGrid id="panel" columns="3">
<h:panelGroup layout="block">
<calendar:calendar value="#{calendarBean.selectedDate}" id="calendar"
jointPoint="#{calendarBean.jointPoint}" direction="#{calendarBean.direction}"
@@ -43,9 +44,24 @@
dataModel="#{calendarDataModel}"
mode="#{calendarBean.mode}"
showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
- cellHeight="22px" style="width:200px" minDaysInFirstWeek="3">
- <f:convertDateTime pattern="#{calendarBean.pattern}" />
+ cellHeight="22px" style="width:200px" minDaysInFirstWeek="3"
+ oncollapse="return onEvent.call(this, event);"
+ onexpand="return onEvent.call(this, event);"
+ oncurrentdateselect="return onEvent.call(this, event);"
+ oncurrentdateselected="return onEvent.call(this, event);"
+ ondateselect="return onEvent.call(this, event);"
+ ondateselected="return onEvent.call(this, event);"
+ ontimeselect="return onEvent.call(this, event);"
+ ontimeselected="return onEvent.call(this, event);"
+ oncomplete="return onEvent.call(this, event);"
+ onclean="return onEvent.call(this, event);"
+ ondatemouseout="return onEvent.call(this, event);"
+ ondatemouseover="return onEvent.call(this, event);"
+
+ >
+ <f:ajax event="change" render="echo-text" />
</calendar:calendar>
+ <h:outputText id="echo-text" value="#{calendarBean.selectedDate}" />
</h:panelGroup>
<h:panelGrid columns="2">
<h:outputText value="Popup Mode:" />
@@ -101,6 +117,17 @@
<f:selectItem itemLabel="bottom-right" itemValue="bottom-right" />
</h:selectOneMenu>
</h:panelGrid>
+ <h:panelGroup layout="block">
+ <div>
+ <a4j:log mode="inline"></a4j:log>
+ </div>
+ <script type="text/javascript">
+ onEvent = function(event, element, data){
+ RichFaces.log.info("jQuery Event: "+(event instanceof jQuery.Event)+"; event: "+event.type+"; data:"+(data || (event['rich']||{})['data'])+"; this.id:"+this.id+"; component:"+ (event['rich']||{})['component']||RichFaces.$(this.id));
+ };
+ //RichFaces.Event.bindById("form:calendar", "dateselect dateselected currentdateselect currentdateselected timeselect timeselected changed clean collapse expand complete datemouseout datemouseout", onEvent);
+ </script>
+ </h:panelGroup>
</h:panelGrid>
</h:form>
</h:body>
14 years, 1 month
JBoss Rich Faces SVN: r20127 - in sandbox/trunk/ui/drag-drop/ui/src/main: java/org/richfaces/renderkit and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-11-19 13:24:33 -0500 (Fri, 19 Nov 2010)
New Revision: 20127
Added:
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/dnd.faces-config.xml
Modified:
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DragBehavior.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DropBehavior.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
Log:
apply workaround for the https://jira.jboss.org/browse/RF-9847
Modified: sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DragBehavior.java
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DragBehavior.java 2010-11-19 18:03:10 UTC (rev 20126)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DragBehavior.java 2010-11-19 18:24:33 UTC (rev 20127)
@@ -23,8 +23,11 @@
package org.richfaces.component.behavior;
+import javax.faces.render.RenderKitFactory;
+
import org.ajax4jsf.component.behavior.ClientBehavior;
import org.richfaces.cdk.annotations.JsfBehavior;
+import org.richfaces.cdk.annotations.JsfBehaviorRenderer;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
@@ -34,7 +37,7 @@
*/
@JsfBehavior(
- id = DragBehavior.BEHAVIOR_ID, tag = @Tag(name = "dragBehavior", handler = "org.richfaces.view.facelets.html.CustomBehaviorHandler", type = TagType.Facelets)
+ id = DragBehavior.BEHAVIOR_ID, renderer = @JsfBehaviorRenderer(renderKitId=RenderKitFactory.HTML_BASIC_RENDER_KIT, type=DropBehavior.BEHAVIOR_ID), tag = @Tag(name = "dragBehavior", handler = "org.richfaces.view.facelets.html.CustomBehaviorHandler", type = TagType.Facelets)
)
public class DragBehavior extends ClientBehavior {
@@ -44,4 +47,14 @@
public void setLiteralAttribute(String name, Object value) {
}
+
+ public String getEvent() {
+ return "mousedown";
+ }
+
+ @Override
+ public String getRendererType() {
+ return BEHAVIOR_ID;
+ }
+
}
Modified: sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DropBehavior.java
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DropBehavior.java 2010-11-19 18:03:10 UTC (rev 20126)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/behavior/DropBehavior.java 2010-11-19 18:24:33 UTC (rev 20127)
@@ -23,8 +23,10 @@
package org.richfaces.component.behavior;
+import javax.faces.render.RenderKitFactory;
import org.ajax4jsf.component.behavior.ClientBehavior;
import org.richfaces.cdk.annotations.JsfBehavior;
+import org.richfaces.cdk.annotations.JsfBehaviorRenderer;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
@@ -34,13 +36,18 @@
*/
@JsfBehavior(
- id = DropBehavior.BEHAVIOR_ID, tag = @Tag(name = "dropBehavior", handler = "org.richfaces.view.facelets.html.CustomBehaviorHandler", type = TagType.Facelets))
+ id = DropBehavior.BEHAVIOR_ID, renderer = @JsfBehaviorRenderer(renderKitId=RenderKitFactory.HTML_BASIC_RENDER_KIT, type=DropBehavior.BEHAVIOR_ID), tag = @Tag(name = "dropBehavior", handler = "org.richfaces.view.facelets.html.CustomBehaviorHandler", type = TagType.Facelets))
public class DropBehavior extends ClientBehavior {
public static final String BEHAVIOR_ID = "org.richfaces.component.behavior.DropBehavior";
+
@Override
public void setLiteralAttribute(String name, Object value) {
}
+ @Override
+ public String getRendererType() {
+ return BEHAVIOR_ID;
+ }
}
Modified: sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java 2010-11-19 18:03:10 UTC (rev 20126)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java 2010-11-19 18:24:33 UTC (rev 20127)
@@ -24,13 +24,21 @@
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.render.ClientBehaviorRenderer;
+import javax.faces.render.RenderKitFactory;
+import org.richfaces.cdk.annotations.JsfBehaviorRenderer;
+import org.richfaces.component.behavior.DropBehavior;
+
/**
* @author abelevich
*
*/
+(a)JsfBehaviorRenderer(renderKitId=RenderKitFactory.HTML_BASIC_RENDER_KIT, type=DropBehavior.BEHAVIOR_ID)
+
@ResourceDependencies({
@ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "jquery-ui-core.js"),
@@ -39,5 +47,8 @@
@ResourceDependency(name = "richfaces-dnd.js")
})
public class DragBehaviorRendererBase extends ClientBehaviorRenderer {
-
+ @Override
+ public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior behavior) {
+ return "DragBehavior encoded";
+ }
}
Modified: sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java 2010-11-19 18:03:10 UTC (rev 20126)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java 2010-11-19 18:24:33 UTC (rev 20127)
@@ -24,6 +24,8 @@
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.render.ClientBehaviorRenderer;
/**
@@ -39,4 +41,11 @@
@ResourceDependency(name = "richfaces-dnd.js")
})
public class DropBehaviorRendererBase extends ClientBehaviorRenderer {
+
+ @Override
+ public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior behavior) {
+ return "DropBehavior encoded";
+ }
+
+
}
Added: sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/dnd.faces-config.xml
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/dnd.faces-config.xml (rev 0)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/dnd.faces-config.xml 2010-11-19 18:24:33 UTC (rev 20127)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<faces-config version="2.0" metadata-complete="false"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <behavior>
+ <description> @author abelevich
+
+</description>
+ <behavior-id>org.richfaces.component.behavior.DropBehavior</behavior-id>
+ <behavior-class>org.richfaces.component.behavior.DropBehavior</behavior-class>
+ <behavior-extension>
+ <cdk:base-class>org.richfaces.component.behavior.DropBehavior
+ </cdk:base-class>
+ <cdk:generate>false</cdk:generate>
+ </behavior-extension>
+ </behavior>
+ <behavior>
+ <description> @author abelevich
+
+</description>
+ <behavior-id>org.richfaces.component.behavior.DragBehavior</behavior-id>
+ <behavior-class>org.richfaces.component.behavior.DragBehavior</behavior-class>
+ <behavior-extension>
+ <cdk:base-class>org.richfaces.component.behavior.DragBehavior
+ </cdk:base-class>
+ <cdk:generate>false</cdk:generate>
+ </behavior-extension>
+ </behavior>
+
+ <render-kit>
+ <render-kit-id>HTML_BASIC</render-kit-id>
+ <client-behavior-renderer>
+ <client-behavior-renderer-type>org.richfaces.component.behavior.DropBehavior</client-behavior-renderer-type>
+ <client-behavior-renderer-class>org.richfaces.renderkit.DropBehaviorRendererBase</client-behavior-renderer-class>
+ </client-behavior-renderer>
+ <client-behavior-renderer>
+ <client-behavior-renderer-type>org.richfaces.component.behavior.DragBehavior</client-behavior-renderer-type>
+ <client-behavior-renderer-class>org.richfaces.renderkit.DragBehaviorRendererBase</client-behavior-renderer-class>
+ </client-behavior-renderer>
+ </render-kit>
+
+ <faces-config-extension>
+ <cdk:prefix>org.richfaces.component</cdk:prefix>
+ <cdk:taglib>
+ <cdk:shortName>dnd</cdk:shortName>
+ <cdk:uri>http://richfaces.org/dnd</cdk:uri>
+ </cdk:taglib>
+ </faces-config-extension>
+
+</faces-config>
14 years, 1 month
JBoss Rich Faces SVN: r20126 - sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-11-19 13:03:10 -0500 (Fri, 19 Nov 2010)
New Revision: 20126
Modified:
sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js
Log:
RF-9496
Modified: sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js
===================================================================
--- sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js 2010-11-19 18:02:08 UTC (rev 20125)
+++ sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js 2010-11-19 18:03:10 UTC (rev 20126)
@@ -102,15 +102,18 @@
__submit: function() {
var originalAction = this.form.attr("action");
+ var originalEncoding = this.form.attr("encoding");
var originalEnctype = this.form.attr("enctype");
try {
this.loadableItem.input.attr("name", this.id);
this.form.attr("action", originalAction + "?" + UID + "=1");
+ this.form.attr("encoding", "multipart/form-data");
this.form.attr("enctype", "multipart/form-data");
this.iframe.load(jQuery.proxy(this.__load, this));
richfaces.submitForm(this.form, null, this.id);
} finally {
this.form.attr("action", originalAction);
+ this.form.attr("encoding", originalEncoding);
this.form.attr("enctype", originalEnctype);
this.loadableItem.input.removeAttr("name");
}
14 years, 1 month