craigmcc 2004/07/26 12:34:49
Modified: contrib/struts-faces build.xml
contrib/struts-faces/src/conf faces-config.xml
struts-faces.xml
contrib/struts-faces/src/java/org/apache/struts/faces/component
FormComponent.java
contrib/struts-faces/src/java/org/apache/struts/faces/renderer
ErrorsRenderer.java
contrib/struts-faces/src/java/org/apache/struts/faces/taglib
FormTag.java
contrib/struts-faces/web/example/WEB-INF validation.xml
Added: contrib/struts-faces/src/java/org/apache/struts/faces/renderer
Dummy.properties
Log:
Further cleanup on struts-faces library:
- Eliminate commons-lang as a dependency (wasn't being used anyway)
- Add concrete properties to form component, and document in faces-config.xml
- Make it possible for ErrorsRenderer to run at design time.
Revision Changes Path
1.14 +3 -8 jakarta-struts/contrib/struts-faces/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-struts/contrib/struts-faces/build.xml,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- build.xml 7 Jul 2004 19:40:29 -0000 1.13
+++ build.xml 26 Jul 2004 19:34:48 -0000 1.14
@@ -46,8 +46,6 @@
value="${struts.home}/lib/commons-digester.jar"/>
<property name="commons-fileupload.jar"
value="${struts.home}/lib/commons-fileupload.jar"/>
- <property name="commons-lang.jar"
- value="${struts.home}/lib/commons-lang.jar"/>
<property name="commons-logging.jar"
value="${struts.home}/lib/commons-logging.jar"/>
<property name="commons-validator.jar"
@@ -147,8 +145,9 @@
<copy todir="${build.home}/conf" filtering="on">
<fileset dir="src/conf" includes="*.MF"/>
</copy>
- <copy todir="${build.home}/classes/META-INF"
- file="src/conf/faces-config.xml"/>
+ <copy todir="${build.home}/classes/META-INF">
+ <fileset dir="src/conf" includes="*faces-config.xml"/>
+ </copy>
</target>
@@ -275,8 +274,6 @@
<copy todir="${build.home}/webapps/example/WEB-INF/lib"
file="${commons-fileupload.jar}"/>
<copy todir="${build.home}/webapps/example/WEB-INF/lib"
- file="${commons-lang.jar}"/>
- <copy todir="${build.home}/webapps/example/WEB-INF/lib"
file="${commons-logging.jar}"/>
<copy todir="${build.home}/webapps/example/WEB-INF/lib"
file="${commons-validator.jar}"/>
@@ -395,8 +392,6 @@
file="${commons-digester.jar}"/>
<copy todir="${build.home}/webapps/example2/WEB-INF/lib"
file="${commons-fileupload.jar}"/>
- <copy todir="${build.home}/webapps/example2/WEB-INF/lib"
- file="${commons-lang.jar}"/>
<copy todir="${build.home}/webapps/example2/WEB-INF/lib"
file="${commons-logging.jar}"/>
<copy todir="${build.home}/webapps/example2/WEB-INF/lib"
1.7 +81 -0 jakarta-struts/contrib/struts-faces/src/conf/faces-config.xml
Index: faces-config.xml
===================================================================
RCS file: /home/cvs/jakarta-struts/contrib/struts-faces/src/conf/faces-config.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- faces-config.xml 8 Jul 2004 01:11:27 -0000 1.6
+++ faces-config.xml 26 Jul 2004 19:34:48 -0000 1.7
@@ -95,6 +95,87 @@
org.apache.struts.faces.component.FormComponent
</component-class>
+ <property>
+ <description>
+ Struts action to be executed.
+ </description>
+ <display-name>Struts Action</display-name>
+ <property-name>action</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+
+ <property>
+ <description>
+ Encoding type for form submit.
+ </description>
+ <display-name>Encoding Type</display-name>
+ <property-name>enctype</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+
+ <property>
+ <description>
+ Name of focus component identifier.
+ </description>
+ <display-name>Focus Component Name</display-name>
+ <property-name>focusIndex</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+
+ <property>
+ <description>
+ Index of focus component identifier.
+ </description>
+ <display-name>Focus Component Index</display-name>
+ <property-name>focusIndex</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+
+ <property>
+ <description>
+ JavaScript to execute on form reset.
+ </description>
+ <display-name>Form Reset Script</display-name>
+ <property-name>onreset</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+
+ <property>
+ <description>
+ JavaScript to execute on form submit.
+ </description>
+ <display-name>Form Submit Script</display-name>
+ <property-name>onsubmit</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+
+ <property>
+ <description>
+ CSS style(s) to render for this component.
+ </description>
+ <display-name>CSS Style(s)</display-name>
+ <property-name>style</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+
+ <property>
+ <description>
+ CSS style class(es) to render for this component.
+ </description>
+ <display-name>CSS Style Class(es)</display-name>
+ <property-name>styleClass</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+
+ <property>
+ <description>
+ Target frame for the response to this form submit.
+ </description>
+ <display-name>Target Frame</display-name>
+ <property-name>target</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+
</component>
1.8 +0 -20 jakarta-struts/contrib/struts-faces/src/conf/struts-faces.xml
Index: struts-faces.xml
===================================================================
RCS file: /home/cvs/jakarta-struts/contrib/struts-faces/src/conf/struts-faces.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- struts-faces.xml 8 Jul 2004 01:11:27 -0000 1.7
+++ struts-faces.xml 26 Jul 2004 19:34:48 -0000 1.8
@@ -270,16 +270,6 @@
</attribute>
<attribute>
- <name>method</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <description>
- <p>Method by which this form submit will occur (GET, POST).
- If not specified, POST is used.</p>
- </description>
- </attribute>
-
- <attribute>
<name>onreset</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
@@ -322,16 +312,6 @@
<rtexprvalue>false</rtexprvalue>
<description>
CSS style class to use when rendering this component.
- </description>
- </attribute>
-
- <attribute>
- <name>styleId</name>
- <required>false</required>
- <rtexprvalue>false</rtexprvalue>
- <description>
- <p>Identifier to be assigned to this HTML element (renders an
- "<code>id</code>" element).</p>
</description>
</attribute>
1.12 +261 -3
jakarta-struts/contrib/struts-faces/src/java/org/apache/struts/faces/component/FormComponent.java
Index: FormComponent.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/struts-faces/src/java/org/apache/struts/faces/component/FormComponent.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- FormComponent.java 8 Jul 2004 01:11:28 -0000 1.11
+++ FormComponent.java 26 Jul 2004 19:34:49 -0000 1.12
@@ -54,10 +54,21 @@
protected static Log log = LogFactory.getLog(FormComponent.class);
- // ---------------------------------------------------- Component Properties
+ // ------------------------------------------------------ Instance Variables
private String action = null;
+ private String enctype = null;
+ private String focus = null;
+ private String focusIndex = null;
+ private String onreset = null;
+ private String onsubmit = null;
+ private String style = null;
+ private String styleClass = null;
+ private String target = null;
+
+
+ // ---------------------------------------------------- Component Properties
/**
@@ -92,6 +103,36 @@
/**
+ * <p>Return the encoding type for this form submit.</p>
+ */
+ public String getEnctype() {
+
+ if (this.enctype != null) {
+ return (this.enctype);
+ }
+ ValueBinding vb = getValueBinding("enctype");
+ if (vb != null) {
+ return ((String) vb.getValue(getFacesContext()));
+ } else {
+ return (null);
+ }
+
+ }
+
+
+ /**
+ * <p>Set the encoding type for this form submit.</p>
+ *
+ * @param enctype The new enctype path
+ */
+ public void setEnctype(String enctype) {
+
+ this.enctype = enctype;
+
+ }
+
+
+ /**
* <p>Return the component family to which this component belongs.</p>
*/
public String getFamily() {
@@ -101,6 +142,207 @@
}
+ /**
+ * <p>Return the focus element name.</p>
+ */
+ public String getFocus() {
+
+ if (this.focus != null) {
+ return (this.focus);
+ }
+ ValueBinding vb = getValueBinding("focus");
+ if (vb != null) {
+ return ((String) vb.getValue(getFacesContext()));
+ } else {
+ return (null);
+ }
+
+ }
+
+
+ /**
+ * <p>Set the focus element name.</p>
+ *
+ * @param focus The new focus path
+ */
+ public void setFocus(String focus) {
+
+ this.focus = focus;
+
+ }
+
+
+ /**
+ * <p>Return the focus element index.</p>
+ */
+ public String getFocusIndex() {
+
+ if (this.focusIndex != null) {
+ return (this.focusIndex);
+ }
+ ValueBinding vb = getValueBinding("focusIndex");
+ if (vb != null) {
+ return ((String) vb.getValue(getFacesContext()));
+ } else {
+ return (null);
+ }
+
+ }
+
+
+ /**
+ * <p>Set the focus element index.</p>
+ *
+ * @param focusIndex The new focusIndex path
+ */
+ public void setFocusIndex(String focusIndex) {
+
+ this.focusIndex = focusIndex;
+
+ }
+
+
+ /**
+ * <p>Return the JavaScript to execute on form reset.</p>
+ */
+ public String getOnreset() {
+
+ if (this.onreset != null) {
+ return (this.onreset);
+ }
+ ValueBinding vb = getValueBinding("onreset");
+ if (vb != null) {
+ return ((String) vb.getValue(getFacesContext()));
+ } else {
+ return (null);
+ }
+
+ }
+
+
+ /**
+ * <p>Set the JavaScript to execute on form reset.</p>
+ *
+ * @param onreset The new onreset path
+ */
+ public void setOnreset(String onreset) {
+
+ this.onreset = onreset;
+
+ }
+
+
+ /**
+ * <p>Return the JavaScript to execute on form submit.</p>
+ */
+ public String getOnsubmit() {
+
+ if (this.onsubmit != null) {
+ return (this.onsubmit);
+ }
+ ValueBinding vb = getValueBinding("onsubmit");
+ if (vb != null) {
+ return ((String) vb.getValue(getFacesContext()));
+ } else {
+ return (null);
+ }
+
+ }
+
+
+ /**
+ * <p>Set the JavaScript to execute on form submit.</p>
+ *
+ * @param onsubmit The new onsubmit path
+ */
+ public void setOnsubmit(String onsubmit) {
+
+ this.onsubmit = onsubmit;
+
+ }
+
+
+ /**
+ * <p>Return the CSS style(s) to be rendered for this component.</p>
+ */
+ public String getStyle() {
+
+ ValueBinding vb = getValueBinding("style");
+ if (vb != null) {
+ return (String) vb.getValue(getFacesContext());
+ } else {
+ return style;
+ }
+
+ }
+
+
+ /**
+ * <p>Set the CSS style(s) to be rendered for this component.</p>
+ *
+ * @param style The new CSS style(s)
+ */
+ public void setStyle(String style) {
+
+ this.style = style;
+
+ }
+
+
+ /**
+ * <p>Return the CSS style class(es) to be rendered for this component.</p>
+ */
+ public String getStyleClass() {
+
+ ValueBinding vb = getValueBinding("styleClass");
+ if (vb != null) {
+ return (String) vb.getValue(getFacesContext());
+ } else {
+ return styleClass;
+ }
+
+ }
+
+
+ /**
+ * <p>Set the CSS style class(es) to be rendered for this component.</p>
+ *
+ * @param style The new CSS style class(es)
+ */
+ public void setStyleClass(String styleClass) {
+
+ this.styleClass = styleClass;
+
+ }
+
+
+ /**
+ * <p>Return the target frame for the response to this form submit.</p>
+ */
+ public String getTarget() {
+
+ ValueBinding vb = getValueBinding("target");
+ if (vb != null) {
+ return (String) vb.getValue(getFacesContext());
+ } else {
+ return target;
+ }
+
+ }
+
+
+ /**
+ * <p>Set the target frame for the response to this form submit.</p>
+ *
+ * @param target The new CSS target(s)
+ */
+ public void setTarget(String target) {
+
+ this.target = target;
+
+ }
+
+
// ---------------------------------------------------------- UIForm Methods
@@ -143,6 +385,14 @@
Object values[] = (Object[]) state;
super.restoreState(context, values[0]);
action = (String) values[1];
+ enctype = (String) values[2];
+ focus = (String) values[3];
+ focusIndex = (String) values[4];
+ onreset = (String) values[5];
+ onsubmit = (String) values[6];
+ style = (String) values[7];
+ styleClass = (String) values[8];
+ target = (String) values[9];
}
@@ -154,9 +404,17 @@
*/
public Object saveState(FacesContext context) {
- Object values[] = new Object[2];
+ Object values[] = new Object[10];
values[0] = super.saveState(context);
values[1] = action;
+ values[2] = enctype;
+ values[3] = focus;
+ values[4] = focusIndex;
+ values[5] = onreset;
+ values[6] = onsubmit;
+ values[7] = style;
+ values[8] = styleClass;
+ values[9] = target;
return (values);
}
1.8 +12 -1
jakarta-struts/contrib/struts-faces/src/java/org/apache/struts/faces/renderer/ErrorsRenderer.java
Index: ErrorsRenderer.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/struts-faces/src/java/org/apache/struts/faces/renderer/ErrorsRenderer.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ErrorsRenderer.java 9 Jun 2004 02:38:12 -0000 1.7
+++ ErrorsRenderer.java 26 Jul 2004 19:34:49 -0000 1.8
@@ -17,6 +17,7 @@
package org.apache.struts.faces.renderer;
+import java.beans.Beans;
import java.io.IOException;
import java.util.Iterator;
import java.util.Locale;
@@ -53,6 +54,13 @@
private static Log log = LogFactory.getLog(ErrorsRenderer.class);
+ /**
+ * The dummy message resources for this package.
+ */
+ protected static MessageResources dummy =
+ MessageResources.getMessageResources
+ ("org.apache.struts.faces.renderer.Dummy");
+
// ---------------------------------------------------------- Public Methods
@@ -78,6 +86,9 @@
// Look up availability of our predefined resource keys
MessageResources resources = resources(context, component);
+ if (Beans.isDesignTime() && (resources == null)) {
+ resources = dummy;
+ }
Locale locale = context.getViewRoot().getLocale();
boolean headerPresent = resources.isPresent(locale, "errors.header");
boolean footerPresent = resources.isPresent(locale, "errors.footer");
1.1
jakarta-struts/contrib/struts-faces/src/java/org/apache/struts/faces/renderer/Dummy.properties
Index: Dummy.properties
===================================================================
# This is a dummy properties file that may be used at design
# time when a runtime MessageResources instance is not available
1.8 +1 -49
jakarta-struts/contrib/struts-faces/src/java/org/apache/struts/faces/taglib/FormTag.java
Index: FormTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/struts-faces/src/java/org/apache/struts/faces/taglib/FormTag.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- FormTag.java 9 Jun 2004 02:28:28 -0000 1.7
+++ FormTag.java 26 Jul 2004 19:34:49 -0000 1.8
@@ -78,16 +78,6 @@
/**
- * <p>The submit method (GET or POST) to use.</p>
- */
- protected String method = null;
-
- public void setMethod(String method) {
- this.method = method;
- }
-
-
- /**
* <p>The JavaScript reset event handler.</p>
*/
protected String onreset = null;
@@ -108,36 +98,6 @@
/**
- * <p>The CSS styles to apply to this element.</p>
- */
- protected String style = null;
-
- public void setStyle(String style) {
- this.style = style;
- }
-
-
- /**
- * <p>The CSS style class to apply to this element.</p>
- */
- protected String styleClass = null;
-
- public void setStyleClass(String styleClass) {
- this.styleClass = styleClass;
- }
-
-
- /**
- * <p>The HTML element id for this element.</p>
- */
- protected String styleId = null;
-
- public void setStyleId(String styleId) {
- this.styleId = styleId;
- }
-
-
- /**
* <p>The window target for this submit.</p>
*/
protected String target = null;
@@ -160,12 +120,8 @@
enctype = null;
focus = null;
focusIndex = null;
- method = null;
onreset = null;
onsubmit = null;
- style = null;
- styleClass = null;
- styleId = null;
target = null;
}
@@ -210,12 +166,8 @@
setStringAttribute(component, "enctype", enctype);
setStringAttribute(component, "focus", focus);
setStringAttribute(component, "focusIndex", focusIndex);
- setStringAttribute(component, "method", method);
setStringAttribute(component, "onreset", onreset);
setStringAttribute(component, "onsubmit", onsubmit);
- setStringAttribute(component, "style", style);
- setStringAttribute(component, "styleClass", styleClass);
- setStringAttribute(component, "styleId", styleId);
setStringAttribute(component, "target", target);
}
1.3 +5 -1
jakarta-struts/contrib/struts-faces/web/example/WEB-INF/validation.xml
Index: validation.xml
===================================================================
RCS file:
/home/cvs/jakarta-struts/contrib/struts-faces/web/example/WEB-INF/validation.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- validation.xml 8 Mar 2004 03:07:36 -0000 1.2
+++ validation.xml 26 Jul 2004 19:34:49 -0000 1.3
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE form-validation PUBLIC
+ "-//Apache Software Foundation//DTD Commons Validator Rules Configuration
1.1//EN"
+ "http://jakarta.apache.org/commons/dtds/validator_1_1.dtd">
+
<!--
Copyright 2002,2004 The Apache Software Foundation.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]