You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jo...@apache.org on 2001/06/11 19:26:26 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/services/intake/xmlmodel XmlField.java
jon 01/06/11 10:26:26
Modified: src/java/org/apache/turbine/services/intake/model Field.java
Group.java
src/java/org/apache/turbine/services/intake/xmlmodel
XmlField.java
Log:
patch for intake to fix some bugs and add a displayName to the <field>...
thanks to: Guido Sohne <ca...@yahoo.com>
Revision Changes Path
1.14 +31 -6 jakarta-turbine/src/java/org/apache/turbine/services/intake/model/Field.java
Index: Field.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/model/Field.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Field.java 2001/05/30 01:08:52 1.13
+++ Field.java 2001/06/11 17:26:25 1.14
@@ -74,7 +74,7 @@
* Base class for Intake generated input processing classes.
*
* @author <a href="mailto:jmcnally@collab.net>John McNally</a>
- * @version $Id: Field.java,v 1.13 2001/05/30 01:08:52 jmcnally Exp $
+ * @version $Id: Field.java,v 1.14 2001/06/11 17:26:25 jon Exp $
*/
public abstract class Field
{
@@ -84,6 +84,7 @@
// the following are set from the xml file and are permanent (final)
protected final String name;
protected final String key;
+ protected final String displayName;
protected final String mapToObject;
protected Validator validator;
protected final Method getter;
@@ -137,6 +138,7 @@
this.group = group;
key = field.getKey();
name = field.getName();
+ displayName = field.getDisplayName();
isMultiValued = field.isMultiValued();
String className = field.getValidator();
if ( className == null && field.getRules().size() > 0 )
@@ -420,6 +422,29 @@
}
/**
+ * Get the display name of the field. Useful for building
+ * data entry forms. Returns name of field if no display
+ * name has been assigned to the field by xml input file
+ *
+ * @return a <code>String</code> value
+ */
+ public String getDisplayName()
+ {
+ return (displayName == null) ? name : displayName;
+ }
+
+ /**
+ * Set the display name of the field. Display names are
+ * used in building data entry forms and serve as a
+ * user friendly description of the data contained in
+ * the field.
+ */
+ public void setDisplayName(String newDisplayName)
+ {
+ this.displayName = newDisplayName;
+ }
+
+ /**
* Get any error message resulting from invalid input.
*
* @return a <code>String</code> value
@@ -486,6 +511,11 @@
try
{
validator.assertValidity(s);
+
+ if ( set_flag )
+ {
+ doSetValue(pp);
+ }
}
catch (ValidationException ve)
{
@@ -510,11 +540,6 @@
}
*/
- if ( set_flag )
- {
- doSetValue(pp);
- }
-
return valid_flag;
}
1.14 +24 -0 jakarta-turbine/src/java/org/apache/turbine/services/intake/model/Group.java
Index: Group.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/model/Group.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Group.java 2001/05/05 15:26:58 1.13
+++ Group.java 2001/06/11 17:26:25 1.14
@@ -371,6 +371,30 @@
}
/**
+ * Calls getter methods on objects that are known to Intake
+ * so that field values in forms can be initialized from
+ * the values contained in the intake tool.
+ */
+ public void getProperties(Object obj)
+ throws Exception
+ {
+ Class cls = obj.getClass();
+ while (cls != null)
+ {
+ Field[] flds = (Field[])mapToObjectFields.get(cls.getName());
+ if( flds != null )
+ {
+ for (int i=flds.length-1; i>=0; i--)
+ {
+ flds[i].getProperty(obj);
+ }
+ }
+
+ cls = cls.getSuperclass();
+ }
+ }
+
+ /**
* Removes references to this group and its fields from the
* query parameters
*/
1.11 +23 -1 jakarta-turbine/src/java/org/apache/turbine/services/intake/xmlmodel/XmlField.java
Index: XmlField.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/intake/xmlmodel/XmlField.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XmlField.java 2001/05/18 19:35:58 1.10
+++ XmlField.java 2001/06/11 17:26:26 1.11
@@ -66,7 +66,7 @@
* A Class for holding data about a property used in an Application.
*
* @author <a href="mailto:jmcnally@collab.net>John McNally</a>
- * @version $Id: XmlField.java,v 1.10 2001/05/18 19:35:58 jmcnally Exp $
+ * @version $Id: XmlField.java,v 1.11 2001/06/11 17:26:26 jon Exp $
*/
public class XmlField
implements java.io.Serializable
@@ -78,6 +78,7 @@
private String name;
private String key;
private String type;
+ private String displayName;
private String onError;
private String multiValued;
private XmlGroup parent;
@@ -170,6 +171,7 @@
setName(attrib.getValue("name"));
key = attrib.getValue("key");
type = attrib.getValue("type");
+ displayName = attrib.getValue("displayName");
//setOnError(attrib.getValue("onError"));
setMultiValued(attrib.getValue("multiValued"));
@@ -213,6 +215,22 @@
}
/**
+ * Get the display name of the property
+ */
+ public String getDisplayName()
+ {
+ return displayName;
+ }
+
+ /**
+ * Set the display name of the property
+ */
+ public void setDisplayName(String newDisplayName)
+ {
+ displayName = newDisplayName;
+ }
+
+ /**
* Set the parameter key of the property
*/
public void setKey(String newKey)
@@ -486,6 +504,10 @@
result.append(" key=\""+key+"\"");
result.append(" type=\""+type+"\"");
+ if (displayName != null)
+ {
+ result.append(" displayName=\""+displayName+"\"");
+ }
if (onError != null)
{
result.append(" onError=\""+onError+"\"");
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org