[Opensource] What is the difference between getValues
and getValidValues
Peter A. Pilgrim
peterp at xenonsoft.demon.co.uk
Fri Apr 9 19:36:57 PDT 2004
Ivan Ivanov wrote:
> Hi friends,
>
> Can you please give more explanantions about
> DBObject.getValues and DBObject.getValidValues?
> I spent some time dealing with multivalued fields and
> their lookup objects and I feel I am missing
> something. My situation is the same as
> Employee-Department example in edg (in fact I write my
> code guided by this example):
>
> public MyDBobject extends SecuredDBObject {
> ...
> public void setupFields() throws DBException {
> addField("ID", "auto-inc", 0, false, "The id
> ");
> addField("NAME_ID", "integer", 0, false, "The
> name");
> addKey("ID");
> setMultiValued("NAME_ID");
>
> setLookupObject("com.mypackage.dbobject.MyLookupDBObject");
> }
> }
>
> and MyLookupDBObject looks like:
>
> public MyLookupDBObject extends SecuredDBObject {
>
> public void setupFields() throws DBException {
> addField("NAME_ID", "auto_inc", 0, false, "The
> name id");
> addField("VALUE", "varchar", 255, false, "The
> value of the name");
> addKey("NAME_ID");
> }
>
> public Vector getValidValues(String fieldName)
> throws DBException {
> if (fieldName.equals("NAME_ID")) {
> return getValuesDefault("NAME_ID",
> "VALUE");
> }
> return super.getValidValues(fieldName);
> }
> }
>
> when I run this piece of code with DBMaint
> http://localhost:8080/myproject/DBMaint.do?&dbobj=com.mypackage.dbobject.MyDBObject&state=Add
> expecting to see a nice combo box with values for
> NAME_ID, I receive this error
> This object: com.mypackage.dbobject.MyLookupObject
> does not have valid values defined
> and the stack trace.
>
> However, when I remove getValidValues() method from
> MyLookupObject and add method getValues():
> public Vector getValues() throws DBException {
> Vector values = getValuesDefault("NAME_ID",
> "VALUE");
> return values;
> }
>
> everything goes just fine and DBMaint shows the combo
> box.
>
> So why getValues() work and getValidValues() (as shown
> in edg) not?
>
> Thank you very much in advance
> Ivan Ivanov
>
> P.S. I spotted two minor mistakes in expresso docs
> (they are still in CVS):
> 1) in expresso/doc/intro/caching.html in the sentence
> "The actual class that controls the caching is called
> the CacheManger and call be found in the expresso tree
> underunder expresso/core/cache/CacheManager" under is
> spelled twice
> 2) in Chapter 5. Database Objects in the following
> code:
> public Vector getValidValues(String fieldName)
> throws DBException {
>
> if (fieldName.equals("Dept_Id")) {
> Vector myValue = this.getValuesDefault(
> "Dept_Id", "Dept_Name" );
> return myValues;
> }
> return super.getValidValues(fieldName);
> }
>
> instead of "return myValues" should be "return myValue";
>
The look up example in the EDG is wrong. I have added an addition
to the CVS about one week and half a go.
The method should be:
public Vector getValidValues()
throws DBException {
Vector myValue = this.getValuesDefault(
"Dept_Id", "Dept_Name" );
return myValues;
}
The getValue() returns the look up for DEPARTMENT table.
--
Peter Pilgrim
__ _____ _____ _____
/ //__ // ___// ___/ + Serverside Java
/ /___/ // /__ / /__ + Struts
/ // ___// ___// ___/ + Expresso Committer
__/ // /__ / /__ / /__ + Independent Contractor
/___//____//____//____/ + Intrinsic Motivation
On Line Resume
||
\\===> `` http://www.xenonsoft.demon.co.uk/no-it-striker.html ''
More information about the Opensource
mailing list