Re: How to pass a variable from Javascript code to Java

"Thiago H. de Paula Figueiredo" <[email protected]>
Newsgroups gmane.comp.java.tapestry.user
Message-ID <CAE_88GYKthFCeiG2dOHn+JjNBmD=jh_yza86w72wM71pUDd2cA@mail.gmail.com>
I've just noticed Peter had already posted the same answer as me. I'm sorry.

On Mon, Aug 27, 2018 at 3:24 PM Thiago H. de Paula Figueiredo <
[email protected]> wrote:

> On Sat, Aug 25, 2018 at 3:33 AM marwa hussein <[email protected]>
> wrote:
>
>> Hello,
>
>
> Hi!
>
>
>> I am building a web application and I have to use an open source
>> Javascript package that is responsible for the visualization tasks. Now, I
>> need to pass a "string variable" from the javascript code to the java
>> code?? how to do this in tapestry5 ..Please refer me to a working example
>> if you can!!
>>
>
> Just use HTML's data attributes, just as Tapestry 5.4+ itself does. For
> example, supposing the div below is one which already exists in your page:
>
> <div id="visualization" data-visualization-data="${vizualizationData}">
>
> Then, in your Java code, you compute the visualization data:
>
> public String getVisualizationData() {
>     ...
>     return data;
> }
>
> Then, in your JavaScript, supposing you're using jQuery:
>
> var visualizationData = $('#visualization').attr('visualization-data');
>
> Notice the code above isn't tested. Of course, feel free to adapt it to
> your existing code.
>
> --
> Thiago
>


-- 
Thiago
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.