pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roger L. Whitcomb" <Roger.Whitc...@ingres.com>
Subject RE: Class loading question
Date Mon, 07 Feb 2011 17:57:51 GMT
Okay, I see what you mean:  I *think* I can get it to work implementing
"Bindable".  I had originally made the object in the BXML file a
"Dialog" which was never getting into my class.  So, I'm trying to read
a "GenericDialog" in the BXML file, which should work as you describe -
I see the code in "readObject" that does the binding up the superclass
chain.  I'm having trouble, though, wrapping my mind around how to get
the BXML code organized....

 

But, I see a problem with just using "bind" (which is what I had in mind
to begin with):  in BXMLSerializer.bind(Object, Class) it calls
"type.getDeclaredFields()" which specifically gets the fields of the
object EXCLUDING inherited fields.  In my case, the object is the
subclass object, but the annotated field is declared in the superclass.
Thus, the field never shows up in the list and is never set.

 

So, if I change this call to "type.getFields()" instead things start
working.  Unfortunately, this has the side-effect that non-public fields
are no longer accessible.  I'm thinking that the code in "bind" could be
changed (maybe at the expense of some speed) to iterate through the
fields in the namespace that have ids and then call either
"type.getDeclaredField()" or if that fails "type.getField()" with the
variable name and check the annotation.  This would then make all
fields, including all public superclass fields accessible....

 

What do you think?

 

Roger Whitcomb | Architect, Engineering | Roger.Whitcomb@ingres.com|
Ingres | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 |
USA
<http://www.google.com/maps?f=q&hl=en&geocode=&q=500+Arguello+Street+%7C
+Suite+200+%7C+Redwood+City+%7C+CA+%7C+94063+%7C+USA+&sll=37.0625,-95.67
7068&sspn=50.557552,73.037109&ie=UTF8&t=h&z=16&iwloc=addr>  | +1
650-587-5596 | fax: +1 650-587-5550

From: Roger L. Whitcomb [mailto:Roger.Whitcomb@ingres.com] 
Sent: Sunday, February 06, 2011 9:10 PM
To: user@pivot.apache.org
Subject: RE: Class loading question

 

When you say "implement Bindable", does that mean the "initialize"
method should do the binding?  Or will it happen just by virtue of
declaring "implements Bindable" and providing a (possibly empty)
"initialize" method?  I tried the latter and the binding still isn't
happening.

 

Roger Whitcomb | Architect, Engineering | Roger.Whitcomb@ingres.com|
Ingres | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 |
USA
<http://www.google.com/maps?f=q&hl=en&geocode=&q=500+Arguello+Street+%7C
+Suite+200+%7C+Redwood+City+%7C+CA+%7C+94063+%7C+USA+&sll=37.0625,-95.67
7068&sspn=50.557552,73.037109&ie=UTF8&t=h&z=16&iwloc=addr>  | +1
650-587-5596 | fax: +1 650-587-5550

From: Greg Brown [mailto:gk_brown@verizon.net] 
Sent: Sunday, February 06, 2011 4:07 PM
To: user@pivot.apache.org
Subject: Re: Class loading question

 

Just checked - if you have your base GenericDialog class implement
Bindable, the annotated values should be bound correctly.

 

On Feb 6, 2011, at 3:57 PM, Greg Brown wrote:

 

If I understand you correctly, you are trying to bind to variables
declared in a base class - is that correct? I thought we had coded
support for that. How are you performing the bind? Are you using the
bind() method or the Bindable interface?

 

On Feb 6, 2011, at 3:12 PM, Roger L. Whitcomb wrote:

 

Okay, I see what you're saying.  So, actually my problem is deeper than
what I thought:

What I'm actually having trouble with (apart from the superficial
question of finding the resources, which I get now) is that I have a
"GenericDialog" class with a bunch of variables, and then a subclass
"DeleteDialog extends GenericDialog".  In the GenericDialog constructor
(called via "super(String)" from DeleteDialog constructor), I want to
load a generic dialog template which has space for a subclass dialog
part (which is named by the "String" parameter).  The problem is that
"this" in the GenericDialog constructor refers to the subclass variable
(as it should), so none of the @BXML annotations within GenericDialog
itself get filled in (because the only object I have is the subclass
object).  Even making the variables "protected" doesn't help.  So, is
there any way to gracefully handle this situation?  Do you need to see
some code to see what I'm trying to do??  Thanks.

 

Roger Whitcomb | Architect, Engineering | Roger.Whitcomb@ingres.com|
Ingres | 500 Arguello Street | Suite 200 | Redwood City | CA | 94063 |
USA
<http://www.google.com/maps?f=q&hl=en&geocode=&q=500+Arguello+Street+%7C
+Suite+200+%7C+Redwood+City+%7C+CA+%7C+94063+%7C+USA+&sll=37.0625,-95.67
7068&sspn=50.557552,73.037109&ie=UTF8&t=h&z=16&iwloc=addr>  | +1
650-587-5596 | fax: +1 650-587-5550

From: Greg Brown [mailto:gk_brown@verizon.net] 
Sent: Friday, February 04, 2011 11:34 PM
To: user@pivot.apache.org
Subject: Re: Class loading question

 

I wish I hadn't introduced that version of BXMLSerializer#readObject().
:-)  It seems to cause more confusion than anything else.

 

Resources in Pivot behave the same as resource bundles in the JDK. If
you use the readObject(URL, Resources) signature rather than
readObject(Class<?>, String) it will probably make more sense. Apologies
for the confusion.

 

G

 

On Feb 4, 2011, at 3:52 PM, Roger L. Whitcomb wrote:





Hi all,

                Let me see if I can even ask this question
intelligently:

-          I've got a package hierarchy where my main program lives in
package "a.b.c".  In this directory I have Main.java, Main.json (with
the resources) and some "g.bxml" files.

-          In this main program I have a helper function that loads an
object from a "bxml" file and binds to whatever object you give it.  It
uses a.b.c.Main as the class and a.b.c.Main for the resources.

-          There is a "Sheet1.java" that loads "sheet1.bxml" (all
residing in "a.b.c" package) and all works fine and the @BXML variables
get set correctly.

-          Now I introduce a "a.b.c.d" package and want to load a
"dialog.bxml" from this directory from "Dialog1.java" (a.b.c.d.Dialog
class) using my same helper function (from a.b.c.Main).  First off,
using a name of "d/dialog.bxml" loads the file fine and I can see it on
screen, BUT none of my @BXML variables inside "a.b.c.d.Dialog" get set,
and I get no errors or exceptions.

-          Fine - I'm thinking it's just a package problem, so I copy
the helper function into Dialog.java and try to use the same resources
from "a.b.c.Main" and it starts giving me "Can't find resource for base
name a.b.c.d.Dialog, locale en_US" messages.  Okay, so I have to move
the resources into there too, which means more initialization, etc.,
etc.

 

So, I guess my question is this:  what is the best way to organize the
markup files and resource file(s) in this package hierarchy?  And what
is the "right" way to use the class names to load resources and send to
the BXMLSerializer so that my annotated variables get set correctly?
Should I always pass the same class name to the serializer (and hence
put the resources and bxml files in the same directory(ies)) as the Java
classes?  If I want to put stuff in a common places (or places) where
should that be?

 

Am I making sense here or is more detail needed?  Thanks much!

 

Roger Whitcomb

Architect, Engineering

Ingres Corporation

roger.whitcomb@ingres.com

 

PHONE +1 650.587.5596

FAX +1 650.587.5550

 

www.ingres.com <http://www.ingres.com/> 

 

This transmission is confidential and intended solely for the use of the
recipient named above. It may contain confidential, proprietary, or
legally privileged information. If you are not the intended recipient,
you are hereby notified that any unauthorized review, use, disclosure or
distribution is strictly prohibited. If you have received this
transmission in error, please contact the sender by reply e-mail and
delete the original transmission and all copies from your system.

 

 

 

 


Mime
View raw message