cem sonmez | 6 Jul 2009 21:44
Picon

how to classes as dynamic names

Hi
I have a class named "pul" and i have created some instances like that :
<pul name="pul1" /><pul name="pul2" /><pul name="pul3" /><pul name="pul4" />

in a method, i want to use these objects whose names should be specified with the i variable in a for expression

i.e. :

for (var i=0; i<4; i++) {
var temp= i+1;
  'pul'+(temp.toString()).

setPulPosition(x,y);
}

But with this use, it is incorrect. Bec. 'pul'+(temp.toString()) is a String and i need "pul" object to use the appropriate method, i know the problem but i i have no idea how to do that.

Any idea?
Best regards.


--
Cem SONMEZ
Marco Lettere | 7 Jul 2009 09:08

Re: how to classes as dynamic names

try with eval('pul1') ...
M.

cem sonmez ha scritto:
> Hi
> I have a class named "pul" and i have created some instances like that :
> <pul name="pul1" /><pul name="pul2" /><pul name="pul3" /><pul
> name="pul4" />
>
> in a method, i want to use these objects whose names should be
> specified with the i variable in a for expression
>
> i.e. :
>
> for (var i=0; i<4; i++) {
> var temp= i+1;
>   'pul'+(temp.toString()).
> setPulPosition(x,y);
> }
>
> But with this use, it is incorrect. Bec. 'pul'+(temp.toString()) is a
> String and i need "pul" object to use the appropriate method, i know
> the problem but i i have no idea how to do that.
>
> Any idea?
> Best regards.
>
>
> -- 
> Cem SONMEZ

--

-- 
DcorE

P T Withington | 7 Jul 2009 14:29
Picon
Favicon
Gravatar

Re: how to classes as dynamic names

Named views will show up as attributes of their parent. The correct  
way to reference an attribute with a computed name in Javascript is to  
use the [] operator.  If your code below is in a method in the parent  
view you would say:

  this['pul'+(temp.toString())].setPulPosition(x,y);

(You don't actually need the toString, since + on a String and a  
Number will coerce the number to a string automatically.)

In JavaScript,
  foo.bar
and
  foo['bar']
are the same, except in the second case you could also say
  foo['b'+'a'+'r']
You can use any expression to calculate the name of the attribute.

On Jul 6, 2009, at 15:44, cem sonmez <cemosonmez@...> wrote:

> Hi
> I have a class named "pul" and i have created some instances like  
> that :
> <pul name="pul1" /><pul name="pul2" /><pul name="pul3" /><pul  
> name="pul4" />
>
> in a method, i want to use these objects whose names should be  
> specified with the i variable in a for expression
>
> i.e. :
>
> for (var i=0; i<4; i++) {
> var temp= i+1;
>   'pul'+(temp.toString()).
> setPulPosition(x,y);
> }
>
> But with this use, it is incorrect. Bec. 'pul'+(temp.toString()) is  
> a String and i need "pul" object to use the appropriate method, i  
> know the problem but i i have no idea how to do that.
>
> Any idea?
> Best regards.
>
>
> -- 
> Cem SONMEZ

Chen Ding | 10 Jul 2009 01:41
Picon

How to upload files in OpenLaszlo?

Hi There, 


I am wondering whether we can do the file upload in OpenLaszlo. If yes, can someone point where I should look at or where the references are. 

Thanks!

Chen Ding
Henry Minsky | 10 Jul 2009 02:12

Re: How to upload files in OpenLaszlo?

There were some examples in lps/components/incubator/uploader

but I haven't tried any of them for a long time...


On Thu, Jul 9, 2009 at 7:41 PM, Chen Ding <chending0602-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hi There, 

I am wondering whether we can do the file upload in OpenLaszlo. If yes, can someone point where I should look at or where the references are. 

Thanks!

Chen Ding



--
Henry Minsky
Software Architect
hminsky <at> laszlosystems.com


Chen Ding | 10 Jul 2009 03:30
Picon

Re: How to upload files in OpenLaszlo?

Henry,


Thanks for the help. The examples worked very well!

Chen Ding

On Fri, Jul 10, 2009 at 8:12 AM, Henry Minsky <hminsky-oDN+GTs16Eu/3pe1ocb+swC/G2K4zDHf@public.gmane.org> wrote:
There were some examples in lps/components/incubator/uploader

but I haven't tried any of them for a long time...


On Thu, Jul 9, 2009 at 7:41 PM, Chen Ding <chending0602-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hi There, 

I am wondering whether we can do the file upload in OpenLaszlo. If yes, can someone point where I should look at or where the references are. 

Thanks!

Chen Ding



--
Henry Minsky
Software Architect
hminsky-oDN+GTs16Eu/3pe1ocb+swC/G2K4zDHf@public.gmane.org



Sarah Allen | 13 Jul 2009 03:56
Favicon

updating dataset data

Andre,

Thanks for the tip on: http://jira.openlaszlo.org/jira/browse/LPP-8323

As long as you don't update the underlying datasource, any new  
replication won't preserve the previously entered text (except for  
pooling replication, just as you described). So in your case, you need  
to call "datapath.updateData()" for every "onvalue" / "onblur" / ...  
event on your edittext.

In reference to my comment:
 > // there must be a better way...
 > dsSurvey.data[1].appendChild(newNode);
---
Some alternatives:
- dsSurvey.getFirstChild().getNextSibling().appendChild(...)
- dsSurvey.getLastChild().appendChild(...)
- dsSurvey.getPointer().xpathQuery("/children[1]").appendChild(...)

I was looking for a way to add a note based on the relative datapath  
of the view, but couldn't figure out what suntax would do that (rather  
than using the global reference to the dataset "dsSurvey" in this case)

Thanks,
Sarah

p.s. cc'ing laszlo-user in case anyone else wants to chime in and  
since the answer might be interesting to others

André Bargull | 13 Jul 2009 18:46

Re: updating dataset data

Let's say you've got a datapath named "dp", then you can access the 
dataset for "dp" either by calling "dp.getDataset()" or by using the 
xpath-query "dp.xpathQuery('/')". In both cases you don't need to use a 
direct reference to the dataset in your code.
Is it this what you are looking for?

- André

On 7/13/2009 3:38 AM, Sarah Allen wrote:
> Andre,
> 
> Thanks for the tip on: http://jira.openlaszlo.org/jira/browse/LPP-8323
> 
> As long as you don't update the underlying datasource, any new 
> replication won't preserve the previously entered text (except for 
> pooling replication, just as you described). So in your case, you need 
> to call "datapath.updateData()" for every "onvalue" / "onblur" / ... 
> event on your edittext.
> 
> In reference to my comment:
>  > // there must be a better way...
>  > dsSurvey.data[1].appendChild(newNode);
> ---
> Some alternatives:
> - dsSurvey.getFirstChild().getNextSibling().appendChild(...)
> - dsSurvey.getLastChild().appendChild(...)
> - dsSurvey.getPointer().xpathQuery("/children[1]").appendChild(...)
> 
> I was looking for a way to add a note based on the relative datapath of 
> the view, but couldn't figure out what suntax would do that (rather than 
> using the global reference to the dataset "dsSurvey" in this case)
> 
> Thanks,
> Sarah
> 
> p.s. cc'ing laszlo-user in case anyone else wants to chime in and since 
> the answer might be interesting to others
> 

Sarah Allen | 13 Jul 2009 21:37
Favicon

Re: updating dataset data

get, although I was hoping for this.datapath.appendChild(...), so the  
class would work no matter where its datapath referred to in the XML  
node hierarchy

On Jul 13, 2009, at 9:46 AM, André Bargull wrote:

> Let's say you've got a datapath named "dp", then you can access the  
> dataset for "dp" either by calling "dp.getDataset()" or by using the  
> xpath-query "dp.xpathQuery('/')". In both cases you don't need to  
> use a direct reference to the dataset in your code.
> Is it this what you are looking for?
>
>
> - André
>
>
> On 7/13/2009 3:38 AM, Sarah Allen wrote:
>> Andre,
>> Thanks for the tip on: http://jira.openlaszlo.org/jira/browse/ 
>> LPP-8323
>> As long as you don't update the underlying datasource, any new  
>> replication won't preserve the previously entered text (except for  
>> pooling replication, just as you described). So in your case, you  
>> need to call "datapath.updateData()" for every "onvalue" /  
>> "onblur" / ... event on your edittext.
>> In reference to my comment:
>> > // there must be a better way...
>> > dsSurvey.data[1].appendChild(newNode);
>> ---
>> Some alternatives:
>> - dsSurvey.getFirstChild().getNextSibling().appendChild(...)
>> - dsSurvey.getLastChild().appendChild(...)
>> - dsSurvey.getPointer().xpathQuery("/children[1]").appendChild(...)
>> I was looking for a way to add a note based on the relative  
>> datapath of the view, but couldn't figure out what suntax would do  
>> that (rather than using the global reference to the dataset  
>> "dsSurvey" in this case)
>> Thanks,
>> Sarah
>> p.s. cc'ing laszlo-user in case anyone else wants to chime in and  
>> since the answer might be interesting to others

André Bargull | 13 Jul 2009 22:27

Re: updating dataset data

Hmm, if you need to add a new node, you can use "addNode(..)" [1] or 
access the data-node the datapath is pointing to [2] and then call 
"appendNode(..)" => this.datapath.p.appendChild(...)

[1] 
http://www.openlaszlo.org/lps4.3/docs/reference/lz.datapointer.html#LzDatapointer.prototype.addNode
[2] 
http://www.openlaszlo.org/lps4.3/docs/reference/lz.datapointer.html#LzDatapointer.__ivars__.p

On 7/13/2009 9:37 PM, Sarah Allen wrote:
> get, although I was hoping for this.datapath.appendChild(...), so the 
> class would work no matter where its datapath referred to in the XML 
> node hierarchy
> 
> On Jul 13, 2009, at 9:46 AM, André Bargull wrote:
> 
>> Let's say you've got a datapath named "dp", then you can access the 
>> dataset for "dp" either by calling "dp.getDataset()" or by using the 
>> xpath-query "dp.xpathQuery('/')". In both cases you don't need to use 
>> a direct reference to the dataset in your code.
>> Is it this what you are looking for?
>>
>>
>> - André
>>
>>
>> On 7/13/2009 3:38 AM, Sarah Allen wrote:
>>> Andre,
>>> Thanks for the tip on: http://jira.openlaszlo.org/jira/browse/LPP-8323
>>> As long as you don't update the underlying datasource, any new 
>>> replication won't preserve the previously entered text (except for 
>>> pooling replication, just as you described). So in your case, you 
>>> need to call "datapath.updateData()" for every "onvalue" / "onblur" / 
>>> ... event on your edittext.
>>> In reference to my comment:
>>> > // there must be a better way...
>>> > dsSurvey.data[1].appendChild(newNode);
>>> ---
>>> Some alternatives:
>>> - dsSurvey.getFirstChild().getNextSibling().appendChild(...)
>>> - dsSurvey.getLastChild().appendChild(...)
>>> - dsSurvey.getPointer().xpathQuery("/children[1]").appendChild(...)
>>> I was looking for a way to add a note based on the relative datapath 
>>> of the view, but couldn't figure out what suntax would do that 
>>> (rather than using the global reference to the dataset "dsSurvey" in 
>>> this case)
>>> Thanks,
>>> Sarah
>>> p.s. cc'ing laszlo-user in case anyone else wants to chime in and 
>>> since the answer might be interesting to others
> 
> 


Gmane