Author: nbelaevski
Date: 2009-05-08 09:27:08 -0400 (Fri, 08 May 2009)
New Revision: 14078
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/editor/InputResetBean.java
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/editor/EditorBean.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/editor/examples/editor.xhtml
Log:
https://jira.jboss.org/jira/browse/RF-7028
Modified:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/editor/EditorBean.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/editor/EditorBean.java 2009-05-08
11:51:31 UTC (rev 14077)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/editor/EditorBean.java 2009-05-08
13:27:08 UTC (rev 14078)
@@ -3,8 +3,13 @@
import java.util.ArrayList;
import java.util.List;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
+import javax.faces.validator.ValidatorException;
+import org.jboss.seam.ui.validator.FormattedTextValidator;
+
public class EditorBean {
private String currentConfiguration = CONFIGS_PACKAGE + "simple";
@@ -69,6 +74,9 @@
this.useSeamText = useSeamText;
}
-
-
+ public void validate(FacesContext context, UIComponent component, Object value) throws
ValidatorException {
+ if (useSeamText) {
+ new FormattedTextValidator().validate(context, component, value);
+ }
+ }
}
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/editor/InputResetBean.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/editor/InputResetBean.java
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/editor/InputResetBean.java 2009-05-08
13:27:08 UTC (rev 14078)
@@ -0,0 +1,54 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.demo.editor;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ValueChangeEvent;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+@Name("inputResetBean")
+(a)Scope(ScopeType.EVENT)
+public class InputResetBean {
+
+ @In
+ private FacesContext facesContext;
+
+ public void processValueChange(ValueChangeEvent valueChangeEvent) {
+ if (facesContext.getMaximumSeverity() != null) {
+ UIComponent component = valueChangeEvent.getComponent();
+ if (component instanceof UIInput) {
+ UIInput input = (UIInput) component;
+ input.resetValue();
+ }
+ }
+ }
+}
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/editor/examples/editor.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/editor/examples/editor.xhtml 2009-05-08
11:51:31 UTC (rev 14077)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/editor/examples/editor.xhtml 2009-05-08
13:27:08 UTC (rev 14078)
@@ -6,56 +6,75 @@
xmlns:rich="http://richfaces.org/rich"
xmlns:s="http://jboss.com/products/seam/taglib">
<style>
+
.column {
width: 400px;
+}
+
+.column, .column2 {
vertical-align: top;
}
+
+.column2 {
+ padding-left: 100px;
+}
</style>
+
<h:form id="form">
- <h:panelGrid columns="2" width="100%"
columnClasses="column,column">
+ <h:panelGrid columns="2" width="100%"
columnClasses="column,column2">
<h:panelGroup style="height:320px;width:400px;"
layout="block">
<rich:editor configuration="#{editorBean.currentConfiguration}"
- id="editor" width="400" height="300"
+ id="editor" width="400" height="300"
validator="#{editorBean.validate}"
viewMode="#{editorBean.viewMode}" value="#{editorBean.value}"
useSeamText="#{editorBean.useSeamText}">
<a4j:support event="onchange" reRender="result"
ajaxSingle="true"
requestDelay="1000"
- onsubmit="if (! #{rich:element('form:editorvalue')}) return
false;" />
+ onsubmit="if (!#{rich:element('form:editorvalue')} &&
!#{editorBean.useSeamText}) return false;" />
</rich:editor>
</h:panelGroup>
- <rich:panel>
+ <rich:panel id="controls" style="width: 400px;">
<f:facet name="header">
<h:outputText value="Editor Settings" />
</f:facet>
<h:panelGrid columns="2">
<h:outputText value="Select Editor Theme" />
<h:selectOneRadio value="#{editorBean.currentConfiguration}"
- layout="pageDirection">
+ layout="pageDirection"
valueChangeListener="#{inputResetBean.processValueChange}">
<f:selectItems value="#{editorBean.configurations}" />
- <a4j:support event="onclick" reRender="editor"
requestDelay="500"
+ <a4j:support event="onclick" reRender="editor,controls"
requestDelay="500"
eventsQueue="settingsQueue" similarityGroupingId="settings"
/>
</h:selectOneRadio>
<h:outputText value="Toggle Modes" escape="false"/>
<h:selectOneRadio value="#{editorBean.viewMode}"
- layout="pageDirection">
+ layout="pageDirection"
valueChangeListener="#{inputResetBean.processValueChange}">
<f:selectItem itemLabel="WYSIWYG mode" itemValue="visual"
/>
<f:selectItem itemLabel="Text Area(Disables Preview)"
itemValue="source" />
- <a4j:support event="onclick" reRender="editor"
requestDelay="500"
+ <a4j:support event="onclick" reRender="editor,controls"
requestDelay="500"
eventsQueue="settingsQueue" similarityGroupingId="settings"
/>
</h:selectOneRadio>
<h:outputText value="Toggle Preview: " />
- <h:selectBooleanCheckbox value="#{editorBean.liveUpdatesEnabled}">
- <a4j:support event="onclick" reRender="result"
requestDelay="500"
+ <h:selectBooleanCheckbox value="#{editorBean.liveUpdatesEnabled}"
+ valueChangeListener="#{inputResetBean.processValueChange}">
+ <a4j:support event="onclick" reRender="result,controls"
requestDelay="500"
eventsQueue="settingsQueue" similarityGroupingId="settings"
/>
</h:selectBooleanCheckbox>
<h:outputText value="Use Seam Text: " />
<h:selectBooleanCheckbox value="#{editorBean.useSeamText}">
- <a4j:support event="onclick" reRender="editor,result"
requestDelay="500"
+ <a4j:support event="onclick"
reRender="editor,result,controls" requestDelay="500"
ajaxSingle="true"
eventsQueue="settingsQueue" similarityGroupingId="settings"
action="#{editorBean.resetValue}"/>
</h:selectBooleanCheckbox>
</h:panelGrid>
</rich:panel>
+
<a4j:outputPanel layout="block" id="result">
- <rich:panel rendered="#{editorBean.liveUpdatesEnabled}">
+
+ <a4j:outputPanel style="color: red;"
+ rendered="#{facesContext.maximumSeverity != null and
editorBean.useSeamText}">
+ <h:outputText value="SeamText: "/>
+ </a4j:outputPanel>
+ <rich:message for="editor" style="color: red;" />
+
+ <rich:panel rendered="#{editorBean.liveUpdatesEnabled}"
+ style="#{facesContext.maximumSeverity != null ? 'display: none;' :
''}">
<f:facet name="header">
<h:outputText value="Preview" />
</f:facet>
@@ -63,6 +82,7 @@
cols="55" rows="20"/>
</rich:panel>
</a4j:outputPanel>
+ <h:outputText />
</h:panelGrid>
</h:form>