[Opensource] What is the difference between getValues and getValidValues

Ivan Ivanov rambiusparkisanius at yahoo.com
Wed Apr 7 23:56:01 PDT 2004


Sorry that I send this again but obviuosly it was not
noticed.

Thanks Ivan
--- Ivan Ivanov <rambiusparkisanius at yahoo.com> 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";
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business $15K Web Design Giveaway 
> http://promotions.yahoo.com/design_giveaway/
> 
> _______________________________________________
> Opensource mailing list
> Opensource at jcorporate.com
>
http://mailman.jcorporate.com/mailman/listinfo/opensource


__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/



More information about the Opensource mailing list