Re: Passing parameters to a JS function

2006-08-04 Thread Rui Pacheco
I see. I will try that and reply with news. On 8/4/06, Karthik N <[EMAIL PROTECTED]> wrote: The model variable will be a member variable in the Page.java - and your method is in the Page.java - so why can't the method access a member variable of the class it is in? On 8/4/06, Rui Pacheco <[E

Re: Passing parameters to a JS function

2006-08-04 Thread Karthik N
The model variable will be a member variable in the Page.java - and your method is in the Page.java - so why can't the method access a member variable of the class it is in? On 8/4/06, Rui Pacheco <[EMAIL PROTECTED]> wrote: Yes, but if I define the function as you did, then the model variable

Re: Passing parameters to a JS function

2006-08-04 Thread Rui Pacheco
Yes, but if I define the function as you did, then the model variable won't be known inside of it. On 8/4/06, Karthik N <[EMAIL PROTECTED]> wrote: each value is stored in a model object in the page. this is because of ognl:model imagine this being like a for loop for(i=0; i < 10; i++) { }

Re: Passing parameters to a JS function

2006-08-04 Thread Karthik N
each value is stored in a model object in the page. this is because of ognl:model imagine this being like a for loop for(i=0; i < 10; i++) { } each iteration the model object is like "i" so when you refer to model in getFoo you are referring to each model that the for loop is iterating thr

Re: Passing parameters to a JS function

2006-08-04 Thread Rui Pacheco
How do you pass the Model object to your getAnswer function? And while writing the line on the page, how is he going to know which model is that line referring to? On 8/4/06, Karthik N <[EMAIL PROTECTED]> wrote: well what i am suggesting is to create a method called getFoo which is not in your

Re: Passing parameters to a JS function

2006-08-04 Thread Karthik N
well what i am suggesting is to create a method called getFoo which is not in your model. getFoo is on your page class using href=ognl:foo all you are doing is wiring the href to a getFoo method on your page inside getFoo you create the string as follows: public String getAnswer() { return ne

Re: Passing parameters to a JS function

2006-08-04 Thread Rui Pacheco
I don't think I can create a getAnswer method, as my answer variable is inside an object through which I am iterating in a @For loop. The problem with trial and error is that I don't know where to begin. On 8/4/06, Karthik N <[EMAIL PROTECTED]> wrote: please try this: href=ognl:answer and in

Re: Passing parameters to a JS function

2006-08-04 Thread Karthik N
please try this: href=ognl:answer and in public String getAnswer() { return new String ( javascript:alert(" ' "+ ognl:model.answer.toString() + " ' " ); } i recommend you use view source to see the generated HTML and tweak things here and there - with a little trial and error you'll get it r

Re: Passing parameters to a JS function

2006-08-04 Thread Rui Pacheco
I changed my code to this: But now I get an alert saying "ognl:model.answer". On 8/4/06, Karthik N <[EMAIL PROTECTED]> wrote: each value of your For loop is stored in the ognl:model so for your href you need to access the model object to create the alert javascr

Re: Passing parameters to a JS function

2006-08-04 Thread Karthik N
each value of your For loop is stored in the ognl:model so for your href you need to access the model object to create the alert javascript. On 8/4/06, Rui Pacheco <[EMAIL PROTECTED]> wrote: Jesse, how can I access the model in your example? I tried your snippet and it generates an exception.

Re: Passing parameters to a JS function

2006-08-04 Thread Rui Pacheco
Jesse, how can I access the model in your example? I tried your snippet and it generates an exception. On 8/4/06, Jesse Kuhnert <[EMAIL PROTECTED]> wrote: The @Any component is great for this. You can attach a jwcid="@Any" to automatically "decorate" existing random html elements without necess

Re: Passing parameters to a JS function

2006-08-04 Thread Rui Pacheco
Its exactly what you saw on the example before. The difference is, I need the parameter passed to the alert to be created dinamically, instead of a hardcoded "1". On 8/4/06, Karthik N <[EMAIL PROTECTED]> wrote: Can you post a snippet also of what you want the final desired HTML to look like?

Re: Passing parameters to a JS function

2006-08-04 Thread Karthik N
Can you post a snippet also of what you want the final desired HTML to look like? On 8/4/06, Rui Pacheco <[EMAIL PROTECTED]> wrote: Sorry, I guess an example is the best way to show my problem:   I want my want to be generated dinamically. T

Re: Passing parameters to a JS function

2006-08-04 Thread Jesse Kuhnert
The @Any component is great for this. You can attach a jwcid="@Any" to automatically "decorate" existing random html elements without necessarily doing anything specific to one component. In your case (as previously suggested), you could add the jwcid="@Any" and then do something like: href="ogn

Re: Passing parameters to a JS function

2006-08-04 Thread Rui Pacheco
Sorry, I guess an example is the best way to show my problem:   I want my want to be generated dinamically. The number comes from the database, inside an object called Model. How can I place it there? On 8/4/06, Jesse Kuhnert <[EMAIL PROTECTED]> wr

Re: Passing parameters to a JS function

2006-08-04 Thread Jesse Kuhnert
Yes, also don't forget the power of "this" and how it changes depending on context. I'd have to see your code but it's quite possible that you can navigate from "this" to any dom node in your browser if "this" points to a dom node. On 8/4/06, Karthik N <[EMAIL PROTECTED]> wrote: i guess i'm not

Re: Passing parameters to a JS function

2006-08-04 Thread Karthik N
i guess i'm not too clear what you want to achieve: i suppose you can have an informal parameter onclick=ognl:clickAction and then create the javascript in the getClickAction which forms the string based on the current ID On 8/4/06, Rui Pacheco <[EMAIL PROTECTED]> wrote: Hi all I need to pass

Passing parameters to a JS function

2006-08-04 Thread Rui Pacheco
Hi all I need to pass a parameter to a JS alert(). This is repeated in several rows of a table created with a @For component, and the parameter is the id of the elements of the current row. Passing will of course break the JS function and the HTML its in. Can anyone please sugest a different so