pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karel Hübl <karel.h...@gemsystem.cz>
Subject RE: in java how can i reference the instance define in a nested bxml's "bxml:id..."
Date Wed, 29 Jan 2014 10:29:17 GMT
Hi Mark,

I checked your code and found following problems:

1) Your MyView class is window. Window may not have multiple child
components. So I moved your subviews to BoxPane, which is only child of your
main Window.
2) Your subviews were also MyView instances - so you build some kind of
recursion which I think was not your intent. So I changed your subviews to
3) The getNamedComponent does not traverse the whole component hierarchy. It
tries to look up only for child component with specified name (not childeren
of child components). So you need to split the lookup into multiple
getNamedComponent calls:
	Container boxPane=(Container)getNamedComponent("boxPane");
	Container subview1=(Container)boxPane.getNamedComponent("subview1");
	Form myForm=(Form)subview1.getNamedComponent("loginForm");

Anyway the fixed code is not very transparent in my opinion. The
bxml:include is suitable to partition large content into multiple parts for
better maintability. I would consider building reusable components using
java classes extending standard pivot containers. 

Find fixed code in attachment. I added myComponent package, where You can
see sample impementation of reusable component as I proposed...

Regards Karel

-----Original Message-----
From: Mark R. Chambers [mailto:mark@mrchambers.org] 
Sent: Monday, January 27, 2014 10:04 PM
To: user@pivot.apache.org
Subject: RE: in java how can i reference the instance define in a nested
bxml's "bxml:id..."

Hi Karel,

I have tried it out, but am having trouble passing a variable into it.
I have modified your example here, to just add and additional username and
password field below the previous one.
In this example the username and login is the generic component that I want
to repeat and get access to...
It seems to work for the first name set, but not the second one... might
need to set the javascript higher up... maybe declaring the var twice causes
a problem?

Any ideas? 

-----Original Message-----
From: Roger L. Whitcomb [mailto:Roger.Whitcomb@actian.com]
Sent: Friday, 24 January 2014 3:40 AM
To: user@pivot.apache.org
Subject: RE: in java how can i reference the instance define in a nested
bxml's "bxml:id..."

So, after digging into this some more, I begin to see what you mean.  If you
don't use "inline='true'" on your "bxml:include" then there is no way
(directly) to get access to the included file's serializer, and thus its
namespace.  If you use "inline" (of course) then you have the possibility of
name collisions.

One possible solution to this is to use a custom subclass of BXMLSerializer
(that you would have to register using
BXMLSerializer.getMimeTypes().put("bxml", your new Serializer class)) that
would do something different with the namespace map.  The difficulty would
be associating the namespace of the included file with the main file's
namespace, since there is no connection (currently).

It definitely does seem like we *should* be able to deal with this situation
more gracefully, but I'm at somewhat of a loss right now what to suggest.
Perhaps we could make a change, and pass some more information to an
"include"d serializer that would tell it to put its variables into the
parent's namespace as something like the bxml:id of the include element
followed by ":" and the id.  Then for multiple levels of nesting you would
get "a:b:c", and etc.  How that would work with the variable bindings,
(i.e., using "serializer.bind(...)") I don't know.

Anyone else have thoughts?  *Perhaps* there is some way, as Karel is
suggesting, of using namespace binding, but I'm not seeing that either.  Of
course, making a Pivot change like this isn't likely to help with your

So, I guess my best suggestion at this point is to make wise choices about
how you split up your BXML files, and how the "include" structure works, so
that you don't have to do cross-file referencing.  And/or make judicious use
of "inline='true'" to put the included variables into the main file's

Anybody else see something I'm not seeing?


-----Original Message-----
From: Roger L. Whitcomb [mailto:Roger.Whitcomb@actian.com]
Sent: Thursday, January 23, 2014 10:08 AM
To: user@pivot.apache.org
Subject: RE: in java how can i reference the instance define in a nested
bxml's "bxml:id..."

Hi Mark,
	I assume you've read through the BXML Primer here:
http://pivot.apache.org/tutorials/bxml-primer.html  It describes how
namespaces work and the "bxml:include" semantics (including the "inline"
attribute).  But, I think that the default behavior of making a separate
namespace for each included BXML file would satisfy your requirements,
unless I don't understand what you're trying to do.

Let us know,

-----Original Message-----
From: Ripgiblet [mailto:mark@mrchambers.org]
Sent: Thursday, January 23, 2014 3:12 AM
To: user@pivot.apache.org
Subject: RE: in java how can i reference the instance define in a nested
bxml's "bxml:id..."

Hi Karel,

Thanks for the response, seemed like what I needed, but I cant seem to get
it too work...
Bit of a deadline on this, later I will try compiling your code and check it
works... I must be missing something...


View this message in context:
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

View raw message