Author: jjamrich
Date: 2011-05-11 16:19:49 -0400 (Wed, 11 May 2011)
New Revision: 22483
Removed:
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/jsr303.xhtml
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichGraphValidatorBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/all.xhtml
Log:
Add autocompletion and calendar into metamer within graphValidator
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichGraphValidatorBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichGraphValidatorBean.java 2011-05-10
20:05:31 UTC (rev 22482)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/rich/RichGraphValidatorBean.java 2011-05-11
20:19:49 UTC (rev 22483)
@@ -23,6 +23,8 @@
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import javax.annotation.PostConstruct;
@@ -106,6 +108,8 @@
@NotNull
@NotEmpty
private String selectOneRadio = smile;
+ @NotNull
+ private Date calendar = new Date(System.currentTimeMillis());
@PostConstruct
public void init(){
@@ -118,7 +122,7 @@
}
@AssertTrue(message = "One of following inputs doesn't contain smile or
numeric value "
- + REQUIRED_INT_VALUE + "!",
+ + REQUIRED_INT_VALUE + " or date is from future!",
groups = {Default.class, ValidationGroupAllComponents.class})
public boolean isAllInputsCorrect() {
@@ -137,7 +141,8 @@
&& !selectManyListbox.isEmpty()
&& selectOneMenu.contains(smile)
&& !selectManyMenu.isEmpty()
- && selectOneRadio.contains(smile);
+ && selectOneRadio.contains(smile)
+ && !calendar.after(new Date(System.currentTimeMillis()));
}
@AssertTrue(message = "One of following numeric inputs doesn't contain value
"
@@ -170,6 +175,27 @@
return result;
}
+ public List<String> autocomplete(String prefix) {
+ ArrayList<String> result = new ArrayList<String>();
+ if ((prefix == null) || (prefix.length() == 0)) {
+ for (int i = 0; i < 10; i++) {
+ result.add(getSelectItems().get(i).getLabel());
+ }
+
+ } else {
+ Iterator<SelectItem> iterator = selectItems.iterator();
+ while (iterator.hasNext()) {
+ SelectItem elem = ((SelectItem) iterator.next());
+ if ((elem.getLabel() != null &&
elem.getLabel().toLowerCase().indexOf(prefix.toLowerCase()) == 0)
+ || "".equals(prefix)) {
+ result.add(elem.getLabel());
+ }
+ }
+ }
+
+ return result;
+ }
+
public Class<?>[] getValidationGroups() throws ClassNotFoundException {
Attribute groups = attributes.get("groups");
Class<?> group;
@@ -327,4 +353,12 @@
public void setSelectOneRadio(String selectOneRadio) {
this.selectOneRadio = selectOneRadio;
}
+
+ public Date getCalendar() {
+ return calendar;
+ }
+
+ public void setCalendar(Date calendar) {
+ this.calendar = calendar;
+ }
}
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/all.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/all.xhtml 2011-05-10
20:05:31 UTC (rev 22482)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/all.xhtml 2011-05-11
20:19:49 UTC (rev 22483)
@@ -58,27 +58,26 @@
groups="#{richGraphValidatorBean.validationGroups}"
type="#{richGraphValidatorBean.attributes['type'].value}"
rendered="#{richGraphValidatorBean.attributes['rendered'].value}"
>
- <rich:panel header="Many rich components within rich:graphValidator"
style="width:500px">
+ <rich:panel header="Many rich components within rich:graphValidator"
style="width:800px">
<rich:messages for="gv1" />
<rich:messages globalOnly="true" />
- <h:panelGrid columns="3">
+ <h:panelGrid columns="6">
<h:outputText for="inplaceSelect" value="Inplace Select"
/>
- <rich:inplaceSelect id="inplaceSelect"
value="#{richGraphValidatorBean.inplaceSelect}"
- defaultLabel="Write smile here..." >
+ <rich:inplaceSelect id="inplaceSelect"
value="#{richGraphValidatorBean.inplaceSelect}" >
<f:selectItems value="#{richGraphValidatorBean.selectItems}" />
</rich:inplaceSelect>
<rich:message for="inplaceSelect" />
- <h:outputText for="inplaceInput" value="Inplace Input"
/>
- <rich:inplaceInput id="inplaceInput"
value="#{richGraphValidatorBean.inplaceInput}" />
- <rich:message for="inplaceInput" />
-
<h:outputText for="select" value="Select" />
<rich:select id="select"
value="#{richGraphValidatorBean.select}" >
<f:selectItems value="#{richGraphValidatorBean.selectItems}" />
</rich:select>
<rich:message for="select" />
+ <h:outputText for="inplaceInput" value="Inplace Input"
/>
+ <rich:inplaceInput id="inplaceInput"
value="#{richGraphValidatorBean.inplaceInput}" />
+ <rich:message for="inplaceInput" />
+
<h:outputText for="inputNumberSlider" value="Input Number
Slider" />
<rich:inputNumberSlider id="inputNumberSlider"
value="#{richGraphValidatorBean.inputNumberSlider}" />
<rich:message for="inputNumberSlider" />
@@ -88,9 +87,14 @@
<rich:message for="inputNumberSpinner" />
<h:outputText for="autocomplete" value="Autocomplete"
/>
- <rich:autocomplete id="autocomplete"
value="#{richGraphValidatorBean.autocompleteInput}" />
+ <rich:autocomplete id="autocomplete"
value="#{richGraphValidatorBean.autocompleteInput}"
+ autocompleteMethod="#{richGraphValidatorBean.autocomplete}"
/>
<rich:message for="autocomplete" />
+ <h:outputText for="selectBooleanCheckbox" value="Select Boolean
Checkbox" />
+ <h:selectBooleanCheckbox id="selectBooleanCheckbox"
value="#{richGraphValidatorBean.selectBooleanCheckbox}" />
+ <rich:message for="selectBooleanCheckbox" />
+
<h:outputText for="inputText" value="Input Text" />
<h:inputText id="inputText"
value="#{richGraphValidatorBean.inputText}" />
<rich:message for="inputText" />
@@ -99,13 +103,23 @@
<h:inputSecret id="inputSecret"
value="#{richGraphValidatorBean.inputSecret}" />
<rich:message for="inputSecret" />
+ <h:outputText for="calendar" value="Calendar" />
+ <rich:calendar id="calendar"
value="#{richGraphValidatorBean.calendar}" />
+ <rich:message for="calendar" />
+
+ <h:column/>
+ <h:column/>
+ <h:column/>
+
<h:outputText for="inputTextarea" value="Input Text Area"
/>
<h:inputTextarea id="inputTextarea"
value="#{richGraphValidatorBean.inputTextarea}" />
<rich:message for="inputTextarea" />
- <h:outputText for="selectBooleanCheckbox" value="Select Boolean
Checkbox" />
- <h:selectBooleanCheckbox id="selectBooleanCheckbox"
value="#{richGraphValidatorBean.selectBooleanCheckbox}" />
- <rich:message for="selectBooleanCheckbox" />
+ <h:outputText for="selectOneListbox" value="Select One
Listbox" />
+ <h:selectOneListbox id="selectOneListbox"
value="#{richGraphValidatorBean.selectOneListbox}" >
+ <f:selectItems value="#{richGraphValidatorBean.selectItems}" />
+ </h:selectOneListbox>
+ <rich:message for="selectOneListbox" />
<h:outputText for="selectManyCheckbox" value="Select Many
Checkbox" />
<h:selectManyCheckbox id="selectManyCheckbox"
@@ -114,12 +128,6 @@
</h:selectManyCheckbox>
<rich:message for="selectManyCheckbox" />
- <h:outputText for="selectOneListbox" value="Select One
Listbox" />
- <h:selectOneListbox id="selectOneListbox"
value="#{richGraphValidatorBean.selectOneListbox}" >
- <f:selectItems value="#{richGraphValidatorBean.selectItems}" />
- </h:selectOneListbox>
- <rich:message for="selectOneListbox" />
-
<h:outputText for="selectManyListbox" value="Select Many
Listbox" />
<h:selectManyListbox id="selectManyListbox"
value="#{richGraphValidatorBean.selectManyListbox}" >
<f:selectItems value="#{richGraphValidatorBean.selectItems}" />
Deleted:
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/jsr303.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/jsr303.xhtml 2011-05-10
20:05:31 UTC (rev 22482)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richGraphValidator/jsr303.xhtml 2011-05-11
20:19:49 UTC (rev 22483)
@@ -1,135 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!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"
-
xmlns:a4j="http://richfaces.org/a4j"
-
xmlns:rich="http://richfaces.org/rich"
-
xmlns:metamer="http://java.sun.com/jsf/composite/metamer">
-
-<!--
-JBoss, Home of Professional Open Source
-Copyright 2010-2011, 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.
- -->
-
-<ui:composition template="/templates/template.xhtml">
-
- <ui:define name="view">
- <f:metadata>
- <f:viewParam name="templates"
value="#{templateBean.templates}">
- <f:converter converterId="templatesListConverter" />
- </f:viewParam>
- </f:metadata>
- </ui:define>
-
- <ui:define name="head">
- <style type="text/css">
- .rf-msg-err {
- display: block !important;
- margin-bottom: 6px;
- }
- </style>
- </ui:define>
-
- <ui:define name="component">
- <script type="text/javascript">
- function setCorrectValues() {
- $('input[id$=pass1]').val('rfvokm334lafd');
- $('input[id$=conf1]').val('rfvokm334lafd');
- }
-
- function setWrongValues() {
- $('input[id$=pass1]').val('rfvdthrfd');
- $('input[id$=conf1]').val('dsararaAqa');
- }
- </script>
-
- <h:form>
- <input id="setCorrectValuesButton" type="button"
value="set correct values" onclick="setCorrectValues()"/>
- <input id="setWrongValuesButton" type="button"
value="set wrong values" onclick="setWrongValues()"/>
-
- <br/>
-
- <ui:fragment
rendered="#{richGraphValidatorBean.attributes['summary'].value==null
- || richGraphValidatorBean.attributes['summary'].value==''}"
>
- <rich:graphValidator id="gv1"
- value="#{richGraphValidatorBean}"
-
groups="#{richGraphValidatorBean.attributes['groups'].value}"
- type="#{richGraphValidatorBean.attributes['type'].value}"
-
rendered="#{richGraphValidatorBean.attributes['rendered'].value}"
>
- <rich:panel header="Change password" style="width:500px">
- <rich:messages for="gv1" />
- <rich:messages globalOnly="true" />
- <h:panelGrid columns="3">
- <h:outputText value="Enter new password:" />
- <h:inputSecret value="#{richGraphValidatorBean.password}"
id="pass1" />
- <rich:message for="pass1" />
- <h:outputText value="Confirm the new password:" />
- <h:inputSecret value="#{richGraphValidatorBean.passwordConfirm}"
id="conf1" />
- <rich:message for="conf1" />
- </h:panelGrid>
- <a4j:commandButton value="Store changes"
- action="#{richGraphValidatorBean.storeNewPassword}" />
- </rich:panel>
- </rich:graphValidator>
- </ui:fragment>
-
- <ui:fragment
rendered="#{richGraphValidatorBean.attributes['summary'].value!=null
- &&
richGraphValidatorBean.attributes['summary'].value!=''}" >
- <rich:graphValidator id="gv2"
- value="#{richGraphValidatorBean}"
-
groups="#{richGraphValidatorBean.attributes['groups'].value}"
-
rendered="#{richGraphValidatorBean.attributes['rendered'].value}"
-
summary="#{richGraphValidatorBean.attributes['summary'].value}"
- type="#{richGraphValidatorBean.attributes['type'].value}"
>
- <rich:panel header="Change password" style="width:500px">
- <rich:messages for="gv2" />
- <rich:messages globalOnly="true" />
- <h:panelGrid columns="3">
- <h:outputText value="Enter new password:" />
- <h:inputSecret value="#{richGraphValidatorBean.password}"
- id="pass2" />
- <rich:message for="pass2" />
- <h:outputText value="Confirm the new password:" />
- <h:inputSecret value="#{richGraphValidatorBean.passwordConfirm}"
- id="conf2" />
- <rich:message for="conf2" />
- </h:panelGrid>
- <a4j:commandButton value="Store changes"
- action="#{richGraphValidatorBean.storeNewPassword}" />
- </rich:panel>
- </rich:graphValidator>
- </ui:fragment>
-
- </h:form>
-
- <br />
- <rich:messages id="msgs" value="#{richGraphValidatorBean}"
/>
-
- </ui:define>
-
- <ui:define name="outOfTemplateAfter">
- <metamer:attributes value="#{richGraphValidatorBean.attributes}"
- id="attributes" />
- </ui:define>
-
-</ui:composition>
-</html>
\ No newline at end of file