Leonardo Mateo escreveu:
On Thu, Sep 18, 2008 at 12:58 PM, Paulo Scardine <[EMAIL PROTECTED]> wrote:
  
Leo,

The problem is that in _javascript_ I can refer a parameter that points to a
dataset object just like if the dataset was declared inside current class,
but the notation "local:datasetname:/path" does not work.

<class name="myclass">
  <attribute name="remoteds"/>
  <dataset name="localds"/>
  <view datapath="local:remoteds:/path"/><!-- Do not work... -->
  <view datapath="local:localds:/path"/>
  <method name="init">
    Debug.write(remoteds); // This works!
    Debug.write(localds);
    super.init();
  </method>
</class>

I think  in this case the compiler do some search for "datasetname" in the
subnode list of the given object, but don't look at the attribute list for
dataset references with the same name.

I think it wold be nice if it searched in the attribute list also, because
we could just point so some dataset without worrying about the relative path
to the given dataset, which leads to better abstraction.
    

I don't know how this works internally, I'm pretty new to OL, but I've
been having certain issues with datasets, thy're not as intuitive as I
thought but, what I've found is that datasets are handled globally, no
matter where you define them, under the hash canvas.datasets['dsName']
and datasets shouldn't be declared inside a class or as a class
attribute.
  
Leo,

You are right, as any dataset instantiated will include an entry in "canvas.datasets" object. You are also correct about datasets declared in the canvas being global to the whole application.

However, you may find useful the fact that you can refer to a locally declared dataset preceding the datapath declaration with "local:", for example:

<canvas>

<view name="outerview">
  <dataset name="localds"/>
  <view name="siblingview" datapath="local:parent.localds:/root/path"><!-- this works -->
    <dataset name="localds"/>
  </view>
  <view name="anothersiblingview" datapath="local:this.localds:/root/path">
    <!-- this issues WARNING: local dataset "[this, localds]" not found in .anothersiblingview  -->
    <dataset name="localds"/>
  </view>
  <view name="innerview1" datapath="local:parent.localds:/root/path" /><!-- this works... -->
  <view name="innerview2" datapath="local:parent.siblingview.localds:/root/path" /><!-- this also works... -->
</view>

</canvas>

In the debugger, a line like "for(i in canvas.datasets) { Debug.write(i, canvas.datasets[i], canvas.datasets[i].parent.name); }" will show 3 entries:

__U28.localds «lz.dataset#9| <localds/>» anothersiblingview
__U22.localds «lz.dataset#30| <localds/>» siblingview
__U18.localds «lz.dataset#31| <localds/>» outerview

It is nice to have local datasets, because you dont have to worry about name clash issues, but this holds the inconvenience that you need to know the relative path (parent.parent.this.those) for the given dataset beforehand.

Thanks,
--
Paulo Scardine


Anyway, this is just my short experience on OL and don't know what the
theory says...

  

Reply via email to