You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by ad...@free.fr on 2010/08/22 17:20:25 UTC

Object dereference problem

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

Re: Object dereference problem

Posted by Greg Brown <gk...@mac.com>.
> "value" sounds like "copy-by-value" to me, suggesting that a copy of the object would be made, which is clearly wrong.

It is true that the result of dereferencing the variable is a reference, but:

a) Everything in BXML is a reference type (not to mention that Java doesn't even support true value types), so that distinction is not really relevant.

b) A Java reference is also a value - the value is a pointer.

So I think "value" is more appropriate, because the element will be replaced by the value referred to by the variable name. Under the hood, that value will be a reference, but again, that's not really relevant to the caller. The caller is simply interested in getting the value of the variable.

G


Re: Object dereference problem

Posted by Dirk Möbius <dm...@scoop-gmbh.de>.
> I prefer the term "value" to "ref". "ref" implies that the tag  
> represents a reference, whereas what it actually represents is the  
> value pointed to by a reference. "deref" might be more accurate, but  
> not very intuitive.  :-)

I'd prefer "ref".

"value" sounds like "copy-by-value" to me, suggesting that a copy of  
the object would be made, which is clearly wrong.

Note that Spring uses <ref> for this, too.

Dirk.



Re: Object dereference problem

Posted by Greg Brown <gk...@mac.com>.
> 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>.

I had a similar thought. This feature is currently being tracked in PIVOT-556:

https://issues.apache.org/jira/browse/PIVOT-556

I prefer the term "value" to "ref". "ref" implies that the tag represents a reference, whereas what it actually represents is the value pointed to by a reference. "deref" might be more accurate, but not very intuitive.  :-)



Re: Object dereference problem

Posted by Dirk Möbius <dm...@scoop-gmbh.de>.
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 <gk...@mac.com> 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/%3c11FA9F00-043E-4C7F-A54F-0FA609CF5272@mac.com%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, adsantos@free.fr 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




Re: Object dereference problem

Posted by Greg Brown <gk...@mac.com>.
> Regarding Pivot 2.0, is it already available? I didn't find any download link on
> the web site.

No, Pivot 2.0 is currently in development. You can see the current state of the project in the trunk branch in SVN.


Re: Object dereference problem

Posted by ad...@free.fr.
Thanks for our advices,
I used a script, and my code looks like this:
  <PushButton buttonData="Load">
    <action>
      <loadAction:LoadAction wtkx:id="action" />
    </action>
  </PushButton>
  <TableView wtkx:id="view">
  ....
  </TableView>
  <wtkx:script>
    importClass(myPackage.LoadAction);
    action.setTable(view);
  </wtkx:script>

Regarding Pivot 2.0, is it already available? I didn't find any download link on
the web site.

Regards
Anton

Re: Object dereference problem

Posted by Greg Brown <gk...@mac.com>.
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/%3c11FA9F00-043E-4C7F-A54F-0FA609CF5272@mac.com%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, adsantos@free.fr 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