JBoss Rich Faces SVN: r20252 - in trunk: examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar and 11 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2010-12-01 10:01:15 -0500 (Wed, 01 Dec 2010)
New Revision: 20252
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/clientStylingDisablement.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/panelMenu.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/CalendarBean.java
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/calendar-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tooltip/samples/tooltip-sample.xhtml
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-9834 + calendar refactoring and issue fixes in client functions attributes
+ tooltip minor layout correction
+ panelMenu sample draft
Modified: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/CalendarBean.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/CalendarBean.java 2010-12-01 10:55:48 UTC (rev 20251)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/CalendarBean.java 2010-12-01 15:01:15 UTC (rev 20252)
@@ -17,6 +17,7 @@
private Date selectedDate;
private boolean showApply = true;
private boolean useCustomDayLabels;
+ private boolean disabled = false;
public CalendarBean() {
@@ -83,4 +84,12 @@
this.showApply = showApply;
}
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
}
\ No newline at end of file
Added: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/panelmenu/PanelMenuBean.java 2010-12-01 15:01:15 UTC (rev 20252)
@@ -0,0 +1,33 @@
+package org.richfaces.demo.panelmenu;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+
+import org.richfaces.event.ItemChangeEvent;
+@ManagedBean
+@RequestScoped
+public class PanelMenuBean {
+ private String current;
+ private boolean singleMode;
+ public boolean isSingleMode() {
+ return singleMode;
+ }
+
+ public void setSingleMode(boolean singleMode) {
+ this.singleMode = singleMode;
+ }
+
+ public PanelMenuBean() {
+ }
+
+ public String getCurrent() {
+ return this.current;
+ }
+
+ public void setCurrent(String current) {
+ this.current = current;
+ }
+ public void updateCurrent(ItemChangeEvent event) {
+ setCurrent(event.getNewItem());
+ }
+}
Modified: trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-01 10:55:48 UTC (rev 20251)
+++ trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-01 15:01:15 UTC (rev 20252)
@@ -422,6 +422,16 @@
<name>Menus</name>
<demos>
<demo new="true">
+ <id>panelMenu</id>
+ <name>rich:panelMenu</name>
+ <samples>
+ <sample>
+ <id>panelMenu</id>
+ <name>Simple Panel Menu</name>
+ </sample>
+ </samples>
+ </demo>
+ <demo new="true">
<id>toolBar</id>
<name>rich:toolBar</name>
<samples>
@@ -458,10 +468,14 @@
<id>calendar</id>
<name>rich:calendar</name>
<samples>
- <sample>
+ <sample new="true">
<id>calendar</id>
<name>Simple Calendar</name>
</sample>
+ <sample new="true">
+ <id>clientStylingDisablement</id>
+ <name>Client Side Styling/Disablement</name>
+ </sample>
</samples>
</demo>
<demo>
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/clientStylingDisablement.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/clientStylingDisablement.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/clientStylingDisablement.xhtml 2010-12-01 15:01:15 UTC (rev 20252)
@@ -0,0 +1,20 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition>
+ <p>This simple example shows the way of client side dates
+ disablement and styling without dataModel usage.</p>
+
+ <ui:include src="#{demoNavigator.sampleIncludeURI}" />
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}" />
+ <ui:param name="sourceType" value="xhtml" />
+ <ui:param name="openLabel" value="View Source" />
+ <ui:param name="hideLabel" value="Hide Source" />
+ </ui:include>
+</ui:composition>
+
+</html>
\ No newline at end of file
Modified: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/calendar-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/calendar-sample.xhtml 2010-12-01 10:55:48 UTC (rev 20251)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/calendar-sample.xhtml 2010-12-01 15:01:15 UTC (rev 20252)
@@ -29,39 +29,46 @@
locale="#{calendarBean.locale}" popup="#{calendarBean.popup}"
datePattern="#{calendarBean.pattern}"
showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
- cellHeight="22px" style="width:200px">
+ cellHeight="22px" style="width:200px"
+ disabled="#{calendarBean.disabled}">
</rich:calendar>
</a4j:outputPanel>
- <h:panelGrid columns="2">
- <h:outputText value="Popup Mode:" />
- <h:selectBooleanCheckbox value="#{calendarBean.popup}">
- <a4j:ajax event="click" render="calendar @this" />
- </h:selectBooleanCheckbox>
- <h:outputText value="Apply Button:" />
- <h:selectBooleanCheckbox value="#{calendarBean.showApply}">
- <a4j:ajax event="click" render="calendar @this" />
- </h:selectBooleanCheckbox>
- <h:outputText value="Select Locale" />
- <h:selectOneRadio value="en/US"
- valueChangeListener="#{calendarBean.selectLocale}">
- <a4j:ajax event="click" render="calendar @this" />
- <f:selectItem itemLabel="US" itemValue="en/US" />
- <f:selectItem itemLabel="DE" itemValue="de/DE" />
- <f:selectItem itemLabel="FR" itemValue="fr/FR" />
- <f:selectItem itemLabel="RU" itemValue="ru/RU" />
- </h:selectOneRadio>
+ <a4j:region>
+ <h:panelGrid columns="2">
+ <h:outputText value="Disabled:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.disabled}">
+ <a4j:ajax event="click" render="calendar @this" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="Popup Mode:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.popup}">
+ <a4j:ajax event="click" render="calendar @this" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="Apply Button:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.showApply}">
+ <a4j:ajax event="click" render="calendar @this" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="Select Locale" />
+ <h:selectOneRadio value="en/US"
+ valueChangeListener="#{calendarBean.selectLocale}">
+ <a4j:ajax event="click" render="calendar @this" />
+ <f:selectItem itemLabel="US" itemValue="en/US" />
+ <f:selectItem itemLabel="DE" itemValue="de/DE" />
+ <f:selectItem itemLabel="FR" itemValue="fr/FR" />
+ <f:selectItem itemLabel="RU" itemValue="ru/RU" />
+ </h:selectOneRadio>
- <h:outputText value="Select Date Pattern:" />
- <h:selectOneMenu value="#{calendarBean.pattern}">
- <a4j:ajax event="change" render="calendar @this" />
- <f:selectItem itemLabel="d/M/yy HH:mm" itemValue="d/M/yy HH:mm" />
- <f:selectItem itemLabel="dd/M/yy hh:mm a"
- itemValue="dd/M/yy hh:mm a" />
- <f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y" />
- <f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy" />
- </h:selectOneMenu>
+ <h:outputText value="Select Date Pattern:" />
+ <h:selectOneMenu value="#{calendarBean.pattern}">
+ <a4j:ajax event="change" render="calendar @this" />
+ <f:selectItem itemLabel="d/M/yy HH:mm" itemValue="d/M/yy HH:mm" />
+ <f:selectItem itemLabel="dd/M/yy hh:mm a"
+ itemValue="dd/M/yy hh:mm a" />
+ <f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y" />
+ <f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy" />
+ </h:selectOneMenu>
- </h:panelGrid>
+ </h:panelGrid>
+ </a4j:region>
</h:panelGrid>
</h:form>
</ui:composition>
\ No newline at end of file
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml 2010-12-01 15:01:15 UTC (rev 20252)
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ 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:rich="http://richfaces.org/rich">
+ <style>
+.everyThirdDay {
+ background-color: gray;
+}
+
+.weekendBold {
+ font-weight: bold;
+ font-style: italic;
+}
+</style>
+ <script type="text/javascript">
+ var curDt = new Date();
+ function disablementFunction(day){
+ if (day.isWeekend) return false;
+ if (curDt==undefined){
+ curDt = day.date.getDate;
+ }
+ if (curDt.getTime() - day.date.getTime() < 0) return true; else return false;
+ }
+ function disabledClassesProv(day){
+ if (curDt.getTime() - day.date.getTime() >= 0) return 'rf-ca-boundary-dates';
+ var res = '';
+ if (day.isWeekend) res+='weekendBold ';
+ if (day.day%3==0) res+='everyThirdDay';
+ return res;
+ }
+ </script>
+ <rich:calendar dayDisableFunction="disablementFunction"
+ dayClassFunction="disabledClassesProv" boundaryDatesMode="scroll" />
+
+</ui:composition>
\ No newline at end of file
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/panelMenu.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/panelMenu.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/panelMenu.xhtml 2010-12-01 15:01:15 UTC (rev 20252)
@@ -0,0 +1,39 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition>
+ <p>The <b>rich:panelMenu</b> component is used to define a
+ collapsible side-menu panel. The component has a pre-defined skinable
+ look-n-feel. You can customize it with styles and a set of component
+ attributes. The folowing demo shows the example of rich:panelMenu</p>
+
+ <ui:include src="#{demoNavigator.sampleIncludeURI}" />
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}" />
+ <ui:param name="sourceType" value="xhtml" />
+ <ui:param name="openLabel" value="View Source" />
+ <ui:param name="hideLabel" value="Hide Source" />
+ </ui:include>
+ <p>Switching mode could be chosen with the <b>itemMode</b>
+ attribute for all panelMenu items except ones where this attribute was
+ redefined.</p>
+ <p>The <b>groupMode</b> attribute defines the submission modes for
+ all collapsing/expanding panelMenu groups except ones where this
+ attribute was redefined.</p>
+ <p>The <b>itemMode </b>and <b>groupMode </b>attributes could be
+ used with three possible parameters:</p>
+ <ul>
+ <li><b>server</b> (default) - The common submission of the form
+ is performed and a page is completely refreshed.</li>
+ <li><b>ajax</b> - An Ajax form submission is performed, and
+ additionally specified elements in the "reRender" attribute are
+ reRendered</li>
+ <li><b>client</b> Items don't fire any submits itself. Behavior
+ is completely defined by the components nested to items. Groups expand
+ on the client side.</li>
+ </ul>
+</ui:composition>
+</html>
\ No newline at end of file
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml 2010-12-01 15:01:15 UTC (rev 20252)
@@ -0,0 +1,78 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ 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:rich="http://richfaces.org/rich">
+ <style>
+.cols {
+ vertical-align: top;
+}
+</style>
+ <h:form id="form">
+ <h:panelGrid columns="2" columnClasses="cols,cols" width="400">
+ <rich:panelMenu style="width:200px" mode="ajax"
+ iconExpandedGroup="disc" iconCollapsedGroup="disc"
+ iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
+ iconCollapsedTopGroup="chevronDown"
+ itemChangeListener="#{panelMenuBean.updateCurrent}">
+ <rich:panelMenuGroup label="Group 1">
+ <rich:panelMenuItem label="Item 1.1">
+ <f:param name="current" value="Item 1.1" />
+ </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 1.2">
+ <f:param name="current" value="Item 1.2" />
+ </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 1.3">
+ <f:param name="current" value="Item 1.3" />
+ </rich:panelMenuItem>
+ </rich:panelMenuGroup>
+ <rich:panelMenuGroup label="Group 2">
+ <rich:panelMenuItem label="Item 2.1">
+ <f:param name="current" value="Item 2.1" />
+ </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 2.2">
+ <f:param name="current" value="Item 2.2" />
+ </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 2.3">
+ <f:param name="current" value="Item 2.3" />
+ </rich:panelMenuItem>
+ <rich:panelMenuGroup label="Group 2.4">
+ <rich:panelMenuItem label="Item 2.4.1">
+ <f:param name="current" value="Item 2.4.1" />
+ </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 2.4.2">
+ <f:param name="current" value="Item 2.4.2" />
+ </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 2.4.3">
+ <f:param name="current" value="Item 2.4.3" />
+ </rich:panelMenuItem>
+ </rich:panelMenuGroup>
+ <rich:panelMenuItem label="Item 2.5">
+ <f:param name="current" value="Item 2.5" />
+ </rich:panelMenuItem>
+ </rich:panelMenuGroup>
+ <rich:panelMenuGroup label="Group 3">
+ <rich:panelMenuItem label="Item 3.1">
+ <f:param name="current" value="Item 3.1" />
+ </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 3.2">
+ <f:param name="current" value="Item 3.2" />
+ </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 3.3">
+ <f:param name="current" value="Item 3.3" />
+ </rich:panelMenuItem>
+ </rich:panelMenuGroup>
+ </rich:panelMenu>
+ <rich:panel bodyClass="rich-laguna-panel-no-header">
+ <a4j:outputPanel ajaxRendered="true">
+ <h:outputText value="#{panelMenuBean.current} selected" id="current" />
+ </a4j:outputPanel>
+ </rich:panel>
+ </h:panelGrid>
+ <rich:tabPanel>
+ <rich:tab label="12 ">asdasd</rich:tab>
+ </rich:tabPanel>
+ </h:form>
+</ui:composition>
\ No newline at end of file
Modified: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tooltip/samples/tooltip-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tooltip/samples/tooltip-sample.xhtml 2010-12-01 10:55:48 UTC (rev 20251)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tooltip/samples/tooltip-sample.xhtml 2010-12-01 15:01:15 UTC (rev 20252)
@@ -9,7 +9,6 @@
.tooltip {
background-color: #{ richSkin.generalBackgroundColor};
border-width:3px;
- padding:10px;
}
.tooltip-custom-body {
background-color: orange;
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-12-01 10:55:48 UTC (rev 20251)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-12-01 15:01:15 UTC (rev 20252)
@@ -138,8 +138,8 @@
@Attribute(defaultValue = "false")
public abstract boolean isEnableManualInput();
- @Attribute(defaultValue = "false")
- public abstract boolean isDayEnabled();
+ @Attribute
+ public abstract String getDayDisableFunction();
@Attribute(defaultValue = "false")
public abstract boolean isShowApplyButton();
@@ -184,7 +184,7 @@
public abstract Object getWeekDayLabels();
@Attribute
- public abstract String getDayStyleClass();
+ public abstract String getDayClassFunction();
@Attribute
public abstract String getTabindex();
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-12-01 10:55:48 UTC (rev 20251)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-12-01 15:01:15 UTC (rev 20252)
@@ -333,13 +333,15 @@
return null;
}
- public JSReference getIsDayEnabled(FacesContext facesContext, AbstractCalendar calendar) {
- return calendar.isDayEnabled() ? JSReference.TRUE : JSReference.FALSE;
+ public JSReference getDayEnabled(FacesContext facesContext, UIComponent component) {
+ AbstractCalendar calendar = (AbstractCalendar) component;
+ String dayEnabled = calendar.getDayDisableFunction();
+ return ((dayEnabled != null && dayEnabled.trim().length() != 0)) ? new JSReference(dayEnabled) : null;
}
public JSReference getDayStyleClass(FacesContext context, UIComponent component) {
AbstractCalendar calendar = (AbstractCalendar) component;
- String dayStyleClass = calendar.getDayStyleClass();
+ String dayStyleClass = calendar.getDayClassFunction();
return ((dayStyleClass != null && dayStyleClass.trim().length() != 0)) ? new JSReference(dayStyleClass) : null;
}
Modified: trunk/ui/input/ui/src/main/templates/calendar.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/calendar.template.xml 2010-12-01 10:55:48 UTC (rev 20251)
+++ trunk/ui/input/ui/src/main/templates/calendar.template.xml 2010-12-01 15:01:15 UTC (rev 20252)
@@ -75,6 +75,7 @@
<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="isDayEnabled" value="#{getDayEnabled(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)}" />
14 years
JBoss Rich Faces SVN: r20251 - in trunk/examples/richfaces-showcase/src/main: java/org/richfaces/demo/components/sh and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2010-12-01 05:55:48 -0500 (Wed, 01 Dec 2010)
New Revision: 20251
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/toolbar/
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/toolbar/ToolBarBean.java
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/arrow.png
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/copy.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/create_doc.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/create_folder.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/cut.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/delete.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/edit.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/filter.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/find.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/ico_new_group.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/ico_new_item.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/open.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/paste.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/redo.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/reload.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/repeat.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/save.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/save_all.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/save_as.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/undo.gif
trunk/examples/richfaces-showcase/src/main/webapp/images/icons/verify.gif
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/samples/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/samples/toolBar-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/samples/toolBarIcons-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/toolBar.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/toolBarIcons.xhtml
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/components/sh/SyntaxHighlighter.java
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
Log:
https://jira.jboss.org/browse/RF-9752
+SH correction. jQuery was missed in dependencies.
Modified: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/components/sh/SyntaxHighlighter.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/components/sh/SyntaxHighlighter.java 2010-12-01 10:36:16 UTC (rev 20250)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/components/sh/SyntaxHighlighter.java 2010-12-01 10:55:48 UTC (rev 20251)
@@ -17,6 +17,7 @@
@FacesComponent(value = "syntaxHighlighter")
@ResourceDependencies({ @ResourceDependency(library = "js", name = "shCore.js"),
+ @ResourceDependency(name = "jquery.js"),
@ResourceDependency(library = "css", name = "shCore.css"),
@ResourceDependency(library = "css", name = "shThemeDefault.css"),
@ResourceDependency(library = "js", name = "shBrushJScript.js"),
Added: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/toolbar/ToolBarBean.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/toolbar/ToolBarBean.java (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/toolbar/ToolBarBean.java 2010-12-01 10:55:48 UTC (rev 20251)
@@ -0,0 +1,30 @@
+package org.richfaces.demo.toolbar;
+
+import java.io.Serializable;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
+
+@ManagedBean
+@ViewScoped
+public class ToolBarBean implements Serializable{
+ private String groupSeparator;
+ private String groupItemSeparator;
+
+ public String getGroupItemSeparator() {
+ return groupItemSeparator;
+ }
+
+ public void setGroupItemSeparator(String groupItemSeparator) {
+ this.groupItemSeparator = groupItemSeparator;
+ }
+
+ public String getGroupSeparator() {
+ return groupSeparator;
+ }
+
+ public void setGroupSeparator(String groupSeparator) {
+ this.groupSeparator = groupSeparator;
+ }
+
+}
Modified: trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-01 10:36:16 UTC (rev 20250)
+++ trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-01 10:55:48 UTC (rev 20251)
@@ -298,7 +298,7 @@
<group>
<name>Trees</name>
<demos>
- <demo new="true">
+ <demo>
<id>tree</id>
<name>rich:tree</name>
<samples>
@@ -337,7 +337,7 @@
</sample>
</samples>
</demo>
- <demo new="true">
+ <demo>
<id>tabPanel</id>
<name>rich:tabPanel</name>
<samples>
@@ -358,7 +358,7 @@
</sample>
</samples>
</demo>
- <demo new="true">
+ <demo>
<id>collapsiblePanel</id>
<name>rich:collapsiblePanel</name>
<samples>
@@ -406,7 +406,7 @@
</sample>
</samples>
</demo>
- <demo new="true">
+ <demo>
<id>tooltip</id>
<name>rich:tooltip</name>
<samples>
@@ -418,19 +418,29 @@
</demo>
</demos>
</group>
- <!-- group>
+ <group>
<name>Menus</name>
<demos>
- <demo>
- <id>panelMenu</id>
- <name>rich:panelMenu</name>
+ <demo new="true">
+ <id>toolBar</id>
+ <name>rich:toolBar</name>
+ <samples>
+ <sample>
+ <id>toolBar</id>
+ <name>Simple Toolbar</name>
+ </sample>
+ <sample>
+ <id>toolBarIcons</id>
+ <name>Icons Customization</name>
+ </sample>
+ </samples>
</demo>
</demos>
- </group-->
+ </group>
<group>
<name>Inputs and Selects</name>
- <demos>
- <demo new="true">
+ <demos>
+ <demo>
<id>autocomplete</id>
<name>rich:autocomplete</name>
<samples>
@@ -438,13 +448,13 @@
<id>cachedAjax</id>
<name>Autocomplete in Cached Ajax mode</name>
</sample>
- <sample new="true">
+ <sample>
<id>clientFilter</id>
<name>Custom client filter</name>
</sample>
</samples>
</demo>
- <demo new="true">
+ <demo>
<id>calendar</id>
<name>rich:calendar</name>
<samples>
@@ -484,7 +494,7 @@
</sample>
</samples>
</demo>
- <demo new="true">
+ <demo>
<id>inplaceSelect</id>
<name>rich:inplaceSelect</name>
<samples>
@@ -494,7 +504,7 @@
</sample>
</samples>
</demo>
- <demo new="true">
+ <demo>
<id>select</id>
<name>rich:select</name>
<samples>
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/arrow.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/arrow.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/copy.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/copy.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/create_doc.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/create_doc.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/create_folder.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/create_folder.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/cut.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/cut.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/delete.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/delete.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/edit.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/edit.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/filter.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/filter.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/find.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/find.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/ico_new_group.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/ico_new_group.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/ico_new_item.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/ico_new_item.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/open.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/open.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/paste.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/paste.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/redo.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/redo.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/reload.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/reload.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/repeat.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/repeat.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/save.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/save.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/save_all.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/save_all.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/save_as.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/save_as.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/undo.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/undo.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/verify.gif
===================================================================
(Binary files differ)
Property changes on: trunk/examples/richfaces-showcase/src/main/webapp/images/icons/verify.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/samples/toolBar-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/samples/toolBar-sample.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/samples/toolBar-sample.xhtml 2010-12-01 10:55:48 UTC (rev 20251)
@@ -0,0 +1,46 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ 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:rich="http://richfaces.org/rich">
+ <style>
+.pic {
+ margin-right: 2px;
+}
+
+.barsearch {
+ height: 14px;
+ width: 100px;
+}
+
+.barsearchbutton {
+ border-width: 1px;
+ background-color: #{ a4jSkin.generalBackgroundColor
+}
+;
+}
+</style>
+
+ <rich:toolBar height="26" itemSeparator="grid">
+ <rich:toolBarGroup>
+ <h:graphicImage value="/images/icons/create_doc.gif" styleClass="pic" />
+ <h:graphicImage value="/images/icons/create_folder.gif"
+ styleClass="pic" />
+ <h:graphicImage value="/images/icons/copy.gif" styleClass="pic" />
+ </rich:toolBarGroup>
+ <rich:toolBarGroup>
+ <h:graphicImage value="/images/icons/save.gif" styleClass="pic" />
+ <h:graphicImage value="/images/icons/save_as.gif" styleClass="pic" />
+ <h:graphicImage value="/images/icons/save_all.gif" styleClass="pic" />
+ </rich:toolBarGroup>
+ <rich:toolBarGroup location="right">
+ <h:inputText styleClass="barsearch" />
+ <h:commandButton styleClass="barsearchbutton" onclick="return false;"
+ value="Search" />
+ </rich:toolBarGroup>
+ </rich:toolBar>
+
+
+</ui:composition>
\ No newline at end of file
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/samples/toolBarIcons-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/samples/toolBarIcons-sample.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/samples/toolBarIcons-sample.xhtml 2010-12-01 10:55:48 UTC (rev 20251)
@@ -0,0 +1,95 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ 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:rich="http://richfaces.org/rich">
+
+ <h:form>
+ <h:panelGrid columns="3" width="100%" cellpadding="0" cellspacing="0"
+ style="margin-bottom : 4px">
+ <rich:panel>
+ <h:panelGrid columns="8">
+ <h:outputText value="Group Separator:" />
+ <a4j:commandLink value="Line">
+ <a4j:param name="gs" value="line"
+ assignTo="#{toolBarBean.groupSeparator}" />
+ </a4j:commandLink>
+
+ <a4j:commandLink value="Grid">
+ <a4j:param name="gs" value="grid"
+ assignTo="#{toolBarBean.groupSeparator}" />
+ </a4j:commandLink>
+
+ <a4j:commandLink value="Disc">
+ <a4j:param name="gs" value="disc"
+ assignTo="#{toolBarBean.groupSeparator}" />
+ </a4j:commandLink>
+
+ <a4j:commandLink value="Square">
+ <a4j:param name="gs" value="square"
+ assignTo="#{toolBarBean.groupSeparator}" />
+ </a4j:commandLink>
+
+ <a4j:commandLink value="None">
+ <a4j:param name="gs" value="none"
+ assignTo="#{toolBarBean.groupSeparator}" />
+ </a4j:commandLink>
+ </h:panelGrid>
+ </rich:panel>
+ <h:panelGroup style="padding-left : 4px">
+ <br />
+ </h:panelGroup>
+ <rich:panel bodyClass="rich-laguna-panel-no-header">
+ <h:panelGrid columns="8">
+ <h:outputText value="Group Item Separator:" />
+ <a4j:commandLink value="Line">
+ <a4j:param name="gs" value="line"
+ assignTo="#{toolBarBean.groupItemSeparator}" />
+ </a4j:commandLink>
+
+ <a4j:commandLink value="Grid">
+ <a4j:param name="gs" value="grid"
+ assignTo="#{toolBarBean.groupItemSeparator}" />
+ </a4j:commandLink>
+
+ <a4j:commandLink value="Disc">
+ <a4j:param name="gs" value="disc"
+ assignTo="#{toolBarBean.groupItemSeparator}" />
+ </a4j:commandLink>
+
+ <a4j:commandLink value="Square">
+ <a4j:param name="gs" value="square"
+ assignTo="#{toolBarBean.groupItemSeparator}" />
+ </a4j:commandLink>
+
+ <a4j:commandLink value="None">
+ <a4j:param name="gs" value="none"
+ assignTo="#{toolBarBean.groupItemSeparator}" />
+ </a4j:commandLink>
+ </h:panelGrid>
+ </rich:panel>
+ </h:panelGrid>
+ </h:form>
+ <a4j:outputPanel ajaxRendered="true">
+ <rich:toolBar id="bar" height="30"
+ itemSeparator="#{toolBarBean.groupSeparator}">
+ <rich:toolBarGroup itemSeparator="#{toolBarBean.groupItemSeparator}">
+ <h:outputText value="Group1.1"></h:outputText>
+ <h:outputText value="Group1.2"></h:outputText>
+ <h:outputText value="Group1.3"></h:outputText>
+ </rich:toolBarGroup>
+ <rich:toolBarGroup itemSeparator="#{toolBarBean.groupItemSeparator}">
+ <h:outputText value="Group2.1"></h:outputText>
+ <h:outputText value="Group2.2"></h:outputText>
+ </rich:toolBarGroup>
+ <rich:toolBarGroup location="right"
+ itemSeparator="#{toolBarBean.groupItemSeparator}">
+ <h:outputText value="Group3.1"></h:outputText>
+ <h:outputText value="Group3.2"></h:outputText>
+ </rich:toolBarGroup>
+ </rich:toolBar>
+ </a4j:outputPanel>
+
+</ui:composition>
\ No newline at end of file
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/toolBar.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/toolBar.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/toolBar.xhtml 2010-12-01 10:55:48 UTC (rev 20251)
@@ -0,0 +1,29 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition>
+ <p><b>Toolbar </b>is a horizontal-oriented panel that can be used in
+ different ways: for top level menu, for information panel and so on. To
+ create top level menu - just use <b>dropDownMenu </b>or <b>menuItem</b>'s as child
+ components.</p>
+ <p>Items on the toolbar can be grouped with ability to define a
+ separator between different groups and between a member of the same
+ group. The "<b>location</b>" attribute set to "<b>right</b>" put a group to the right
+ side of the panel.</p>
+
+ <p>The following example shows how the simple toolbar might look
+ like:</p>
+
+ <ui:include src="#{demoNavigator.sampleIncludeURI}" />
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}" />
+ <ui:param name="sourceType" value="xhtml" />
+ <ui:param name="openLabel" value="View Source" />
+ <ui:param name="hideLabel" value="Hide Source" />
+ </ui:include>
+
+</ui:composition>
+</html>
\ No newline at end of file
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/toolBarIcons.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/toolBarIcons.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/toolBar/toolBarIcons.xhtml 2010-12-01 10:55:48 UTC (rev 20251)
@@ -0,0 +1,20 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition>
+ <p>There you could check how the default separators could be used:</p>
+
+ <ui:include src="#{demoNavigator.sampleIncludeURI}" />
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}" />
+ <ui:param name="sourceType" value="xhtml" />
+ <ui:param name="openLabel" value="View Source" />
+ <ui:param name="hideLabel" value="Hide Source" />
+ </ui:include>
+ <p>Separators could be customized using URI to custom icons in
+ <b>itemSeparator</b> attribute</p>
+</ui:composition>
+</html>
\ No newline at end of file
14 years
JBoss Rich Faces SVN: r20250 - trunk/examples/output-demo/src/main/webapp/examples.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-12-01 05:36:16 -0500 (Wed, 01 Dec 2010)
New Revision: 20250
Modified:
trunk/examples/output-demo/src/main/webapp/examples/toolbar.xhtml
Log:
fix demo
Modified: trunk/examples/output-demo/src/main/webapp/examples/toolbar.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/toolbar.xhtml 2010-12-01 09:01:59 UTC (rev 20249)
+++ trunk/examples/output-demo/src/main/webapp/examples/toolbar.xhtml 2010-12-01 10:36:16 UTC (rev 20250)
@@ -7,10 +7,7 @@
<h:head>
<title>ToolBar sample</title>
<style>
- .pic {
- margin-bottom: -4px;
- margin-right: 2px;
- }
+
</style>
</h:head>
<h:body>
@@ -19,63 +16,63 @@
||
</f:facet>
<tb:toolBarGroup itemSeparator="line" onitemclick="22">
- <h:graphicImage value="/images/icons/create_doc.gif" styleClass="pic"/>
- <a href="sdsd">link 1</a> Text
- <a href="sdsd 2">link 2</a>
- <h:graphicImage value="/images/icons/create_folder.gif" styleClass="pic" onclick="q1"/>
- <h:graphicImage value="/images/icons/copy.gif" styleClass="pic"/>
- <a href="sdsd">link 3</a> Text
- <a href="sdsd 2">link 4</a>
+ <h:graphicImage value="/images/icons/create_doc.gif"/>
+ <a href="#">link 1</a> Text
+ <a href="#">link 2</a>
+ <h:graphicImage value="/images/icons/create_folder.gif" onclick="q1"/>
+ <h:graphicImage value="/images/icons/copy.gif"/>
+ <a href="#">link 3</a> Text
+ <a href="#">link 4</a>
</tb:toolBarGroup>
<tb:toolBarGroup itemSeparator="none">
- <h:graphicImage value="/images/icons/save.gif" styleClass="pic" onclick="q2"/>
- <h:graphicImage value="/images/icons/save.gif" styleClass="pic" onclick="q2"/>
- <h:graphicImage value="/images/icons/save.gif" styleClass="pic" onclick="q2"/>
- <h:graphicImage value="/images/icons/save.gif" styleClass="pic" onclick="q2"/>
+ <h:graphicImage value="/images/icons/save.gif" onclick="q2"/>
+ <h:graphicImage value="/images/icons/save.gif" onclick="q2"/>
+ <h:graphicImage value="/images/icons/save.gif" onclick="q2"/>
+ <h:graphicImage value="/images/icons/save.gif" onclick="q2"/>
</tb:toolBarGroup>
<tb:toolBarGroup itemSeparator="line">
- <h:graphicImage value="/images/icons/save.gif" styleClass="pic" onclick="q2"/>
- <h:graphicImage value="/images/icons/save.gif" styleClass="pic" onclick="q2"/>
+ <h:graphicImage value="/images/icons/save.gif" onclick="q2"/>
+ <h:graphicImage value="/images/icons/save.gif" onclick="q2"/>
</tb:toolBarGroup>
<tb:toolBarGroup location="right" itemSeparator="square">
- <h:graphicImage value="/images/icons/find.gif" styleClass="pic"/>
- <h:graphicImage value="/images/icons/filter.gif" styleClass="pic"/>
+ <h:graphicImage value="/images/icons/find.gif" />
+ <h:graphicImage value="/images/icons/filter.gif" />
</tb:toolBarGroup>
</tb:toolBar>
<br/>
<tb:toolBar itemSeparator="grid">
<tb:toolBarGroup itemSeparator="line">
- <h:graphicImage value="/images/icons/create_doc.gif" styleClass="pic"/>
- <h:graphicImage value="/images/icons/create_folder.gif" styleClass="pic"/>
- <h:graphicImage value="/images/icons/copy.gif" styleClass="pic"/>
+ <h:graphicImage value="/images/icons/create_doc.gif"/>
+ <h:graphicImage value="/images/icons/create_folder.gif"/>
+ <h:graphicImage value="/images/icons/copy.gif"/>
</tb:toolBarGroup>
<tb:toolBarGroup itemSeparator="disc">
- <h:graphicImage value="/images/icons/save.gif" styleClass="pic"/>
- <h:graphicImage value="/images/icons/save_as.gif" styleClass="pic"/>
- <h:graphicImage value="/images/icons/save_all.gif" styleClass="pic"/>
+ <h:graphicImage value="/images/icons/save.gif"/>
+ <h:graphicImage value="/images/icons/save_as.gif"/>
+ <h:graphicImage value="/images/icons/save_all.gif"/>
</tb:toolBarGroup>
<tb:toolBarGroup location="right" itemSeparator="square">
- <h:graphicImage value="/images/icons/find.gif" styleClass="pic"/>
- <h:graphicImage value="/images/icons/filter.gif" styleClass="pic"/>
+ <h:graphicImage value="/images/icons/find.gif"/>
+ <h:graphicImage value="/images/icons/filter.gif"/>
</tb:toolBarGroup>
</tb:toolBar>
<br/>
<tb:toolBar height="26" itemSeparator="grid">
<tb:toolBarGroup itemSeparator="line">
- <h:graphicImage value="/images/icons/create_doc.gif" styleClass="pic"/>
- <h:graphicImage value="/images/icons/create_folder.gif" styleClass="pic"/>
- <h:graphicImage value="/images/icons/copy.gif" styleClass="pic"/>
+ <h:graphicImage value="/images/icons/create_doc.gif"/>
+ <h:graphicImage value="/images/icons/create_folder.gif"/>
+ <h:graphicImage value="/images/icons/copy.gif"/>
</tb:toolBarGroup>
<tb:toolBarGroup itemSeparator="disc">
- <h:graphicImage value="/images/icons/save.gif" styleClass="pic"/>
- <h:graphicImage value="/images/icons/save_as.gif" styleClass="pic"/>
- <h:graphicImage value="/images/icons/save_all.gif" styleClass="pic"/>
+ <h:graphicImage value="/images/icons/save.gif"/>
+ <h:graphicImage value="/images/icons/save_as.gif"/>
+ <h:graphicImage value="/images/icons/save_all.gif"/>
</tb:toolBarGroup>
<tb:toolBarGroup location="right" itemSeparator="square">
- <h:graphicImage value="/images/icons/find.gif" styleClass="pic"/>
- <h:graphicImage value="/images/icons/filter.gif" styleClass="pic"/>
+ <h:graphicImage value="/images/icons/find.gif"/>
+ <h:graphicImage value="/images/icons/filter.gif"/>
</tb:toolBarGroup>
</tb:toolBar>
</h:body>
14 years
JBoss Rich Faces SVN: r20249 - modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-12-01 04:01:59 -0500 (Wed, 01 Dec 2010)
New Revision: 20249
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichDataTableBean.java
Log:
* unnecessary imports removed
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichDataTableBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichDataTableBean.java 2010-12-01 00:51:49 UTC (rev 20248)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichDataTableBean.java 2010-12-01 09:01:59 UTC (rev 20249)
@@ -26,7 +26,6 @@
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import java.util.Map.Entry;
import javax.annotation.PostConstruct;
@@ -36,7 +35,6 @@
import org.ajax4jsf.model.DataComponentState;
import org.richfaces.component.UIDataTable;
-import org.richfaces.event.SortingEvent;
import org.richfaces.model.Filter;
import org.richfaces.tests.metamer.Attributes;
import org.richfaces.tests.metamer.model.Employee;
14 years
JBoss Rich Faces SVN: r20248 - trunk/ui/output/ui/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-30 19:51:49 -0500 (Tue, 30 Nov 2010)
New Revision: 20248
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractProgressBar.java
Log:
ProgressBar: added missing default values for 'minValue' & 'maxValue' attributes
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractProgressBar.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractProgressBar.java 2010-12-01 00:41:27 UTC (rev 20247)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractProgressBar.java 2010-12-01 00:51:49 UTC (rev 20248)
@@ -126,10 +126,10 @@
@Attribute(defaultValue = "SwitchType.DEFAULT")
public abstract SwitchType getMode();
- @Attribute
+ @Attribute(defaultValue = "100")
public abstract int getMaxValue();
- @Attribute
+ @Attribute(defaultValue = "0")
public abstract int getMinValue();
@Attribute
14 years
JBoss Rich Faces SVN: r20247 - branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-11-30 19:41:27 -0500 (Tue, 30 Nov 2010)
New Revision: 20247
Modified:
branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource/AjaxResourceLibrary.java
Log:
CODING IN PROGRESS - issue RF-9612: Create JSF 2.0 resource loading extension to dynamically add scripts and its dependencies.
https://jira.jboss.org/browse/RF-9612
Modified: branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource/AjaxResourceLibrary.java
===================================================================
--- branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource/AjaxResourceLibrary.java 2010-12-01 00:40:36 UTC (rev 20246)
+++ branches/RF-8742-1/ui/common/ui/src/main/java/org/richfaces/resource/AjaxResourceLibrary.java 2010-12-01 00:41:27 UTC (rev 20247)
@@ -21,15 +21,13 @@
*/
package org.richfaces.resource;
-import static org.richfaces.application.configuration.ConfigurationServiceHelper.getBooleanConfigurationValue;
+import static org.richfaces.application.configuration.ConfigurationServiceHelper.*;
import javax.faces.context.FacesContext;
-
import org.richfaces.application.CommonComponentsConfiguration;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ObjectArrays;
/**
* @author Nick Belaevski
14 years
JBoss Rich Faces SVN: r20246 - in branches/RF-8742-1/ui/validator: ui/src/main/java/org/richfaces/application and 9 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-11-30 19:40:36 -0500 (Tue, 30 Nov 2010)
New Revision: 20246
Added:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/FunctionDefWithDependencies.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/JavaScriptService.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptWithDependencies.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIResource.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIScripts.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/JavaScriptServiceImpl.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ScriptsRenderer.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/ValidatorTestBase.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/JavaScriptServiceTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/Script.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceGetOrCreateResourceTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererBuildScriptTest.java
Removed:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIValidatorScriptCollectionTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UITransient.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java
branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/faces-config.xml
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/AjaxValidationTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIViewResourceTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorTestBase.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
Log:
CODING IN PROGRESS - issue RF-9612: Create JSF 2.0 resource loading extension to dynamically add scripts and its dependencies.
https://jira.jboss.org/browse/RF-9612
Added: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/FunctionDefWithDependencies.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/FunctionDefWithDependencies.java (rev 0)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/FunctionDefWithDependencies.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -0,0 +1,35 @@
+/*
+ * $Id$
+ * 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.javascript;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface FunctionDefWithDependencies extends ScriptWithDependencies {
+
+ String getName();
+
+}
Property changes on: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/FunctionDefWithDependencies.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/JavaScriptService.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/JavaScriptService.java (rev 0)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/JavaScriptService.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -0,0 +1,56 @@
+/*
+ * $Id$
+ * 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.javascript;
+
+import javax.faces.context.FacesContext;
+
+
+/**
+ * <p class="changed_added_4_0">
+ * This service stores JavaScript objects for deffered rendering, as described on
+ * http://community.jboss.org/wiki/RichFacesJavaScripthandling
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface JavaScriptService {
+
+ /**
+ * <p class="changed_added_4_0">Adds new script to render at the end of page. Is the same script already set to render ( lookup by equals() method ), no new object added.</p>
+ * @param facesContext TODO
+ * @param script
+ * @return actual object that will be rendered at the end of page.
+ */
+ <S> S addScript(FacesContext facesContext, S script);
+
+ /**
+ * <p class="changed_added_4_0">This method adds script that has to be executed in page.onready event listener, as required by jQuery components.</p>
+ * @param facesContext TODO
+ * @param script
+ * @param <S>
+ * @return
+ */
+ <S> S addPageReadyScript(FacesContext facesContext, S script);
+}
Property changes on: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/JavaScriptService.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -1,14 +0,0 @@
-package org.richfaces.javascript;
-
-import org.ajax4jsf.javascript.ScriptString;
-import org.richfaces.resource.ResourceLibrary;
-
-/**
- * This interface describes JavaScript object with optional dependent resources.
- * @author asmirnov
- *
- */
-public interface LibraryScriptString extends ResourceLibrary, ScriptString {
-
-
-}
\ No newline at end of file
Copied: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptWithDependencies.java (from rev 20241, branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java)
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptWithDependencies.java (rev 0)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptWithDependencies.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -0,0 +1,14 @@
+package org.richfaces.javascript;
+
+import org.ajax4jsf.javascript.ScriptString;
+import org.richfaces.resource.ResourceLibrary;
+
+/**
+ * This interface describes JavaScript object with optional dependent resources.
+ * @author asmirnov
+ *
+ */
+public interface ScriptWithDependencies extends ResourceLibrary, ScriptString {
+
+
+}
\ No newline at end of file
Property changes on: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptWithDependencies.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -31,6 +31,8 @@
import org.richfaces.javascript.ClientScriptService;
import org.richfaces.javascript.ClientScriptServiceImpl;
import org.richfaces.javascript.ClientServiceConfigParser;
+import org.richfaces.javascript.JavaScriptService;
+import org.richfaces.javascript.JavaScriptServiceImpl;
import org.richfaces.javascript.LibraryFunction;
import org.richfaces.validator.BeanValidator;
import org.richfaces.validator.BeanValidatorFactory;
@@ -64,6 +66,7 @@
configureBeanValidators(factory);
factory.setInstance(FacesConverterService.class, new ConverterServiceImpl());
factory.setInstance(FacesValidatorService.class, new FacesValidatorServiceImpl());
+ factory.setInstance(JavaScriptService.class, new JavaScriptServiceImpl());
ClientScriptServiceImpl clientScriptService = createClientScriptService();
factory.setInstance(ClientScriptService.class, clientScriptService);
}
Added: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIResource.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIResource.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIResource.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -0,0 +1,125 @@
+/*
+ * $Id$
+ * 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.component;
+
+import javax.faces.application.ResourceHandler;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
+import javax.faces.context.FacesContext;
+import javax.faces.render.Renderer;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class UIResource extends UITransient {
+
+ private final String name;
+ private final String library;
+
+ public UIResource(UIComponent parent,String name, String library) {
+ this.name = name;
+ this.library = library;
+ setParent(parent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.UITransient#hasAttribute(java.lang.Object)
+ */
+ @Override
+ protected boolean hasAttribute(Object key) {
+ if("name".equals(key)){
+ return null != getName();
+ } else if ("library".equals(key)) {
+ return null != getLibrary();
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.UITransient#setAttribute(java.lang.String, java.lang.Object)
+ */
+ @Override
+ protected Object setAttribute(String key, Object value) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.UITransient#getAttribute(java.lang.Object)
+ */
+ @Override
+ protected Object getAttribute(Object key) {
+ if("name".equals(key)){
+ return getName();
+ } else if ("library".equals(key)) {
+ return getLibrary();
+ }
+ return null;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the library
+ */
+ public String getLibrary() {
+ return library;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ @Override
+ public String getFamily() {
+ return UIOutput.COMPONENT_FAMILY;
+ }
+
+ @Override
+ public String getRendererType() {
+ return getRendererType(getFacesContext());
+ }
+
+ public String getRendererType(FacesContext context) {
+ ResourceHandler resourceHandler = context.getApplication().getResourceHandler();
+ return resourceHandler.getRendererTypeForResourceName(getName());
+ }
+
+ @Override
+ protected Renderer getRenderer(FacesContext context) {
+ String rendererType = getRendererType(context);
+ Renderer result = null;
+ if (rendererType != null) {
+ result = context.getRenderKit().getRenderer(getFamily(), rendererType);
+ }
+ return result;
+ }
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIScripts.java (from rev 20241, branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java)
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIScripts.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIScripts.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -0,0 +1,110 @@
+/*
+ * $Id$
+ * 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.component;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+
+import org.richfaces.renderkit.html.ComponentValidatorScript;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0">
+ * This component user to render Client Validator scripts. Any ClientValidatorBehavior that requires additional scripts
+ * should put them to this component, associated with "form" target in view resources.
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class UIScripts extends UITransient {
+
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Scripts";
+
+ private final List<Object> scripts = Lists.newArrayList();
+
+ private final List<Object> pageReadyScripts = Lists.newArrayList();
+
+ private String target = "form";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.Script";
+
+ public Collection<Object> getScripts() {
+ return scripts;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the pageReadyScripts
+ */
+ public Collection<Object> getPageReadyScripts() {
+ return this.pageReadyScripts;
+ }
+
+
+ @Override
+ public String getFamily() {
+ return UIScripts.COMPONENT_FAMILY;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ @Override
+ protected boolean hasAttribute(Object key) {
+ return "target".equals(key);
+ }
+
+ @Override
+ protected Object setAttribute(String key, Object value) {
+ if ("target".equals(key)) {
+ String oldTarget = getTarget();
+ setTarget((String) value);
+ return oldTarget;
+ }
+ return null;
+ }
+
+ @Override
+ protected Object getAttribute(Object key) {
+ if("target".equals(key)){
+ return getTarget();
+ }
+ return null;
+ }
+
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIScripts.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UITransient.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UITransient.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UITransient.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -20,7 +20,7 @@
import javax.faces.event.FacesListener;
import javax.faces.render.Renderer;
-import org.richfaces.renderkit.html.ValidatorScriptRenderer;
+import org.richfaces.renderkit.html.ScriptsRenderer;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -28,13 +28,10 @@
public abstract class UITransient extends UIComponent {
- public static final String COMPONENT_FAMILY = "org.richfaces.Script";
private String id;
private UIComponent parent;
- private String target = "form";
-
private final Map<String, Object> attributesMap = new AttributesMap();
@@ -45,19 +42,6 @@
}
- public void setTarget(String target) {
- this.target = target;
- }
-
- public String getTarget() {
- return target;
- }
-
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-
public Object saveState(FacesContext context) {
// This is transient component
return null;
@@ -81,11 +65,13 @@
return attributesMap;
}
+ @SuppressWarnings("deprecation")
@Override
public ValueBinding getValueBinding(String name) {
return null;
}
+ @SuppressWarnings("deprecation")
@Override
public void setValueBinding(String name, ValueBinding binding) {
// do nothing
@@ -110,7 +96,7 @@
// if the clientId is not yet set
if (this.clientId == null) {
- UIComponent namingContainerAncestor = this.getNamingContainerAncestor();
+ UIComponent namingContainerAncestor = this.getNamingContainer();
String parentId = null;
// give the parent the opportunity to first
@@ -146,17 +132,6 @@
return this.clientId;
}
- private UIComponent getNamingContainerAncestor() {
- UIComponent namingContainer = this.getParent();
- while (namingContainer != null) {
- if (namingContainer instanceof NamingContainer) {
- return namingContainer;
- }
- namingContainer = namingContainer.getParent();
- }
- return null;
- }
-
@Override
public String getId() {
return this.id;
@@ -165,7 +140,7 @@
@Override
public void setId(String id) {
this.id = id;
-
+ this.clientId = null;
}
@Override
@@ -190,12 +165,12 @@
@Override
public String getRendererType() {
- return ValidatorScriptRenderer.RENDERER_TYPE;
+ return ScriptsRenderer.RENDERER_TYPE;
}
@Override
public void setRendererType(String rendererType) {
- // TODO Auto-generated method stub
+ // do nothing
}
@@ -247,14 +222,18 @@
@Override
public void encodeBegin(FacesContext context) throws IOException {
- // TODO Auto-generated method stub
-
+ Renderer renderer = getRenderer(context);
+ if(null != renderer){
+ renderer.encodeBegin(context, this);
+ }
}
@Override
public void encodeChildren(FacesContext context) throws IOException {
- // TODO Auto-generated method stub
-
+ Renderer renderer = getRenderer(context);
+ if(null != renderer){
+ renderer.encodeChildren(context, this);
+ }
}
@Override
@@ -331,6 +310,7 @@
}
final class AttributesMap implements Map<String, Object> {
+
public void clear() {
// do nothing
@@ -338,7 +318,7 @@
public boolean containsKey(Object key) {
- return "target".equals(key)||"id".equals(key)||"clientId".equals(key);
+ return "target".equals(key)||"id".equals(key)||"clientId".equals(key)||hasAttribute(key);
}
public boolean containsValue(Object value) {
@@ -350,14 +330,13 @@
}
public Object get(Object key) {
- if("target".equals(key)){
- return getTarget();
- } else if ("id".equals(key)) {
+ if ("id".equals(key)) {
return getId();
} else if ("clientId".equals(key)) {
return getClientId();
+ } else {
+ return getAttribute(key);
}
- return null;
}
public boolean isEmpty() {
@@ -369,16 +348,13 @@
}
public Object put(String key, Object value) {
- if("target".equals(key)){
- String target = getTarget();
- setTarget((String) value);
- return target;
- } else if ("id".equals(key)) {
+ if ("id".equals(key)) {
String id = getId();
setId((String) value);
return id;
+ } else {
+ return setAttribute(key, value);
}
- return null;
}
public void putAll(Map<? extends String, ? extends Object> m) {
@@ -395,8 +371,16 @@
}
public Collection<Object> values() {
- return ImmutableList.<Object>of(getTarget(),getId(),getClientId());
+ return ImmutableList.<Object>of(getId(),getClientId());
}
}
+ protected abstract boolean hasAttribute(Object key);
+
+
+ protected abstract Object setAttribute(String key, Object value);
+
+
+ protected abstract Object getAttribute(Object key);
+
}
\ No newline at end of file
Deleted: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -1,70 +0,0 @@
-/*
- * $Id$
- * 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.component;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-
-import org.richfaces.renderkit.html.ComponentValidatorScript;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-
-/**
- * <p class="changed_added_4_0">
- * This component user to render Client Validator scripts. Any ClientValidatorBehavior that requires additional scripts
- * should put them to this component, associated with "form" target in view resources.
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public class UIValidatorScript extends UITransient {
-
-
- public static final String COMPONENT_TYPE = "org.richfaces.ValidatorScript";
-
- final List<ComponentValidatorScript> scripts = Lists.newArrayList();
-
- public Collection<ComponentValidatorScript> getScripts() {
- return scripts;
- }
-
- public ComponentValidatorScript addOrFindScript(ComponentValidatorScript validatorScript) {
- // TODO optimize
- for (ComponentValidatorScript script : this.scripts) {
- if (script.equals(validatorScript)) {
- return script;
- }
- }
- scripts.add(validatorScript);
- return validatorScript;
- }
-
-}
Added: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/JavaScriptServiceImpl.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/JavaScriptServiceImpl.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/JavaScriptServiceImpl.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -0,0 +1,112 @@
+/*
+ * $Id$
+ * 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.javascript;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.UIScripts;
+import org.richfaces.renderkit.html.NoSuchComponentException;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class JavaScriptServiceImpl implements JavaScriptService {
+
+ /* (non-Javadoc)
+ * @see org.richfaces.javascript.JavaScriptService#addScript(org.ajax4jsf.javascript.ScriptString)
+ */
+ public <S> S addScript(FacesContext facesContext, S script) {
+ UIScripts scriptResource = getOrCreateScriptResource(facesContext);
+
+ return addOrFind(scriptResource.getScripts(),script);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.javascript.JavaScriptService#addPageReadyScript(org.ajax4jsf.javascript.ScriptString)
+ */
+ public <S> S addPageReadyScript(FacesContext facesContext, S script) {
+ UIScripts scriptResource = getOrCreateScriptResource(facesContext);
+
+ return addOrFind(scriptResource.getPageReadyScripts(),script);
+ }
+
+
+ @SuppressWarnings("unchecked")
+ private <S> S addOrFind(Collection<Object> collection,S script){
+ for (Object object : collection) {
+ if(script.equals(object)){
+ return (S) object;
+ }
+ }
+ collection.add(script);
+ return script;
+ }
+ /**
+ * <p class="changed_added_4_0">
+ * This method looks for {@link UIScripts} component in view resource. If such resource not found, it
+ * creates a new instance and stores it in {@link UIViewRoot} view resource with default target.
+ * </p>
+ *
+ * @param facesContext
+ * @return
+ */
+ UIScripts getOrCreateScriptResource(FacesContext facesContext) {
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ if (null == viewRoot) {
+ throw new FacesException("View is not created");
+ }
+ List<UIComponent> componentResources = viewRoot.getComponentResources(facesContext, "form");
+ try {
+ return findScriptResource(componentResources);
+ } catch (NoSuchComponentException e) {
+ componentResources = viewRoot.getComponentResources(facesContext, "body");
+ try {
+ return findScriptResource(componentResources);
+ } catch (NoSuchComponentException e1) {
+ UIScripts component =
+ (UIScripts) facesContext.getApplication().createComponent(UIScripts.COMPONENT_TYPE);
+ viewRoot.addComponentResource(facesContext, component);
+ return component;
+ }
+ }
+ }
+ private UIScripts findScriptResource(List<UIComponent> componentResources) throws NoSuchComponentException {
+ for (UIComponent uiComponent : componentResources) {
+ if (uiComponent instanceof UIScripts) {
+ UIScripts script = (UIScripts) uiComponent;
+ return script;
+ }
+ }
+ throw new NoSuchComponentException();
+ }
+
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/JavaScriptServiceImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -17,7 +17,7 @@
}
- public Iterable<ResourceKey> getResources(FacesContext context) {
+ public Iterable<ResourceKey> getResources() {
return Collections.emptySet();
}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -2,7 +2,7 @@
import java.util.Collection;
-import org.richfaces.javascript.LibraryScriptString;
+import org.richfaces.javascript.ScriptWithDependencies;
public class ClientAndAjaxScript extends ClientOnlyScript{
@@ -11,8 +11,8 @@
final String ajaxScript;
- public ClientAndAjaxScript(LibraryScriptString clientSideConverterScript,
- Collection<? extends LibraryScriptString> validatorScripts, String ajaxScript) {
+ public ClientAndAjaxScript(ScriptWithDependencies clientSideConverterScript,
+ Collection<? extends ScriptWithDependencies> validatorScripts, String ajaxScript) {
super(clientSideConverterScript,validatorScripts);
this.ajaxScript = ajaxScript;
}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -3,9 +3,7 @@
import java.util.Collection;
import java.util.LinkedHashSet;
-import javax.faces.context.FacesContext;
-
-import org.richfaces.javascript.LibraryScriptString;
+import org.richfaces.javascript.ScriptWithDependencies;
import org.richfaces.resource.ResourceKey;
import com.google.common.collect.Iterables;
@@ -13,11 +11,11 @@
public class ClientOnlyScript extends ValidatorScriptBase{
- protected final LibraryScriptString converter;
- protected final Collection<? extends LibraryScriptString> validators;
+ protected final ScriptWithDependencies converter;
+ protected final Collection<? extends ScriptWithDependencies> validators;
- public ClientOnlyScript(LibraryScriptString clientSideConverterScript,
- Collection<? extends LibraryScriptString> validatorScripts) {
+ public ClientOnlyScript(ScriptWithDependencies clientSideConverterScript,
+ Collection<? extends ScriptWithDependencies> validatorScripts) {
super();
if(null==clientSideConverterScript){
this.converter = NULL_CONVERTER_SCRIPT;
@@ -28,11 +26,11 @@
}
- public Iterable<ResourceKey> getResources(FacesContext context) {
+ public Iterable<ResourceKey> getResources() {
// TODO - make immutable.
LinkedHashSet<ResourceKey> resources = Sets.newLinkedHashSet();
Iterables.addAll(resources,converter.getResources());
- for (LibraryScriptString scriptString : validators) {
+ for (ScriptWithDependencies scriptString : validators) {
Iterables.addAll(resources,scriptString.getResources());
}
return resources;
@@ -52,7 +50,7 @@
converter.appendScriptToStringBuilder(body);
body.append(EOL);
// call validators
- for (LibraryScriptString validatorScript : validators) {
+ for (ScriptWithDependencies validatorScript : validators) {
validatorScript.appendScriptToStringBuilder(body);
body.append(EOL);
}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -21,12 +21,13 @@
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
import org.richfaces.application.ServiceTracker;
-import org.richfaces.component.UIValidatorScript;
+import org.richfaces.component.UIScripts;
import org.richfaces.component.behavior.ClientValidatorBehavior;
import org.richfaces.component.behavior.ConverterNotFoundException;
import org.richfaces.javascript.ClientScriptService;
+import org.richfaces.javascript.JavaScriptService;
import org.richfaces.javascript.LibraryFunction;
-import org.richfaces.javascript.LibraryScriptString;
+import org.richfaces.javascript.ScriptWithDependencies;
import org.richfaces.javascript.ScriptNotFoundException;
import org.richfaces.validator.ConverterDescriptor;
import org.richfaces.validator.FacesObjectDescriptor;
@@ -135,53 +136,15 @@
ComponentValidatorScript validatorScript = createValidatorScript(behaviorContext, behavior);
if (null != validatorScript) {
FacesContext facesContext = behaviorContext.getFacesContext();
- UIValidatorScript scriptResource = getOrCreateValidatorScriptResource(facesContext);
- validatorScript = scriptResource.addOrFindScript(validatorScript);
+ JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class);
+ validatorScript = javaScriptService.addScript(facesContext, validatorScript);
return validatorScript.createCallScript(behaviorContext.getComponent().getClientId(facesContext),behaviorContext.getSourceId());
} else {
return null;
}
}
- /**
- * <p class="changed_added_4_0">
- * This method looks for {@link UIValidatorScript} component in view resource. If such resource not found, it
- * creates a new instance and stores it in {@link UIViewRoot} view resource with default target.
- * </p>
- *
- * @param facesContext
- * @return
- */
- UIValidatorScript getOrCreateValidatorScriptResource(FacesContext facesContext) {
- UIViewRoot viewRoot = facesContext.getViewRoot();
- if (null == viewRoot) {
- throw new FacesException("View is not created");
- }
- List<UIComponent> componentResources = viewRoot.getComponentResources(facesContext, "form");
- try {
- return findScriptResource(componentResources);
- } catch (NoSuchComponentException e) {
- componentResources = viewRoot.getComponentResources(facesContext, "body");
- try {
- return findScriptResource(componentResources);
- } catch (NoSuchComponentException e1) {
- UIValidatorScript component =
- (UIValidatorScript) facesContext.getApplication().createComponent(UIValidatorScript.COMPONENT_TYPE);
- viewRoot.addComponentResource(facesContext, component);
- return component;
- }
- }
- }
- private UIValidatorScript findScriptResource(List<UIComponent> componentResources) throws NoSuchComponentException {
- for (UIComponent uiComponent : componentResources) {
- if (uiComponent instanceof UIValidatorScript) {
- UIValidatorScript script = (UIValidatorScript) uiComponent;
- return script;
- }
- }
- throw new NoSuchComponentException();
- }
ComponentValidatorScript createValidatorScript(ClientBehaviorContext behaviorContext,
ClientValidatorBehavior behavior) {
@@ -192,7 +155,7 @@
ConverterDescriptor converter = behavior.getConverter(behaviorContext);
if (null != converter) {
try {
- LibraryScriptString clientSideConverterScript =
+ ScriptWithDependencies clientSideConverterScript =
getClientSideConverterScript(behaviorContext.getFacesContext(), converter);
validatorScript = createValidatorScript(behaviorContext, behavior, validators, clientSideConverterScript);
} catch (ScriptNotFoundException e) {
@@ -221,8 +184,8 @@
private ValidatorScriptBase createValidatorScript(ClientBehaviorContext behaviorContext,
ClientValidatorBehavior behavior, Collection<ValidatorDescriptor> validators,
- LibraryScriptString clientSideConverterScript) {
- Collection<? extends LibraryScriptString> validatorScripts = getClientSideValidatorScript(behaviorContext.getFacesContext(), validators);
+ ScriptWithDependencies clientSideConverterScript) {
+ Collection<? extends ScriptWithDependencies> validatorScripts = getClientSideValidatorScript(behaviorContext.getFacesContext(), validators);
if (validatorScripts.isEmpty()) {
return new AjaxOnlyScript(createAjaxScript(behaviorContext, behavior));
} else if (validatorScripts.size() < validators.size()) {
@@ -270,14 +233,14 @@
* @return
* @throws ScriptNotFoundException
*/
- LibraryScriptString getClientSideConverterScript(FacesContext facesContext,
+ ScriptWithDependencies getClientSideConverterScript(FacesContext facesContext,
ConverterDescriptor converter) throws ScriptNotFoundException {
ClientScriptService clientScriptService =
ServiceTracker.getService(facesContext, ClientScriptService.class);
return createClientFunction(facesContext, converter, VALUE_LITERAL, clientScriptService);
}
- private LibraryScriptString createClientFunction(FacesContext facesContext, FacesObjectDescriptor descriptor,
+ private ScriptWithDependencies createClientFunction(FacesContext facesContext, FacesObjectDescriptor descriptor,
JSReference variable, ClientScriptService clientScriptService) throws ScriptNotFoundException {
LibraryFunction script = clientScriptService.getScript(facesContext, descriptor.getImplementationClass());
return new LibraryScriptFunction(script, variable, descriptor.getMessage(), descriptor.getAdditionalParameters());
@@ -293,11 +256,11 @@
* @return
* @throws ScriptNotFoundException
*/
- Collection<? extends LibraryScriptString> getClientSideValidatorScript(FacesContext facesContext,
+ Collection<? extends ScriptWithDependencies> getClientSideValidatorScript(FacesContext facesContext,
Collection<ValidatorDescriptor> validators) {
ClientScriptService clientScriptService =
ServiceTracker.getService(facesContext, ClientScriptService.class);
- List<LibraryScriptString> scripts = Lists.newArrayList();
+ List<ScriptWithDependencies> scripts = Lists.newArrayList();
for (FacesObjectDescriptor validator : validators) {
try {
scripts.add(createClientFunction(facesContext, validator, CONVERTED_VALUE_LITERAL, clientScriptService));
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -1,16 +1,10 @@
package org.richfaces.renderkit.html;
-import javax.faces.context.FacesContext;
+import org.richfaces.javascript.FunctionDefWithDependencies;
-import org.ajax4jsf.javascript.ScriptString;
-import org.richfaces.resource.ResourceKey;
-
-public interface ComponentValidatorScript extends ScriptString {
+public interface ComponentValidatorScript extends FunctionDefWithDependencies {
- String getName();
- Iterable<ResourceKey> getResources(FacesContext context);
-
/**
* <p class="changed_added_4_0">Creates JavasCript that calls validator function.</p>
* @param clientId
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -25,7 +25,7 @@
import org.ajax4jsf.javascript.JSFunction;
import org.richfaces.javascript.LibraryFunction;
-import org.richfaces.javascript.LibraryScriptString;
+import org.richfaces.javascript.ScriptWithDependencies;
import org.richfaces.resource.ResourceKey;
/**
@@ -36,7 +36,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public class LibraryScriptFunction extends JSFunction implements LibraryScriptString {
+public class LibraryScriptFunction extends JSFunction implements ScriptWithDependencies {
private final Iterable<ResourceKey> resources;
private final String name;
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -6,7 +6,7 @@
import java.util.Collections;
import org.ajax4jsf.javascript.JSLiteral;
-import org.richfaces.javascript.LibraryScriptString;
+import org.richfaces.javascript.ScriptWithDependencies;
import org.richfaces.resource.ResourceKey;
/**
@@ -15,7 +15,7 @@
* @author asmirnov
*
*/
-public class NullConverterScript extends JSLiteral implements LibraryScriptString {
+public class NullConverterScript extends JSLiteral implements ScriptWithDependencies {
private String name;
Copied: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ScriptsRenderer.java (from rev 20241, branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java)
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ScriptsRenderer.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ScriptsRenderer.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -0,0 +1,78 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.html;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.richfaces.component.UIResource;
+import org.richfaces.component.UIScripts;
+import org.richfaces.resource.ResourceKey;
+import org.richfaces.resource.ResourceLibrary;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ScriptsRenderer extends Renderer {
+
+ public static final String RENDERER_TYPE = "org.richfaces.renderer.ScriptsRenderer";
+ private static final String TEXT_JAVASCRIPT = "text/javascript";
+ private static final String SRC = "src";
+ private static final String TYPE = "type";
+ private static final String SCRIPT = "script";
+ private static final ResourceKey JQUERY = ResourceKey.create("jquery.js",null);
+
+ @Override
+ public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
+ UIScripts validatorScript = (UIScripts) component;
+ ResponseWriter responseWriter = context.getResponseWriter();
+ // TODO - change behavior for AJAX requests.
+ Collection<Object> scripts = validatorScript.getScripts();
+ encodeDependentResources(context, component, scripts);
+ Collection<Object> pageReadyScripts = validatorScript.getPageReadyScripts();
+ if(!pageReadyScripts.isEmpty()){
+ encodeResource(component, context, JQUERY);
+ encodeDependentResources(context, component, pageReadyScripts);
+ }
+ responseWriter.startElement(SCRIPT, null);
+ responseWriter.writeAttribute(TYPE, TEXT_JAVASCRIPT, null);
+ for (Object script : scripts) {
+ ScriptUtils.writeToStream(responseWriter, script);
+ responseWriter.writeText("\n",null);
+ }
+ if(!pageReadyScripts.isEmpty()){
+ responseWriter.writeText("$(document).ready(function() {\n",null);
+ for (Object script : pageReadyScripts) {
+ ScriptUtils.writeToStream(responseWriter, script);
+ responseWriter.writeText("\n",null);
+ }
+ responseWriter.writeText("});\n",null);
+ }
+ responseWriter.endElement(SCRIPT);
+ }
+
+ private void encodeDependentResources(FacesContext context, UIComponent component, Collection<Object> scripts) throws IOException {
+ for (Object script : scripts) {
+ if (script instanceof ResourceLibrary) {
+ ResourceLibrary library = (ResourceLibrary) script;
+ for( ResourceKey resource :library.getResources()){
+ encodeResource(component, context, resource);
+ }
+ }
+ }
+ }
+
+ private void encodeResource(UIComponent component,FacesContext context, ResourceKey resource) throws IOException {
+ UIResource resourceComponent = new UIResource(component,resource.getResourceName(),resource.getLibraryName());
+ resourceComponent.encodeAll(context);
+ }
+
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ScriptsRenderer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Deleted: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -1,74 +0,0 @@
-/**
- *
- */
-package org.richfaces.renderkit.html;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-
-import javax.faces.FacesException;
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.Renderer;
-
-import org.richfaces.component.UIValidatorScript;
-import org.richfaces.resource.ResourceKey;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-
-/**
- * @author asmirnov
- *
- */
-public class ValidatorScriptRenderer extends Renderer {
-
- public static final String RENDERER_TYPE = "org.richfaces.renderer.ValidatorScriptRenderer";
- private static final String TEXT_JAVASCRIPT = "text/javascript";
- private static final String SRC = "src";
- private static final String TYPE = "type";
- private static final String SCRIPT = "script";
-
- @Override
- public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
- UIValidatorScript validatorScript = (UIValidatorScript) component;
-
- Collection<ComponentValidatorScript> scripts = validatorScript.getScripts();
- // flatten all dependent resources.
- LinkedHashSet<ResourceKey> resources = Sets.newLinkedHashSet();
- for (ComponentValidatorScript script : scripts) {
- Iterables.addAll(resources, script.getResources(context));
- }
- // render dependencies
- for (ResourceKey resource : resources) {
- encodeResource(context, resource);
- }
- ResponseWriter responseWriter = context.getResponseWriter();
- responseWriter.startElement(SCRIPT, null);
- responseWriter.writeAttribute(TYPE, TEXT_JAVASCRIPT, null);
- for (ComponentValidatorScript componentValidatorScript : scripts) {
- responseWriter.writeText(componentValidatorScript.toScript(), null);
- responseWriter.write('\n');
- }
- responseWriter.endElement(SCRIPT);
- }
-
- private void encodeResource(FacesContext context, ResourceKey resource) throws IOException {
- ResourceHandler resourceHandler = context.getApplication().getResourceHandler();
- Resource jsfResource = resourceHandler.createResource(resource.getResourceName(), resource.getLibraryName());
- if (null != jsfResource) {
- ResponseWriter responseWriter = context.getResponseWriter();
- responseWriter.startElement(SCRIPT, null);
- responseWriter.writeAttribute(TYPE, TEXT_JAVASCRIPT, null);
- responseWriter.writeURIAttribute(SRC, jsfResource.getRequestPath(), null);
- responseWriter.endElement(SCRIPT);
- } else {
- throw new FacesException("Dependent resource "+resource.toString()+ " not found");
- }
- }
-
-}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/faces-config.xml
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/faces-config.xml 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/main/resources/META-INF/faces-config.xml 2010-12-01 00:40:36 UTC (rev 20246)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<component>
- <component-type>org.richfaces.ValidatorScript</component-type>
- <component-class>org.richfaces.component.UIValidatorScript</component-class>
+ <component-type>org.richfaces.Scripts</component-type>
+ <component-class>org.richfaces.component.UIScripts</component-class>
</component>
<behavior>
<behavior-id>org.richfaces.behavior.ClientValidator</behavior-id>
@@ -11,8 +11,8 @@
<render-kit>
<renderer>
<component-family>org.richfaces.Script</component-family>
- <renderer-type>org.richfaces.renderer.ValidatorScriptRenderer</renderer-type>
- <renderer-class>org.richfaces.renderkit.html.ValidatorScriptRenderer</renderer-class>
+ <renderer-type>org.richfaces.renderer.ScriptsRenderer</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.ScriptsRenderer</renderer-class>
</renderer>
<client-behavior-renderer>
<client-behavior-renderer-type>org.richfaces.ClientValidatorRenderer</client-behavior-renderer-type>
Added: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/ValidatorTestBase.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/ValidatorTestBase.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/ValidatorTestBase.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -0,0 +1,34 @@
+package org.richfaces;
+
+import javax.el.ValueExpression;
+
+import org.jboss.test.faces.mock.Environment;
+import org.jboss.test.faces.mock.Environment.Feature;
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockController;
+import org.jboss.test.faces.mock.MockFacesEnvironment;
+import org.jboss.test.faces.mock.Stub;
+import org.junit.After;
+import org.richfaces.application.ServicesFactory;
+
+public class ValidatorTestBase {
+
+ @Mock()
+ @Environment({ Feature.APPLICATION, Feature.RENDER_KIT, Feature.EL_CONTEXT })
+ protected MockFacesEnvironment environment;
+ protected MockController controller;
+ @Mock
+ protected ValueExpression expression;
+ @Stub
+ protected ServicesFactory factory;
+
+ public ValidatorTestBase() {
+ super();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ controller.release();
+ }
+
+}
\ No newline at end of file
Property changes on: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/ValidatorTestBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/AjaxValidationTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/AjaxValidationTest.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/AjaxValidationTest.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -20,7 +20,7 @@
/**
- * Test for dynamic add/remove {@link UIValidatorScript} as view resource.
+ * Test for dynamic add/remove {@link UIScripts} as view resource.
* @author asmirnov
*
*/
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -7,9 +7,10 @@
import java.util.Collection;
import java.util.Collections;
-import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
+import org.richfaces.application.ServiceTracker;
+import org.richfaces.javascript.JavaScriptService;
import org.richfaces.renderkit.html.ComponentValidatorScript;
import org.richfaces.resource.ResourceKey;
@@ -49,7 +50,7 @@
}
}
- public Collection<ResourceKey> getResources(FacesContext context) {
+ public Collection<ResourceKey> getResources() {
return Collections.singleton(TEST_RESOURCE);
}
@@ -80,11 +81,9 @@
}
public String action() {
+ JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class);
FacesContext facesContext = FacesContext.getCurrentInstance();
- UIViewRoot viewRoot = facesContext.getViewRoot();
- UIValidatorScript resource = (UIValidatorScript) facesContext.getApplication().createComponent(UIValidatorScript.COMPONENT_TYPE);
- resource.addOrFindScript(SCRIPT );
- viewRoot.addComponentResource(facesContext, resource);
+ javaScriptService.addPageReadyScript(facesContext, SCRIPT);
return null;
}
Deleted: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -1,77 +0,0 @@
-package org.richfaces.component;
-
-import java.io.IOException;
-import java.util.Collections;
-
-import javax.faces.context.FacesContext;
-
-import org.richfaces.javascript.LibraryScriptString;
-import org.richfaces.resource.ResourceKey;
-
-final class Script implements LibraryScriptString {
- private final String name;
-
- Script(String name) {
- this.name = name;
- }
-
- public String toScript() {
- return name;
- }
-
- public void appendScript(Appendable target) throws IOException {
- target.append(name);
- }
-
- public void appendScriptToStringBuilder(StringBuilder stringBuilder) {
- try {
- appendScript(stringBuilder);
- } catch (IOException e) {
- //ignore
- }
- }
-
- public Iterable<ResourceKey> getResources() {
- return Collections.singleton(UIValidatorScriptCollectionTest.FOO_RESOURCE);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Script other = (Script) obj;
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- return true;
- }
-
- public String getName() {
- return name;
- }
-}
\ No newline at end of file
Deleted: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIValidatorScriptCollectionTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIValidatorScriptCollectionTest.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIValidatorScriptCollectionTest.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -1,72 +0,0 @@
-package org.richfaces.component;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.junit.Test;
-import org.richfaces.javascript.LibraryScriptString;
-import org.richfaces.renderkit.html.ClientOnlyScript;
-import org.richfaces.renderkit.html.ComponentValidatorScript;
-import org.richfaces.resource.ResourceKey;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-/**
- * Test collection of validator scripts.
- * @author asmirnov
- *
- */
-public class UIValidatorScriptCollectionTest {
-
- static final ResourceKey FOO_RESOURCE = ResourceKey.create("foo","org.rf");
-
-
- @Test
- public void testAddOrFindScript() {
- UIValidatorScript validatorScriptComponent = new UIValidatorScript();
- ComponentValidatorScript validatorScript = createValidatorScript("foo", "bar");
- ComponentValidatorScript validatorScript2 = validatorScriptComponent.addOrFindScript(validatorScript);
- Collection<ComponentValidatorScript> scripts = validatorScriptComponent.getScripts();
- assertEquals(1, scripts.size());
- assertSame(validatorScript,Iterables.getOnlyElement(scripts));
- }
-
- @Test
- public void testAddOrFindScript2() {
- UIValidatorScript validatorScriptComponent = new UIValidatorScript();
- ComponentValidatorScript validatorScript = createValidatorScript("foo", "bar");
- validatorScriptComponent.addOrFindScript(validatorScript);
- ComponentValidatorScript validatorScript2 = createValidatorScript("fooz", "baz","bar");
- ComponentValidatorScript validatorScript3 = validatorScriptComponent.addOrFindScript(validatorScript2);
- Collection<ComponentValidatorScript> scripts = validatorScriptComponent.getScripts();
- assertEquals(2, scripts.size());
- assertSame(validatorScript2,validatorScript3);
- }
-
- @Test
- public void testAddOrFindScript3() {
- UIValidatorScript validatorScriptComponent = new UIValidatorScript();
- ComponentValidatorScript validatorScript = createValidatorScript("foo", "bar");
- validatorScriptComponent.addOrFindScript(validatorScript);
- ComponentValidatorScript validatorScript2 = createValidatorScript("foo", "bar");
- ComponentValidatorScript validatorScript3 = validatorScriptComponent.addOrFindScript(validatorScript2);
- Collection<ComponentValidatorScript> scripts = validatorScriptComponent.getScripts();
- assertEquals(1, scripts.size());
- assertSame(validatorScript,validatorScript3);
- }
-
- private LibraryScriptString createLibraryScript(final String name) {
- return new Script(name);
- }
-
- private ComponentValidatorScript createValidatorScript(String converter, String ...validators){
- ArrayList<LibraryScriptString> validatorScripts = Lists.newArrayList();
- for (String validatorName : validators) {
- validatorScripts.add(createLibraryScript(validatorName));
- }
- return new ClientOnlyScript(createLibraryScript(converter), validatorScripts);
- }
-}
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIViewResourceTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIViewResourceTest.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIViewResourceTest.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -14,7 +14,7 @@
/**
- * Test for dynamic add/remove {@link UIValidatorScript} as view resource.
+ * Test for dynamic add/remove {@link UIScripts} as view resource.
* @author asmirnov
*
*/
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorTestBase.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorTestBase.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/behavior/BehaviorTestBase.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -2,40 +2,24 @@
import static org.easymock.EasyMock.expect;
-import javax.el.ValueExpression;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.component.behavior.ClientBehaviorContext;
import javax.faces.render.ClientBehaviorRenderer;
-import org.jboss.test.faces.mock.Environment;
-import org.jboss.test.faces.mock.Environment.Feature;
import org.jboss.test.faces.mock.Mock;
-import org.jboss.test.faces.mock.MockController;
-import org.jboss.test.faces.mock.MockFacesEnvironment;
-import org.jboss.test.faces.mock.Stub;
-import org.junit.After;
import org.junit.Before;
-import org.richfaces.application.ServicesFactory;
+import org.richfaces.ValidatorTestBase;
-public class BehaviorTestBase {
+public class BehaviorTestBase extends ValidatorTestBase {
- @Mock()
- @Environment({ Feature.APPLICATION, Feature.RENDER_KIT,Feature.EL_CONTEXT })
- protected MockFacesEnvironment environment;
@Mock
protected UIInput input;
@Mock
protected ClientBehaviorContext behaviorContext;
@Mock
protected ClientBehaviorRenderer behaviorRenderer;
- protected MockController controller;
protected ClientValidatorBehavior behavior;
- @Mock
- protected ValueExpression expression;
- @Stub
- protected ServicesFactory factory;
-
public BehaviorTestBase() {
super();
}
@@ -46,11 +30,6 @@
}
- @After
- public void tearDown() throws Exception {
- controller.release();
- }
-
protected ClientBehaviorContext setupBehaviorContext(UIComponent component) {
expect(behaviorContext.getComponent()).andStubReturn(component);
expect(behaviorContext.getFacesContext()).andStubReturn(environment.getFacesContext());
Added: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/JavaScriptServiceTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/JavaScriptServiceTest.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/JavaScriptServiceTest.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -0,0 +1,129 @@
+/*
+ * $Id$
+ * 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.javascript;
+
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.jboss.test.faces.mock.Environment;
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockController;
+import org.jboss.test.faces.mock.MockFacesEnvironment;
+import org.jboss.test.faces.mock.MockTestRunner;
+import org.jboss.test.faces.mock.Environment.Feature;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.ValidatorTestBase;
+import org.richfaces.component.UIScripts;
+import org.richfaces.renderkit.html.ClientOnlyScript;
+import org.richfaces.renderkit.html.ComponentValidatorScript;
+import org.richfaces.resource.ResourceKey;
+
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+(a)RunWith(MockTestRunner.class)
+public class JavaScriptServiceTest extends ValidatorTestBase {
+
+ static final ResourceKey FOO_RESOURCE = ResourceKey.create("foo","org.rf");
+
+
+ private UIScripts scriptResource;
+
+ private JavaScriptServiceImpl serviceImpl;
+
+ @Before
+ public void setUpResource(){
+ serviceImpl = new JavaScriptServiceImpl(){
+ @Override
+ UIScripts getOrCreateScriptResource(FacesContext facesContext) {
+ return scriptResource;
+ }
+ };
+ scriptResource = new UIScripts();
+ }
+
+ @After
+ public void cleanUpResource(){
+ scriptResource = null;
+ }
+
+
+ @Test
+ public void testAddOrFindScript() {
+ ComponentValidatorScript validatorScript = createValidatorScript("foo", "bar");
+ ComponentValidatorScript validatorScript2 = serviceImpl.addScript(environment.getFacesContext(),validatorScript);
+ Collection<Object> scripts = scriptResource.getScripts();
+ assertEquals(1, scripts.size());
+ assertSame(validatorScript,Iterables.getOnlyElement(scripts));
+ }
+
+ @Test
+ public void testAddOrFindScript2() {
+ ComponentValidatorScript validatorScript = createValidatorScript("foo", "bar");
+ serviceImpl.addScript(environment.getFacesContext(),validatorScript);
+ ComponentValidatorScript validatorScript2 = createValidatorScript("fooz", "baz","bar");
+ ComponentValidatorScript validatorScript3 = serviceImpl.addScript(environment.getFacesContext(),validatorScript2);
+ Collection<Object> scripts = scriptResource.getScripts();
+ assertEquals(2, scripts.size());
+ assertSame(validatorScript2,validatorScript3);
+ }
+
+ @Test
+ public void testAddOrFindScript3() {
+ ComponentValidatorScript validatorScript = createValidatorScript("foo", "bar");
+ serviceImpl.addScript(environment.getFacesContext(),validatorScript);
+ ComponentValidatorScript validatorScript2 = createValidatorScript("foo", "bar");
+ ComponentValidatorScript validatorScript3 = serviceImpl.addScript(environment.getFacesContext(),validatorScript2);
+ Collection<Object> scripts = scriptResource.getScripts();
+ assertEquals(1, scripts.size());
+ assertSame(validatorScript,validatorScript3);
+ }
+
+ private ScriptWithDependencies createLibraryScript(final String name) {
+ return new Script(name);
+ }
+
+ private ComponentValidatorScript createValidatorScript(String converter, String ...validators){
+ ArrayList<ScriptWithDependencies> validatorScripts = Lists.newArrayList();
+ for (String validatorName : validators) {
+ validatorScripts.add(createLibraryScript(validatorName));
+ }
+ return new ClientOnlyScript(createLibraryScript(converter), validatorScripts);
+ }
+
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/JavaScriptServiceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/Script.java (from rev 20241, branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java)
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/Script.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/Script.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -0,0 +1,74 @@
+package org.richfaces.javascript;
+
+import java.io.IOException;
+import java.util.Collections;
+
+import org.richfaces.resource.ResourceKey;
+
+final class Script implements ScriptWithDependencies {
+ private final String name;
+
+ Script(String name) {
+ this.name = name;
+ }
+
+ public String toScript() {
+ return name;
+ }
+
+ public void appendScript(Appendable target) throws IOException {
+ target.append(name);
+ }
+
+ public void appendScriptToStringBuilder(StringBuilder stringBuilder) {
+ try {
+ appendScript(stringBuilder);
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+
+ public Iterable<ResourceKey> getResources() {
+ return Collections.singleton(JavaScriptServiceTest.FOO_RESOURCE);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Script other = (Script) obj;
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ return true;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
\ No newline at end of file
Property changes on: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/Script.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceGetOrCreateResourceTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceGetOrCreateResourceTest.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceGetOrCreateResourceTest.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -0,0 +1,112 @@
+package org.richfaces.javascript;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockTestRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.ValidatorTestBase;
+import org.richfaces.component.UIScripts;
+
+import com.google.common.collect.Lists;
+
+(a)RunWith(MockTestRunner.class)
+public class ServiceGetOrCreateResourceTest extends ValidatorTestBase {
+
+
+ @Mock
+ private UIViewRoot viewRoot;
+
+
+ private UIScripts scriptResource;
+
+ private JavaScriptServiceImpl serviceImpl;
+
+ @Before
+ public void setUpResource(){
+ serviceImpl = new JavaScriptServiceImpl();
+ scriptResource = new UIScripts();
+ }
+
+ @After
+ public void cleanUpResource(){
+ scriptResource = null;
+ }
+ /**
+ * <p class="changed_added_4_0">
+ * No resource exist in view, create a new one and store in "form" target.
+ * </p>
+ */
+ @Test
+ public void testCreateValidatorScriptResource() {
+ FacesContext facesContext = recordResources(null, null);
+ expect(environment.getApplication().createComponent(UIScripts.COMPONENT_TYPE))
+ .andReturn(scriptResource);
+ viewRoot.addComponentResource(facesContext, scriptResource);
+ expectLastCall();
+ verifyResult(facesContext);
+ }
+
+ private FacesContext recordResources(UIComponent formResource, UIComponent bodyResource) {
+ FacesContext facesContext = recordViewRoot();
+ recordViewResources("form", formResource);
+ if(null == formResource || null != bodyResource){
+ recordViewResources("body", bodyResource);
+ }
+ return facesContext;
+ }
+
+ private void verifyResult(FacesContext facesContext) {
+ controller.replay();
+ assertSame(scriptResource, serviceImpl.getOrCreateScriptResource(facesContext));
+ controller.verify();
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Resource already exists in "form" target
+ * </p>
+ */
+ @Test
+ public void testGetValidatorScriptResourceForm() {
+ FacesContext facesContext = recordResources(scriptResource, null);
+ verifyResult(facesContext);
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * Resource already exists in "body" target
+ * </p>
+ */
+ @Test
+ public void testGetValidatorScriptResourceBody() {
+ FacesContext facesContext = recordResources(null, scriptResource);
+ verifyResult(facesContext);
+ }
+
+
+ private void recordViewResources(String target, UIComponent resource) {
+ FacesContext facesContext = environment.getFacesContext();
+ List<UIComponent> resources = Lists.newArrayList();
+ if (null != resource) {
+ resources.add(resource);
+ }
+ expect(viewRoot.getComponentResources(facesContext, target)).andReturn(resources);
+ }
+
+ private FacesContext recordViewRoot() {
+ FacesContext facesContext = environment.getFacesContext();
+ expect(facesContext.getViewRoot()).andStubReturn(viewRoot);
+ return facesContext;
+ }
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceGetOrCreateResourceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererBuildScriptTest.java (from rev 20241, branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java)
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererBuildScriptTest.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererBuildScriptTest.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -0,0 +1,71 @@
+package org.richfaces.renderkit.html;
+
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.context.FacesContext;
+
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockTestRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.application.ServiceTracker;
+import org.richfaces.component.UIScripts;
+import org.richfaces.component.behavior.ClientValidatorBehavior;
+import org.richfaces.javascript.ClientScriptService;
+import org.richfaces.javascript.JavaScriptService;
+
+import com.google.common.collect.Lists;
+
+(a)RunWith(MockTestRunner.class)
+public class RendererBuildScriptTest extends RendererTestBase {
+
+ private static final String FUNCTION_NAME = "inputValidate";
+
+ private static final String SOURCE_ID ="clientValidator";
+
+ @Mock
+ private UIViewRoot viewRoot;
+
+ @Mock
+ private ComponentValidatorScript validatorScript;
+
+ @Mock
+ private JavaScriptService scriptService;
+
+ @Before
+ public void setUpResource(){
+ expect(factory.getInstance(JavaScriptService.class)).andReturn(scriptService);
+ ServiceTracker.setFactory(factory);
+ }
+
+ @After
+ public void cleanUpResource(){
+ ServiceTracker.release();
+ }
+
+ @Test
+ public void buildAndStoreScript() throws Exception {
+ ClientValidatorRenderer renderer = new ClientValidatorRenderer() {
+ ComponentValidatorScript createValidatorScript(ClientBehaviorContext behaviorContext,
+ ClientValidatorBehavior behavior) {
+ return validatorScript;
+ };
+ };
+ setupBehaviorContext(input);
+ expect(behaviorContext.getSourceId()).andStubReturn(SOURCE_ID);
+ expect(validatorScript.createCallScript(FUNCTION_NAME,SOURCE_ID)).andReturn(FUNCTION_NAME);
+ expect(input.getClientId(environment.getFacesContext())).andReturn(FUNCTION_NAME);
+ expect(scriptService.addScript(environment.getFacesContext(), validatorScript)).andReturn(validatorScript);
+ controller.replay();
+ assertEquals(FUNCTION_NAME, renderer.buildAndStoreValidatorScript(behaviorContext, mockBehavior));
+ controller.verify();
+ }
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererBuildScriptTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -20,7 +20,7 @@
import org.richfaces.application.ServiceTracker;
import org.richfaces.javascript.ClientScriptService;
import org.richfaces.javascript.LibraryFunction;
-import org.richfaces.javascript.LibraryScriptString;
+import org.richfaces.javascript.ScriptWithDependencies;
import org.richfaces.javascript.ScriptNotFoundException;
import org.richfaces.validator.ConverterDescriptor;
import org.richfaces.validator.ValidatorDescriptor;
@@ -63,7 +63,7 @@
expect(scriptService.getScript(environment.getFacesContext(), RegexValidator.class)).andThrow(new ScriptNotFoundException());
controller.replay();
- Collection<? extends LibraryScriptString> clientSideValidatorScript = renderer.getClientSideValidatorScript(
+ Collection<? extends ScriptWithDependencies> clientSideValidatorScript = renderer.getClientSideValidatorScript(
environment.getFacesContext(), descriptors);
assertTrue(clientSideValidatorScript.isEmpty());
controller.verify();
@@ -88,7 +88,7 @@
expect(script.getName()).andReturn(REGEX_VALIDATOR).atLeastOnce();
expect(script.getResources()).andReturn(CLIENT_VALIDATOR_LIBRARY);
controller.replay();
- Collection<? extends LibraryScriptString> clientSideScripts = renderer.getClientSideValidatorScript(environment.getFacesContext(), descriptors);
+ Collection<? extends ScriptWithDependencies> clientSideScripts = renderer.getClientSideValidatorScript(environment.getFacesContext(), descriptors);
LibraryScriptFunction clientSideScript = (LibraryScriptFunction) Iterables.getOnlyElement(clientSideScripts);
assertEquals(ClientValidatorRenderer.CONVERTED_VALUE_LITERAL, clientSideScript.getParameters().get(0));
assertEquals(VALIDATOR_MESSAGE, clientSideScript.getParameters().get(1));
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -25,8 +25,8 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.javascript.LibraryFunction;
-import org.richfaces.javascript.LibraryScriptString;
import org.richfaces.javascript.ScriptNotFoundException;
+import org.richfaces.javascript.ScriptWithDependencies;
import org.richfaces.resource.ResourceKey;
import org.richfaces.validator.ConverterDescriptor;
import org.richfaces.validator.FacesObjectDescriptor;
@@ -139,7 +139,7 @@
// check what generated script contains ajax and client side scripts.
assertThat(script,
allOf(containsString(JSF_AJAX_REQUEST), containsString(REGEX_VALIDATOR), containsString(NUMBER_CONVERTER)));
- assertThat(validatorScript.getResources(environment.getFacesContext()), hasItem(CORE_LIBRARY_MATCHER));
+ assertThat(validatorScript.getResources(), hasItem(CORE_LIBRARY_MATCHER));
}
/**
@@ -175,7 +175,7 @@
script,
allOf(not(containsString(JSF_AJAX_REQUEST)), containsString(REGEX_VALIDATOR),
not(containsString(NUMBER_CONVERTER))));
- assertThat(validatorScript.getResources(environment.getFacesContext()), hasItem(CORE_LIBRARY_MATCHER));
+ assertThat(validatorScript.getResources(), hasItem(CORE_LIBRARY_MATCHER));
}
/**
@@ -196,7 +196,7 @@
script,
allOf(not(containsString(JSF_AJAX_REQUEST)), containsString(REGEX_VALIDATOR),
containsString(NUMBER_CONVERTER)));
- assertThat(validatorScript.getResources(environment.getFacesContext()), hasItem(CORE_LIBRARY_MATCHER));
+ assertThat(validatorScript.getResources(), hasItem(CORE_LIBRARY_MATCHER));
}
private LibraryScriptFunction createValidatorFunction() {
@@ -238,7 +238,7 @@
}
@Override
- Collection<? extends LibraryScriptString> getClientSideValidatorScript(FacesContext facesContext,
+ Collection<? extends ScriptWithDependencies> getClientSideValidatorScript(FacesContext facesContext,
Collection<ValidatorDescriptor> validators) {
return Lists.newArrayList(validatorFunctions);
}
Deleted: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java 2010-11-30 19:36:09 UTC (rev 20245)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetOrCreateResourceTest.java 2010-12-01 00:40:36 UTC (rev 20246)
@@ -1,133 +0,0 @@
-package org.richfaces.renderkit.html;
-
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.component.behavior.ClientBehaviorContext;
-import javax.faces.context.FacesContext;
-
-import org.jboss.test.faces.mock.Mock;
-import org.jboss.test.faces.mock.MockTestRunner;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.richfaces.component.UIValidatorScript;
-import org.richfaces.component.behavior.ClientValidatorBehavior;
-
-import com.google.common.collect.Lists;
-
-(a)RunWith(MockTestRunner.class)
-public class RendererGetOrCreateResourceTest extends RendererTestBase {
-
- private static final String FUNCTION_NAME = "inputValidate";
-
- private static final String SOURCE_ID ="clientValidator";
-
- @Mock
- private UIViewRoot viewRoot;
-
- @Mock
- private ComponentValidatorScript validatorScript;
-
- private UIValidatorScript scriptResource;
-
- @Before
- public void setUpResource(){
- scriptResource = new UIValidatorScript();
- }
-
- @After
- public void cleanUpResource(){
- scriptResource = null;
- }
- /**
- * <p class="changed_added_4_0">
- * No resource exist in view, create a new one and store in "form" target.
- * </p>
- */
- @Test
- public void testCreateValidatorScriptResource() {
- FacesContext facesContext = recordResources(null, null);
- expect(environment.getApplication().createComponent(UIValidatorScript.COMPONENT_TYPE))
- .andReturn(scriptResource);
- viewRoot.addComponentResource(facesContext, scriptResource);
- expectLastCall();
- verifyResult(facesContext);
- }
-
- private FacesContext recordResources(UIComponent formResource, UIComponent bodyResource) {
- FacesContext facesContext = recordViewRoot();
- recordViewResources("form", formResource);
- if(null == formResource || null != bodyResource){
- recordViewResources("body", bodyResource);
- }
- return facesContext;
- }
-
- private void verifyResult(FacesContext facesContext) {
- controller.replay();
- assertSame(scriptResource, renderer.getOrCreateValidatorScriptResource(facesContext));
- controller.verify();
- }
-
- /**
- * <p class="changed_added_4_0">
- * Resource already exists in "form" target
- * </p>
- */
- @Test
- public void testGetValidatorScriptResourceForm() {
- FacesContext facesContext = recordResources(scriptResource, null);
- verifyResult(facesContext);
- }
-
- /**
- * <p class="changed_added_4_0">
- * Resource already exists in "body" target
- * </p>
- */
- @Test
- public void testGetValidatorScriptResourceBody() {
- FacesContext facesContext = recordResources(null, scriptResource);
- verifyResult(facesContext);
- }
-
- @Test
- public void buildAndStoreScript() throws Exception {
- FacesContext facesContext = recordResources(scriptResource, null);
- ClientValidatorRenderer renderer = new ClientValidatorRenderer() {
- ComponentValidatorScript createValidatorScript(ClientBehaviorContext behaviorContext,
- ClientValidatorBehavior behavior) {
- return validatorScript;
- };
- };
- setupBehaviorContext(input);
- expect(behaviorContext.getSourceId()).andStubReturn(SOURCE_ID);
- expect(validatorScript.createCallScript(FUNCTION_NAME,SOURCE_ID)).andReturn(FUNCTION_NAME);
- expect(input.getClientId(facesContext)).andReturn(FUNCTION_NAME);
- controller.replay();
- assertEquals(FUNCTION_NAME, renderer.buildAndStoreValidatorScript(behaviorContext, mockBehavior));
- assertEquals(1, scriptResource.getScripts().size());
- controller.verify();
- }
-
- private void recordViewResources(String target, UIComponent resource) {
- FacesContext facesContext = environment.getFacesContext();
- List<UIComponent> resources = Lists.newArrayList();
- if (null != resource) {
- resources.add(resource);
- }
- expect(viewRoot.getComponentResources(facesContext, target)).andReturn(resources);
- }
-
- private FacesContext recordViewRoot() {
- FacesContext facesContext = environment.getFacesContext();
- expect(facesContext.getViewRoot()).andStubReturn(viewRoot);
- return facesContext;
- }
-}
14 years