[cvs] eforum commit by ppilgrim: Latest updates
JCorporate Ltd
jcorp at jcorp2.servlets.net
Thu Dec 2 18:35:51 PST 2004
Log Message:
-----------
Latest updates
Modified Files:
--------------
eforum/src/WEB-INF/src/com/jcorporate/eforum/dbobj:
ForumOptions.java
eforum/src/WEB-INF/src/com/jcorporate/eforum/controller:
Personalise.java
Revision Data
-------------
Index: ForumOptions.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/eforum/src/WEB-INF/src/com/jcorporate/eforum/dbobj/ForumOptions.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -Lsrc/WEB-INF/src/com/jcorporate/eforum/dbobj/ForumOptions.java -Lsrc/WEB-INF/src/com/jcorporate/eforum/dbobj/ForumOptions.java -u -r1.4 -r1.5
--- src/WEB-INF/src/com/jcorporate/eforum/dbobj/ForumOptions.java
+++ src/WEB-INF/src/com/jcorporate/eforum/dbobj/ForumOptions.java
@@ -1,11 +1,14 @@
package com.jcorporate.eforum.dbobj;
+import java.util.Vector;
+
import org.apache.log4j.Logger;
import com.jcorporate.expresso.core.dataobjects.DataObjectMetaData;
import com.jcorporate.expresso.core.db.DBException;
import com.jcorporate.expresso.core.dbobj.RequestContext;
import com.jcorporate.expresso.core.dbobj.SecuredDBObject;
+import com.jcorporate.expresso.core.dbobj.ValidValue;
import com.jcorporate.expresso.core.misc.StringUtil;
/**
@@ -32,7 +35,7 @@
/** Data field name constant */
public static final String FLD_MSG_HEIGHT = "MessageHeight";
/** Data field name constant */
- public static final String FLD_IDENT_REPLIES = "IdentReplies";
+ public static final String FLD_INDENT_REPLIES = "IndentReplies";
/** Data field name constant */
public static final String FLD_USE_SIGNATURE = "UseSignature";
/** Data field name constant */
@@ -87,8 +90,8 @@
* @throws DBException
*/
public synchronized void add() throws DBException {
- checkDefaultValueIntegrity();
- super.add();
+ checkDefaultValueIntegrity();
+ super.add();
}
@@ -97,26 +100,25 @@
* @see com.jcorporate.expresso.core.dbobj.SecuredDBObject#setupFields
* @throws DBException
*/
- protected void checkDefaultValueIntegrity() throws DBException
+ public void checkDefaultValueIntegrity() throws DBException
{
- // Retrieve all the field names
- DataObjectMetaData metaData = getMetaData();
- String fieldNames[] = metaData.getFields();
-
- for (int k = 0; k < fieldNames.length; ++k) {
- // For all field names which are not keys
- if (!metaData.getFieldMetadata(fieldNames[k]).isKey() ) {
- // Check if this field value is empty or not.
- if ( StringUtil.isBlankOrNull( getField(fieldNames[k]) )) {
- // This field is empty. Attempt to use the default value if possible.
- String defval = metaData.getDefaultValue( fieldNames[k] );
- if ( defval != null )
- setField( fieldNames[k] , defval );
- }
- }
- }
+ // Retrieve all the field names
+ DataObjectMetaData metaData = getMetaData();
+ String fieldNames[] = metaData.getFields();
+
+ for (int k = 0; k < fieldNames.length; ++k) {
+ // For all field names which are not keys
+ if (!metaData.getFieldMetadata(fieldNames[k]).isKey() ) {
+ // Check if this field value is empty or not.
+ if ( StringUtil.isBlankOrNull( getField(fieldNames[k]) )) {
+ // This field is empty. Attempt to use the default value if possible.
+ String defval = metaData.getDefaultValue( fieldNames[k] );
+ if ( defval != null )
+ setField( fieldNames[k] , defval );
+ }
+ }
+ }
}
-
/**
* Define meta data for this data object
@@ -136,7 +138,7 @@
addField(FLD_UID, "int", 0, false, "FN_User");
addField(FLD_MSG_WIDTH, "int", 0, false, "FN_MsgWidth");
addField(FLD_MSG_HEIGHT, "int", 0, false, "FN_MsgHeight");
- addField(FLD_IDENT_REPLIES, "boolean", 0, true, "FN_IdentReplies");
+ addField(FLD_INDENT_REPLIES, "boolean", 0, true, "FN_IdentReplies");
addField(FLD_USE_SIGNATURE, "boolean", 0, true, "FN_UseSignature");
addField(FLD_WORD_WRAP_LENGTH, "int", 0, true, "FN_WordWrapLength");
addField(FLD_AUTO_WRAP_MSG, "boolean", 0, true, "FN_AutoWrapMsg");
@@ -147,33 +149,33 @@
// addField(FLD_, "int", 0, false, "FN_");
- // Define the primary key fields
+ // Define the primary key fields
addKey(FLD_UID);
- // Set up default values for a subscriber
- setDefaultValue( FLD_MSG_WIDTH, "64" );
- setDefaultValue( FLD_MSG_HEIGHT, "24" );
- setDefaultValue( FLD_IDENT_REPLIES, "true" );
- setDefaultValue( FLD_USE_SIGNATURE, "false" );
- setDefaultValue( FLD_WORD_WRAP_LENGTH, "80" );
- setDefaultValue( FLD_AUTO_WRAP_MSG, "false" );
- setDefaultValue( FLD_AUTO_WRAP_REPLIES, "false" );
- setDefaultValue( FLD_DISPLAY_VARIABLE, "true" );
-
- // Here follows an real example of automatic look up of
- // enumerated values pertaining to a database column. In
- // Expresso Framework we specify the column only accepts
- // enumerated values. In order to use the automatic lookup
- // facility FRAMEWORK MANAGED RELATIONSHIP, declare the column
- // with a lookup meta data. In the target data objects declare
- // a `getValues()' that returns an Vector collection of the
- // enumerated valid values.
+ // Set up default values for a subscriber
+ setDefaultValue( FLD_MSG_WIDTH, "64" );
+ setDefaultValue( FLD_MSG_HEIGHT, "24" );
+ setDefaultValue( FLD_INDENT_REPLIES, "true" );
+ setDefaultValue( FLD_USE_SIGNATURE, "false" );
+ setDefaultValue( FLD_WORD_WRAP_LENGTH, "80" );
+ setDefaultValue( FLD_AUTO_WRAP_MSG, "false" );
+ setDefaultValue( FLD_AUTO_WRAP_REPLIES, "false" );
+ setDefaultValue( FLD_DISPLAY_VARIABLE, "true" );
+
+ // Here follows an real example of automatic look up of
+ // enumerated values pertaining to a database column. In
+ // Expresso Framework we specify the column only accepts
+ // enumerated values. In order to use the automatic lookup
+ // facility FRAMEWORK MANAGED RELATIONSHIP, declare the column
+ // with a lookup meta data. In the target data objects declare
+ // a `getValues()' that returns an Vector collection of the
+ // enumerated valid values.
- // Define Multiple Values fields
+ // Define Multiple Values fields
setMultiValued(FLD_VAR_TEXT_FONT_ID);
setMultiValued(FLD_MONO_TEXT_FONT_ID);
- // Define lookup fields
+ // Define lookup fields
setLookupObject(FLD_VAR_TEXT_FONT_ID, ForumVarTextDef.class.getName() );
setLookupObject(FLD_MONO_TEXT_FONT_ID, ForumMonoTextDef.class.getName() );
@@ -185,36 +187,61 @@
*/
public synchronized void populateDefaultValues() throws DBException
{
- // To avoid foreign key invalidations, make sure
- // personalisation object are initialised first
- ForumMonoTextDef monoTextDef = new ForumMonoTextDef();
- monoTextDef.setDataContext(getDataContext());
- monoTextDef.populateDefaultValues();
-
- ForumVarTextDef varTextDef = new ForumVarTextDef();
- varTextDef.setDataContext(getDataContext());
- varTextDef.populateDefaultValues();
-
- ForumOptions forumOption = new ForumOptions();
- forumOption.setDataContext(getDataContext());
-
-
- // Set up personalisation row for the Expresso Administrator
- forumOption.setField( FLD_UID, 3 /* FIXME: SysAdmin*/ );
- forumOption.setField( FLD_MSG_WIDTH, "64" );
- forumOption.setField( FLD_MSG_HEIGHT, "24" );
- forumOption.setField( FLD_IDENT_REPLIES, true );
- forumOption.setField( FLD_USE_SIGNATURE, true );
- forumOption.setField( FLD_WORD_WRAP_LENGTH, "80" );
- forumOption.setField( FLD_AUTO_WRAP_MSG, "false" );
- forumOption.setField( FLD_AUTO_WRAP_REPLIES, "false" );
- forumOption.setField( FLD_DISPLAY_VARIABLE, "true" );
+ // To avoid foreign key invalidations, make sure
+ // personalisation object are initialised first
+ ForumMonoTextDef monoTextDef = new ForumMonoTextDef();
+ monoTextDef.setDataContext(getDataContext());
+ monoTextDef.populateDefaultValues();
+
+ ForumVarTextDef varTextDef = new ForumVarTextDef();
+ varTextDef.setDataContext(getDataContext());
+ varTextDef.populateDefaultValues();
+
+ ForumOptions forumOption = new ForumOptions();
+ forumOption.setDataContext(getDataContext());
+
+ // Set up personalisation row for the Expresso Administrator
+ forumOption.setField( FLD_UID, 3 /* FIXME: SysAdmin*/ );
+ forumOption.setField( FLD_MSG_WIDTH, "64" );
+ forumOption.setField( FLD_MSG_HEIGHT, "24" );
+ forumOption.setField( FLD_INDENT_REPLIES, true );
+ forumOption.setField( FLD_USE_SIGNATURE, true );
+ forumOption.setField( FLD_WORD_WRAP_LENGTH, "80" );
+ forumOption.setField( FLD_AUTO_WRAP_MSG, "false" );
+ forumOption.setField( FLD_AUTO_WRAP_REPLIES, "false" );
+ forumOption.setField( FLD_DISPLAY_VARIABLE, "true" );
forumOption.setField( FLD_VAR_TEXT_FONT_ID, 1 );
forumOption.setField( FLD_MONO_TEXT_FONT_ID, 1 );
- forumOption.addIfNeeded();
+ forumOption.addIfNeeded();
+ }
+
+ /**
+ * Define multiple selection for boolean fields in the
+ * forum options data object
+ *
+ * @param fieldName the field name
+ * @return the valid vlaue
+ * @throws DBException
+ * @see com.jcorporate.expresso.core.dbobj.DBObject#getValidValues(java.lang.String)
+ */
+ public Vector getValidValues(String fieldName)
+ throws DBException
+ {
+ if ( fieldName.equals( FLD_INDENT_REPLIES ) ||
+ fieldName.equals( FLD_USE_SIGNATURE ) ||
+ fieldName.equals( FLD_AUTO_WRAP_MSG ) ||
+ fieldName.equals( FLD_AUTO_WRAP_REPLIES ) ||
+ fieldName.equals( FLD_DISPLAY_VARIABLE ) ) {
+ Vector myValues = new Vector();
+ myValues.addElement(new ValidValue("true", "Yes"));
+ myValues.addElement(new ValidValue("false", "No"));
+ return myValues;
+ }
+ return super.getValidValues(fieldName);
}
+
}
// End
Index: Personalise.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/eforum/src/WEB-INF/src/com/jcorporate/eforum/controller/Personalise.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lsrc/WEB-INF/src/com/jcorporate/eforum/controller/Personalise.java -Lsrc/WEB-INF/src/com/jcorporate/eforum/controller/Personalise.java -u -r1.2 -r1.3
--- src/WEB-INF/src/com/jcorporate/eforum/controller/Personalise.java
+++ src/WEB-INF/src/com/jcorporate/eforum/controller/Personalise.java
@@ -3,6 +3,7 @@
*/
package com.jcorporate.eforum.controller;
+import java.util.*;
import org.apache.log4j.Logger;
import com.jcorporate.eforum.dbobj.ForumOptions;
@@ -95,6 +96,7 @@
addState(processEditOption);
}
+
/**
* State method:
* Generates the WUI option form to allow the subscriber to
@@ -229,8 +231,8 @@
oneInput = new Input("signature");
oneInput.setType( Input.ATTRIBUTE_TEXTAREA );
- oneInput.setMaxLength(80);
- oneInput.setDisplayLength( 8 );
+ oneInput.setAttribute( "cols", "80" );
+ oneInput.setAttribute( "rows", "8" );
oneInput.setLabel("signature");
oneInput.setDefaultValue( sign.getField( ForumSignature.FLD_SIGNATURE_TEXT ));
optionsBlock.add(oneInput);
More information about the cvs
mailing list