Author: mvitenkov
Date: 2009-03-17 13:34:22 -0400 (Tue, 17 Mar 2009)
New Revision: 12993
Added:
trunk/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/colorPicker/
trunk/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/colorPicker/ColorPicker.java
Modified:
trunk/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/rich/RichBean.java
trunk/test-applications/seamApp/web/src/main/webapp/WEB-INF/faces-config.xml
Log:
Add colorPicker component to seamApp test application
Added:
trunk/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/colorPicker/ColorPicker.java
===================================================================
---
trunk/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/colorPicker/ColorPicker.java
(rev 0)
+++
trunk/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/colorPicker/ColorPicker.java 2009-03-17
17:34:22 UTC (rev 12993)
@@ -0,0 +1,205 @@
+package org.richfaces.helloworld.domain.colorPicker;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.richfaces.component.html.HtmlColorPicker;
+
+import org.richfaces.helloworld.domain.util.componentInfo.ComponentInfo;
+
+@Name("colorPicker")
+(a)Scope(ScopeType.SESSION)
+public class ColorPicker implements Validator, Converter {
+ private HtmlColorPicker htmlColorPicker;
+ private String colorMode;// hex, rgb
+ private String converterMessage;
+ private boolean disabled;
+ private boolean flat;
+ private boolean immediate;
+ private boolean localValueSet;
+ private boolean rendered;
+ private boolean required;
+ private String requiredMessage;
+ private boolean valid;
+ private String validatorMessage;
+ private String value;
+ private String bindLabel;
+
+ public ColorPicker() {
+ colorMode = "rgb";
+ converterMessage = "custom converter message";
+ disabled = false;
+ flat = false;
+ immediate = false;
+ localValueSet = true;
+ rendered = true;
+ required = false;
+ requiredMessage = "custom required message";
+ valid = true;
+ validatorMessage = "custom validator message";
+ value = "rgb(255, 250, 240)";
+ bindLabel = "Click Binding";
+ }
+
+ public void checkBinding(ActionEvent e){
+ FacesContext context = FacesContext.getCurrentInstance();
+ bindLabel = htmlColorPicker.getClientId(context);
+ }
+
+ public void changeValue(ValueChangeEvent e) {
+ System.out.println("old value:" + e.getOldValue() + " new value:"
+ + e.getNewValue());
+ }
+
+ public void addColorPicker() {
+ ComponentInfo info = ComponentInfo.getInstance();
+ info.addField(htmlColorPicker);
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public void validate(FacesContext context, UIComponent component,
+ Object value) throws ValidatorException {
+ String str = value.toString();
+ if (str.startsWith("rgb")) {
+ if (str.indexOf("100") != -1)
+ throw new ValidatorException(new FacesMessage(
+ "Test validator: 100 is restricted!"));
+ }
+ }
+
+ public Object getAsObject(FacesContext context, UIComponent component,
+ String value) throws ConverterException {
+ if (value.indexOf("100") != -1)
+ throw new ConverterException(new FacesMessage("Test converter(getAsObject): 100
is restricted!"));
+ return new String(value + " converted");
+ }
+
+ public String getAsString(FacesContext context, UIComponent component,
+ Object value) throws ConverterException {
+ if (value.toString().indexOf("100") != -1)
+ throw new ConverterException(new FacesMessage("Test converter(getAsString): 100
is restricted!"));
+ return value.toString();
+ }
+
+ public String getColorMode() {
+ return colorMode;
+ }
+
+ public void setColorMode(String colorMode) {
+ this.colorMode = colorMode;
+ }
+
+ public String getConverterMessage() {
+ return converterMessage;
+ }
+
+ public void setConverterMessage(String converterMessage) {
+ this.converterMessage = converterMessage;
+ }
+
+ public boolean isDisabled() {
+ return disabled;
+ }
+
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+
+ public boolean isFlat() {
+ return flat;
+ }
+
+ public void setFlat(boolean flat) {
+ this.flat = flat;
+ }
+
+ public boolean isImmediate() {
+ return immediate;
+ }
+
+ public void setImmediate(boolean immediate) {
+ this.immediate = immediate;
+ }
+
+ public boolean isLocalValueSet() {
+ return localValueSet;
+ }
+
+ public void setLocalValueSet(boolean localValueSet) {
+ this.localValueSet = localValueSet;
+ }
+
+ public boolean isRendered() {
+ return rendered;
+ }
+
+ public void setRendered(boolean rendered) {
+ this.rendered = rendered;
+ }
+
+ public boolean isRequired() {
+ return required;
+ }
+
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
+ public String getRequiredMessage() {
+ return requiredMessage;
+ }
+
+ public void setRequiredMessage(String requiredMessage) {
+ this.requiredMessage = requiredMessage;
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public void setValid(boolean valid) {
+ this.valid = valid;
+ }
+
+ public String getValidatorMessage() {
+ return validatorMessage;
+ }
+
+ public void setValidatorMessage(String validatorMessage) {
+ this.validatorMessage = validatorMessage;
+ }
+
+ public String getBindLabel() {
+ return bindLabel;
+ }
+
+ public void setBindLabel(String bindLabel) {
+ this.bindLabel = bindLabel;
+ }
+
+ public HtmlColorPicker getHtmlColorPicker() {
+ return htmlColorPicker;
+ }
+
+ public void setHtmlColorPicker(HtmlColorPicker htmlColorPicker) {
+ this.htmlColorPicker = htmlColorPicker;
+ }
+
+}
Modified:
trunk/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/rich/RichBean.java
===================================================================
---
trunk/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/rich/RichBean.java 2009-03-17
17:32:45 UTC (rev 12992)
+++
trunk/test-applications/seamApp/web/src/main/java/org/richfaces/helloworld/domain/rich/RichBean.java 2009-03-17
17:34:22 UTC (rev 12993)
@@ -81,7 +81,7 @@
map.add("ExtendedDataTable",
add("/ExtendedDataTable/ExtendedDataTable", new boolean [] {false, true,
false}));
map.add("Editor", add("/Editor/Editor", new boolean [] {true, true,
false}));
map.add("Queue", add("/Queue/Queue", new boolean [] {false, true,
true}));
-
+ map.add("ColorPicker", add("/ColorPicker/ColorPicker", new boolean
[] {false, true, false}));
Iterator<String> iterator = map.getSet().iterator();
while(iterator.hasNext()){
list.add(new SelectItem(iterator.next()));
Modified: trunk/test-applications/seamApp/web/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seamApp/web/src/main/webapp/WEB-INF/faces-config.xml 2009-03-17
17:32:45 UTC (rev 12992)
+++
trunk/test-applications/seamApp/web/src/main/webapp/WEB-INF/faces-config.xml 2009-03-17
17:34:22 UTC (rev 12993)
@@ -20,6 +20,10 @@
org.richfaces.helloworld.domain.util.converter.InplaceInputConverter
</converter-class>
</converter>
+ <converter>
+ <converter-id>colorPickerConverter</converter-id>
+ <converter-class>org.richfaces.helloworld.domain.colorPicker.ColorPicker</converter-class>
+ </converter>
<validator>
<validator-id>CalendarValidator</validator-id>
<validator-class>
@@ -32,6 +36,20 @@
org.richfaces.helloworld.domain.message.MessageValidator
</validator-class>
</validator>
+ <managed-bean>
+ <managed-bean-name>skinBean</managed-bean-name>
+ <managed-bean-class>
+ org.richfaces.helloworld.domain.util.skins.Skins
+ </managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>skinning</managed-bean-name>
+ <managed-bean-class>
+ org.richfaces.helloworld.domain.skinning.Skinning
+ </managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
<locale-config>
@@ -44,6 +62,8 @@
</locale-config>
</application>
<lifecycle>
- <phase-listener>org.richfaces.helloworld.domain.util.phaseTracker.PhaseTracker</phase-listener>
+ <phase-listener>
+ org.richfaces.helloworld.domain.util.phaseTracker.PhaseTracker
+ </phase-listener>
</lifecycle>
</faces-config>
Show replies by date