My first thought was that this problem could be solved by using <wtkx:define>. Then I realized that there is no way to dereference the defined object in a container. Currently the object can only be referenced in an attribute. So there's something missing; a counterpart to <wtkx:define>. I propose <wtkx:ref>. Example:

<wtkx:define>
  <TableView wtkx:id="view">
    ....
  </TableView>
</wtkx:define>

<Panel>
  <PushButton buttonData="Load">
    <action>
      <loadAction:LoadAction table="$view" />
    </action>
  </PushButton>
  <wtkx:ref name="$view"/>
</Panel>

Should be easy to implement. What do you think?

Dirk.

Greg Brown <[email protected]> wrote:

Unfortunately, there is no way to refer to a variable in WTKX before you declare it. Like a script, WTKX is processed linearly. In general, this does not cause a problem because you often want to refer to other page variables in an event handler, which isn't evaluated until after the WTKX document has been completely processed. See this thread for more info (WTKX has been renamed to BXML in Pivot 2.0):

http://mail-archives.apache.org/mod_mbox/pivot-dev/201008.mbox/%[email protected]%3e

As an alternative, you could create a script block at the end of your document that creates the association between the action and the table view. Alternatively, if you use Pivot 2.0, you can use namespace binding to accomplish this:

<loadAction:LoadAction table="${view}"/>

Namespace bindings aren't processed until the entire document has been read.

Greg

On Aug 22, 2010, at 11:20 AM, [email protected] wrote:


Hi

in a TableBox, I have a TableView and a PushButton with an action that populates
the table.
The action needs a reference to the table in order to populate it. My wtkx file
looks like this:

<TableView wtkx:id="view">
....
</TableView>
<PushButton buttonData="Load">
   <action>
     <loadAction:LoadAction table="$view" />
   </action>
</PushButton>
This worked fine. But now, I want the button to be displayed on top of the
table, so I declared it in the wtkx file before the table and now following
exception is thrown:
org.apache.pivot.beans.PropertyNotFoundException: Property "table" does not
exist or is read-only.

I could work around this problem with a custom TableView class, but I 'd like to
know if there is another way to do it ?
Thanks
Anton



Reply via email to